PDA

View Full Version : error message ???


Curiousguy
09-07-2003, 05:25 PM
wat is this error message means ??? , but this code still able to perform the function....


Warning: Supplied argument is not a valid MySQL result resource in
c:\phpweb/view_group.php on line 41


34<?
35 echo "<TABLE width=\"40%\" CELLSPACING=\"0\" CELLPADDING=\"0\" BORDER=\"1\" align=center>";
36 echo "<TR><TD width=\"15%\" align=center height=\"30\"><font face=\"Arial Narrow\"><font size=\"4\">Group</font></TD><TD width=\"15%\" align=center height=\"30\"><font face=\"Arial Narrow\"><font size=\"4\">Username</font></TD><td width=\"5%\" align=center><font face=\"Arial Narrow\"><font size=\"4\">Action</td></TR>\n";
37 while ($number_of_array = mysql_fetch_array($result1))
38 {
39 $call = $number_of_array[group1];
40 $result2 = mysql_query("select * from $call");
41 while ($number_of_array1 = mysql_fetch_array($result2))
42 {
43 echo "<tr>\n";
44 echo "<TD align=center><font face=\"Arial Narrow\"><font size=\"3\">$number_of_array[group1]</font></TD>\n";
45 echo "<TD align=center><font face=\"Arial Narrow\"><font size=\"3\">$number_of_array1[username]</font></TD>\n";
46 echo "<td align=center><font face=\"Arial Narrow\"><form name=\"form1\" method=\"post\" action=\"main3.php?username=$number_of_array1[username]&group2=$number_of_array1[group2]\" onClick=\"return confirm('Are you sure you want to delete this record? ');\"><br><input type=\"submit\" name=\"Submit\" value=\"Delete\" ></form></font></TD>\n";
47 }
48 }
49?>

Nightfire
09-07-2003, 05:44 PM
while ($number_of_array1 = mysql_fetch_array($result2))

What's that 1 doing there?

raf
09-07-2003, 05:46 PM
We can't see that from your code.

Could be that the resultset is empty or that you don't have an activa MySQL connection.

When you run a select, you always need to do some checks, like

$sql_select="select * from $call";
$result2 = mysql_query($sql_select,$link) or die(mysql_error());
//$link is the connectionhandler --> not required

if ($result2){
if (mysql_num_rows($result2)== 0){ // always check if there are records --> an empty recordset will also return $result2 = TRUE
echo ("<br/><font color='red'><b>No records found</b></font>");
echo ("<br/><br/><a href='javascript:history.back();'>Back<br></a>");
}
else {
...
}
}


If this doesn't help, please post the code that is above the select