Page 1 of 1

mysql_num_rows and related

Posted: Mon Jan 06, 2003 10:12 am
by PingLeeQuan
This is driving me crazy and i am so tired of working around it... can some one please tell me why every time i try to run "mysql_num_rows" it gives me the following message

---code---
$CheckButtonIN_QRY = "select * from tregON where Active = 1 and tempNav=1 and tempName='".$zoneitT."'";
$CheckButtonIN_Result = mysql_query($CheckButtonIN_QRY);
$rrr=mysql_num_rows(CheckButtonIN_Result);

---msg ---
* * * Supplied argument is not a valid MySQL result resource xxxxxxxx


i looked in the manual and i did not find any information about it being deprecated.!... yet it worked on another server that we had but it does not work now. Both are using teh same version of mysql.


i am having similar problem whenever i try to retrieve the fields, table names........ just about anything that does not have a SELECT, INSERT, or UPDATE.

if i am doing something wrong, please let me know so i can kik my self in the axx

:x

Posted: Mon Jan 06, 2003 11:58 am
by Elmseeker
Error is here:

$rrr=mysql_num_rows(CheckButtonIN_Result);

it should be:

$rrr=mysql_num_rows($CheckButtonIN_Result);

Posted: Mon Jan 06, 2003 12:57 pm
by PingLeeQuan
thanks Elmseeker... the problem is solved... i still remeber times where i had the $ for the variable and it still did not work...

thanks again.

Posted: Tue Jan 07, 2003 3:20 am
by twigletmac
PingLeeQuan wrote:i still remeber times where i had the $ for the variable and it still did not work...
If there is something wrong with the SQL statement and mysql_query() is unable to return a valid result and there is no error handling to catch this then the call to mysql_num_rows() will fail. When debugging this sort of problem you can do something like:

Code: Select all

<?php
$CheckButtonIN_QRY = "SELECT * FROM tregON WHERE Active = 1 AND tempNav = 1 AND tempName = '$zoneitT'"; 
$CheckButtonIN_Result = mysql_query($CheckButtonIN_QRY) or die(mysql_error().'<p>'.$CheckButtonIN_QRY.'</p>'); 

$rrr = mysql_num_rows($CheckButtonIN_Result);
?>
Using the or die() statement will kill the script if mysql_query() fails and mysql_error() will tell you what MySQL thinks the problem is.

Mac