473,325 Members | 2,785 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

error using mysql_num_rows( )

Ive got the following code which works great on my localserver, but
when i upload it to my service provider i get an error

"Warning: mysql_num_rows(): supplied argument is not a valid MySQL
result resource in /opt2/home3/mitas/public_html/register.php on line
86

It seems to be only this function mysql_num_rows() causing a problem,
and the rest of the code works ok, and it adds data correctly.

I have checked with the provider, and they are using
PHP 4.3.10
mySQL 4.0.26

While im using
PHP 5.12
mySQL 5.0.15

Im wondering is this function supported by the older versions ?
Or any other ideas.

CODE------------------------------------------------------------
82 $conn=@mysql_connect( "myServer", "myUser", "myPassword" ) or die(
"Err:Conn" );
83 $rs = @mysql_select_db( "myDatabase", $conn) or die( "Err:Db" );

84 $sql="SELECT eMail FROM tblusers WHERE eMail=\"$eMail\" ";
85 $rs=mysql_query($sql,$conn);
86 $mRecLen=mysql_num_rows($rs);
87 if ($mRecLen>=1) {
88 exit("Sorry,the record exists try another" );
89 }

END CODE----------------------------------------------------

Thanks
Fish44

Mar 23 '06 #1
4 1739

Fish44 wrote:
Ive got the following code which works great on my localserver, but
when i upload it to my service provider i get an error

"Warning: mysql_num_rows(): supplied argument is not a valid MySQL
result resource in /opt2/home3/mitas/public_html/register.php on line
86


It means it exactly what it says - $rs is not a valid resource, which
means the line that gives $rs has failed.

echo mysql_error() after every MySQL call, to find out what the problem
is.
P.S. You probably want to put quotes around the e-mail address in the
query, and also call mysql_real_escape_string() on $eMail.

--
Oli

Mar 23 '06 #2
Try :

$sql="SELECT eMail FROM tblusers WHERE eMail='$eMail' ";

Mar 23 '06 #3
LJB
If you do not have a valid resource you will always get an error.

Try catching your resource in an "if" statement.

If($rs) {
do this....
} else {
do something else...
}

If nothing is selected and there are no matching rows you will
not get a valid resource.

Oli Filth wrote:
Fish44 wrote:
Ive got the following code which works great on my localserver, but
when i upload it to my service provider i get an error

"Warning: mysql_num_rows(): supplied argument is not a valid MySQL
result resource in /opt2/home3/mitas/public_html/register.php on line
86

It means it exactly what it says - $rs is not a valid resource, which
means the line that gives $rs has failed.

echo mysql_error() after every MySQL call, to find out what the problem
is.
P.S. You probably want to put quotes around the e-mail address in the
query, and also call mysql_real_escape_string() on $eMail.

Mar 26 '06 #4
Thanks for all the replies. The problem was an obvious one and i should
have picked it up.
It was the case was incorrect in some table names.

Worked fine local (windows apache), but when i put it on my website,
(apache / Linux) case was important.
Oli your advice was spot on, espacially the mysql_errror|() function
which gave me the name of the table at fault.

Mar 29 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: lawrence k | last post by:
I've made it habit to check all returns in my code, and usually, on most projects, I'll have an error function that reports error messages to some central location. I recently worked on a project...
1
by: d3vkit | last post by:
Alright I can not figure this one out, so I'm guessing it's some simple typo and some extra eyes will help me spot it. Here's the query (already connected to DB everything works in that respect):...
9
nomad
by: nomad | last post by:
When I run this program I get an error. The error appears after I select the second link. I get this error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL...
10
by: priyakollu | last post by:
hi guyz! please help me in sorting out error as im unable to find it... my requirement is there will be userid field and password field and "login" button after clicking button certain validations...
6
by: ashraf02 | last post by:
can some one please help me i am getting this error but i cant seem to figure out wat is wrong on line 3 everything looks fine <?php $conn = mysql_connect("localhost","root","") or die...
15
by: Lawrence Krubner | last post by:
Does anything about this script look expensive, in terms of resources or execution time? This script dies after processing about 20 or 25 numbers, yet it leaves no errors in the error logs. This is...
14
luckysanj
by: luckysanj | last post by:
$sql_result=mysql_query($query) or die("Error in Checking User".mysql_error()); echo $no=mysql_num_rows($sql_result); if($no<>1) { return(false); } else { return...
2
by: bips2008 | last post by:
The code seems to work fine in other browser but in IE it throws this error. This is very urgent for me and any help would be greatly appreciated For your convienence i have posted the code for the...
1
by: chienee | last post by:
here is the code <?php session_cache_limiter('private,must-revalidate'); session_start(); require_once("config.php"); include ("classes/db_functions.php"); include ("classes/display.php");
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.