Autor Beitrag
Supernova
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 108

WinXP
D7 Prof
BeitragVerfasst: Di 17.01.06 17:36 
Hallo,

ich bekomme bei meinem GB-Script folgende Fehlermedlung:

ausblenden Quelltext
1:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource ... on line 100					


Zeile 100 sieht dabei so aus:

ausblenden Quelltext
1:
for($i=0;$i<mysql_num_rows($result);$i++)					


+/- 5 Zeilen:

ausblenden Quelltext
1:
2:
3:
4:
5:
$result = mysql_query($sql, $link);
for($i=0;$i<mysql_num_rows($result);$i++)
{
$ergebnis[$i]=mysql_fetch_array($result);
}


Ich weis einfach nicht was ich da Falsch mache... :cry:

Grüße,
Supernova

_________________
Input - Output => Ganz Kaputt
*** MFG Supernova ***
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: Di 17.01.06 17:41 
Welche SQL-Abfrage führst Du aus?

Was meldet Dir is_resource($result)???

Prüfe den Wert $result einmal gegen false === $result ...

_________________
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.
Supernova Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 108

WinXP
D7 Prof
BeitragVerfasst: Di 17.01.06 18:42 
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
$tabellenname="guestbook";
$sql="SELECT absender, betreff, message, datum FROM $tabellenname WHERE check=1 ORDER BY datum DESC ";
$link = mysql_connect("localhost", "**", "***");
mysql_select_db("**", $link);
$result = mysql_query($sql, $link);
for($i=0;$i<mysql_num_rows($result);$i++)
{
$ergebnis[$i]=mysql_fetch_array($result);
}

_________________
Input - Output => Ganz Kaputt
*** MFG Supernova ***
TriphunEM
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 97



BeitragVerfasst: Di 17.01.06 19:46 
das heißt das mysql_num_rows() kein gültigen wert im $result bekommt. der fehler wird im query liegen.
führe deine query (sql-anweisung -> SELECT...) mal im phpmyadmin aus. der sagt dir dann genau wo der fehler liegt!

ich empfehle dir aber keine for schleife zu nehmen. man macht das eher so :

ausblenden Quelltext
1:
2:
3:
4:
while ($data=mysql_fetch_array($result))
{
  echo $data["message"];
}
matze.de
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 576

Win95, Win98 SE, WinXp Prof SP2
D7P, D8P, FPC2.0
BeitragVerfasst: Mi 18.01.06 12:50 
Ändere deine Query mal um von $sql="SELECT absender, betreff, message, datum FROM $tabellenname WHERE check=1 ORDER BY datum DESC ";
in
$sql="SELECT absender, betreff, message, datum FROM ".$tabellenname." WHERE check='1' ORDER BY datum DESC";

mfg matze

_________________
si tacuisses, philosophus mansisses.
alcaeus
half ontopic starofftopic starofftopic starofftopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 226



BeitragVerfasst: Mi 18.01.06 14:07 
user profile iconmatze.de hat folgendes geschrieben:
Ändere deine Query mal um von [...]


Und was soll das bringen? Er hat das Query in " eingeschlossen, also wird $tabellenname auch geparst. Und solange check ein int-feld ist, muss er den wert auch nicht mit ' umschliessen ;)

Greetz
alcaeus
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 18.01.06 14:18 
1. Feldnamen in Backticks ... `` Auch wenn MySQL es ohne annimmt, kann es zu Problemen kommen, wenn man sie nicht nutzt.

@alcaeus:matze hat in der WHERE-Clause den Wert in '' (Single Quotes) eingeschlossen. Sollte man auch überall bei Werten machen ...

_________________
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.
Supernova Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 108

WinXP
D7 Prof
BeitragVerfasst: Mi 18.01.06 18:35 
Jungs, hab den fehler gefunden... "check" ist ein reserviertes Wort vom MySQL :wink:

Trotzdem Danke,
Grüße,
Supernova

_________________
Input - Output => Ganz Kaputt
*** MFG Supernova ***