Autor Beitrag
FinnO
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1331
Erhaltene Danke: 123

Mac OSX, Arch
TypeScript (Webstorm), Kotlin, Clojure (IDEA), Golang (VSCode)
BeitragVerfasst: 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:

ausblenden 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 :roll:

Könnt ihr mir vielleicht sagen wodran das liegt, bzw. wie ich den Fehler los werde?


Moderiert von user profile iconKlabautermann: Topic aus Off Topic verschoben am Do 25.06.2009 um 10:12
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19272
Erhaltene Danke: 1740

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: 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 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1331
Erhaltene Danke: 123

Mac OSX, Arch
TypeScript (Webstorm), Kotlin, Clojure (IDEA), Golang (VSCode)
BeitragVerfasst: Mi 24.06.09 16:55 
Danke, hab ich auch gerade bemerkt :-o -> wer lesen kann ist klar im vorteil -.-
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: 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
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 3661
Erhaltene Danke: 604

Win 8.1, Win 10 x64
Pascal: Lazarus Snapshot, Delphi 7,2007; PHP, JS: WebStorm
BeitragVerfasst: Mi 24.06.09 17:39 
user profile iconBenBE hat folgendes geschrieben Zum zitierten Posting springen:
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
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: 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.