Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in

Reply

Join Date: May 2006
Posts: 3
Reputation: Zayed is an unknown quantity at this point 
Solved Threads: 0
Zayed Zayed is offline Offline
Newbie Poster

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in

 
0
  #1
May 31st, 2006
[code]
[php]
<?php
$SearchType = $_POST["SearchPlace"];
$host= 'localhost';
$user= 'user';
$passwd= 'password';
$database= 'dbase';
$table1= 'BUS';
$table2= 'STUDENT';

$connect= mysql_connect($host, $user, $passwd);
mysql_select_db($database);
$pquery = "select busNo from $table1 where place like '".$SearchType."'";

$squery = "select * from $table2 where busNo like '".$pquery."'";

$run = mysql_query($squery);
$num_results = mysql_num_rows($run);




if (!$SearchType )
{
echo "<b>You have not selected search details. Please go back and try again.</b>";
}
else
{

if (!$connect)
{
echo"</b>Error: Could not connect to database. Please try again later.</b>";
}

else
{
for ($i=0; $i<$num_results; $i++)
{
$row = mysql_fetch_array($run);

$IDNo= stripslashes($row["IDNo"]);
$sName= stripslashes($row["sName"]);
$startDate= stripslashes($row["startDate"]);
$endDate = stripslashes($row["endDate"]);
$sPhone= stripslashes($row["sPhone"]);
$OBox= stripslashes($row["OBox"]);
$busNo= stripslashes($row["busNo"]);

echo "<tr>\n";
echo "<td align=left>\n";
echo "<p> Student ID: ".$IDNo."";
echo "<br>Student Name: ".$sName."";
echo "<br>Starting Date: ".$startDate."";
echo "<br>Ending Date: ".$endDate."";
echo "<br>Student Phone: ".$sPhone."";
echo "<br>P.O.Box: ".$OBox."";
echo "<br>Bus number: ".$busNo."";
echo "</p>";
echo "</td></tr>\n";

echo "\n";
echo "\n";
echo "</table>\n";
}

}
}
?>
[inlinecode]
[/php]

Hi I am getting this warning and I don't know why?!! :!:

please can you help me to find the error
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 32
Reputation: BlazingWolf is an unknown quantity at this point 
Solved Threads: 1
BlazingWolf BlazingWolf is offline Offline
Light Poster

Re: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in

 
0
  #2
May 31st, 2006
Your query is probably failing. Try

[php]$run = mysql_query($squery) or die(mysql_error());[/php]

And see if you get an error.

Or echo out your SQL statment and trying running it against the database.
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 3
Reputation: Zayed is an unknown quantity at this point 
Solved Threads: 0
Zayed Zayed is offline Offline
Newbie Poster

Re: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in

 
0
  #3
May 31st, 2006
I tried
[php]
$run = mysql_query($squery) or die(mysql_error());
[/php]

I got this message "Query was empty"

Wat does this mean?
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 5
Reputation: cdwhalley.com is an unknown quantity at this point 
Solved Threads: 0
cdwhalley.com's Avatar
cdwhalley.com cdwhalley.com is offline Offline
Newbie Poster

Re: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource

 
0
  #4
May 31st, 2006
[PHP]
$pquery = "select busNo from $table1 where place like '".$SearchType."'";

$squery = "select * from $table2 where busNo like '".$pquery."'";
[/PHP]
If $_POST['searchplace'] was given as "Foobar" (for want of a better example), $squery would be set to:
select * from STUDENT where busNo like 'select busNo from BUS where place like 'Foobar''
Try running that by itself :-|
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC