Autor |
Beitrag |
FinnO
Beiträge: 1331
Erhaltene Danke: 123
Mac OSX, Arch
TypeScript (Webstorm), Kotlin, Clojure (IDEA), Golang (VSCode)
|
Verfasst: Mi 24.06.09 16:36
Hi Leute,
irgendwann im Leben ist es so weit, man muss einfach PHP lernen. Auch ich bin gerade dabei und erhalte bei folgendem Code immer folgenden Error:
Quelltext 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14:
| $Datenbank = mysql_connect("localhost","imapic","***********") or die ("Keine Verbindung möglich, Passwort oder Nutzername sind falsch!"); //pw geändert echo "Eingeloggt"; $SQLstring = "SELECT vorname FROM php"; $Result = mysql_query($SQLstring); echo "<br>Verbunden"; while($row = mysql_fetch_object($Result)) // hier muss irgendetwas falsch sein { echo "$row->vorname"; } |
Zitat: | Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in /usr/export/www/vhosts/funnetwork/hosting/imapic/Index/PHP/Datenbanken/index.php on line 12 |
//edit: Frage vergessen
Könnt ihr mir vielleicht sagen wodran das liegt, bzw. wie ich den Fehler los werde? Moderiert von Klabautermann: Topic aus Off Topic verschoben am Do 25.06.2009 um 10:12
|
|
jaenicke
Beiträge: 19285
Erhaltene Danke: 1743
W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
|
Verfasst: Mi 24.06.09 16:54
Da fehlt noch mysql_select_db, woher soll denn MySQL sonst wissen auf welche Datenbank du dich beziehst?
|
|
FinnO
Beiträge: 1331
Erhaltene Danke: 123
Mac OSX, Arch
TypeScript (Webstorm), Kotlin, Clojure (IDEA), Golang (VSCode)
|
Verfasst: Mi 24.06.09 16:55
Danke, hab ich auch gerade bemerkt -> wer lesen kann ist klar im vorteil -.-
|
|
BenBE
Beiträge: 8721
Erhaltene Danke: 191
Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
|
Verfasst: Mi 24.06.09 17:25
Man kann den DB-Namen auch in der Query mitreichen ... Zudem müsste für die fehlgeschlagene MySQL-Abfrage eigentlich auch eine Warnung erscheinen ...
_________________ Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
|
|
Martok
Beiträge: 3661
Erhaltene Danke: 604
Win 8.1, Win 10 x64
Pascal: Lazarus Snapshot, Delphi 7,2007; PHP, JS: WebStorm
|
Verfasst: Mi 24.06.09 17:39
BenBE hat folgendes geschrieben : | Man kann den DB-Namen auch in der Query mitreichen ... Zudem müsste für die fehlgeschlagene MySQL-Abfrage eigentlich auch eine Warnung erscheinen ... |
Nope, das gibt bestenfalls eine Notice. Wenn überhaupt, ich muss das immer von Hand machen (mysql_error).
_________________ "The phoenix's price isn't inevitable. It's not part of some deep balance built into the universe. It's just the parts of the game where you haven't figured out yet how to cheat."
|
|
BenBE
Beiträge: 8721
Erhaltene Danke: 191
Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
|
Verfasst: Mi 24.06.09 17:49
Gut. Ich hab für sowas eh nen Custom Error-Handler, der mir ALLE!!! Meldungen um die Ohren haut, und eigenständige DB-Klassen, in denen auch das Escaping bzw. die Arbeit mit Prepared Statements behandelt wird.
_________________ Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
|
|
|