mysql_num_rows and related

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
PingLeeQuan
Forum Commoner
Posts: 58
Joined: Tue Sep 03, 2002 8:08 am

mysql_num_rows and related

Post 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
User avatar
Elmseeker
Forum Contributor
Posts: 132
Joined: Sun Dec 22, 2002 5:48 am
Location: Worcester, MA

Post by Elmseeker »

Error is here:

$rrr=mysql_num_rows(CheckButtonIN_Result);

it should be:

$rrr=mysql_num_rows($CheckButtonIN_Result);
PingLeeQuan
Forum Commoner
Posts: 58
Joined: Tue Sep 03, 2002 8:08 am

Post 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.
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post 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
Post Reply