I have placed a code onto my site, i made it, but it gives a MySQL error. However, when I look, the code still does what it was meant to do.
Here's the Code:
[CODE START]
$totaltournaments=mysql_query("SELECT COUNT(*) FROM tourneys");
$totaltournaments= mysql_fetch_array($totaltournaments);
$totaltournaments= "$totaltournaments[0]";
if($totaltournaments == 0){
$headerTourn = "<li><a href='javascript:;' target='_self'>No current tournaments.</a></li>";
}else{
$headerTourn = mysql_query("SELECT id,name,size FROM tourneys ORDER BY id");
while( list($id,$name,$size) = mysql_fetch_array($headerTour) ){
$spotsleft=mysql_query("SELECT COUNT(*) FROM tourneyplayers WHERE tourneyid='$id'");
$spotsleft= mysql_fetch_array($spotsleft);
$spotsleft=$spotsleft[0];
if($spotsleft >= $size){
$spots="FULL";
}else{
$spots="$spotsleft/$size";
}
$headerTourn .= "<li><a href='./tournaments.php?tourney[id]=$id' target='_self'>$name - [$spots]</a></li>";
}
}
[CODE END]
...and the outcome:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in ----/html.php on line 443
This is what shows up where it 'works':
Resource id #17
Halloween Singles Snipe Out - [6/8]
What is wrong with the script above, it does not look like I made any syntax errors? (It shouldn't show "Resource id #17")
Please don't give me an answer to add @ at the beginning, I'm aware of what that does. I want to know WHY its doing it. Thank you.
To output code is:
<? echo headerTourn; ?>
I found the answer, dumb mistake, correct answer gets the ten points.
It doesn't ahve to do with, for the most part this:
mysql_fetch_array($headerTour)
In fact, I have no clue why it got rid of the 'n' ($headerTourn).
It's supposed to be:
mysql_fetch_array($headerTourn)
Here's the Code:
[CODE START]
$totaltournaments=mysql_query("SELECT COUNT(*) FROM tourneys");
$totaltournaments= mysql_fetch_array($totaltournaments);
$totaltournaments= "$totaltournaments[0]";
if($totaltournaments == 0){
$headerTourn = "<li><a href='javascript:;' target='_self'>No current tournaments.</a></li>";
}else{
$headerTourn = mysql_query("SELECT id,name,size FROM tourneys ORDER BY id");
while( list($id,$name,$size) = mysql_fetch_array($headerTour) ){
$spotsleft=mysql_query("SELECT COUNT(*) FROM tourneyplayers WHERE tourneyid='$id'");
$spotsleft= mysql_fetch_array($spotsleft);
$spotsleft=$spotsleft[0];
if($spotsleft >= $size){
$spots="FULL";
}else{
$spots="$spotsleft/$size";
}
$headerTourn .= "<li><a href='./tournaments.php?tourney[id]=$id' target='_self'>$name - [$spots]</a></li>";
}
}
[CODE END]
...and the outcome:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in ----/html.php on line 443
This is what shows up where it 'works':
Resource id #17
Halloween Singles Snipe Out - [6/8]
What is wrong with the script above, it does not look like I made any syntax errors? (It shouldn't show "Resource id #17")
Please don't give me an answer to add @ at the beginning, I'm aware of what that does. I want to know WHY its doing it. Thank you.
To output code is:
<? echo headerTourn; ?>
I found the answer, dumb mistake, correct answer gets the ten points.
It doesn't ahve to do with, for the most part this:
mysql_fetch_array($headerTour)
In fact, I have no clue why it got rid of the 'n' ($headerTourn).
It's supposed to be:
mysql_fetch_array($headerTourn)