For Programmers: Free Programming Magazines  


Home > Archive > PHP DB > November 2004 > RE: [PHP-DB] Problems with mysql_num-rows()









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author RE: [PHP-DB] Problems with mysql_num-rows()
Bastien Koert

2004-11-01, 3:55 am

Very simply, either your connection is messed up, you are not getting a
result set back or there is an error in your sql

try this:

$result = mysql_query($query, $link) or die ("failed because
".mysql_error());


then start debugging

bastien





>From: "Arne Essa Madsen" <arne@aem-engineering.dk>
>Reply-To: "Arne Essa Madsen" <arne@aem-engineering.dk>
>To: php-db@lists.php.net
>Subject: [PHP-DB] Problems with mysql_num-rows()
>Date: Sun, 31 Oct 2004 19:32:09 +0100
>
>I have the following problem:
>
>This one does not work:
> $query = "SELECT * from user where name='$userid' and
>pass=password('$password')";
> $result = mysql_query($query, $link);
> $num_rows = mysql_num_rows($result);
>
>I get this error message:
>Warning: mysql_num_rows(): supplied argument is not a valid MySQL result
>resource in c:\wamp\www\fs1812_new\authmain.php on line 18
>
>This one works OK:
> $query = "SELECT * FROM user";
> $result = mysql_query($query, $link);
> $num_rows = mysql_num_rows($result);
>
>What is wrong and how can I use mysql_num_rows when the query include
>"WHERE"
>
>A fast response will be very much appreciated.
>
>Arne Essa Madsen;
>arne@aem-engineering.dk
>
>--
>PHP Database Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php
>

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com