Re: Beginners issue with mysql_num_rows()
From: Pedro Graca (hexkid_at_hotpop.com)
Date: 02/26/04
- Previous message: Geoff Berrow: "Re: Beginners issue with mysql_num_rows()"
- In reply to: David Nikel: "Beginners issue with mysql_num_rows()"
- Next in thread: Tom Thackrey: "Re: Beginners issue with mysql_num_rows()"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 26 Feb 2004 20:24:53 GMT
David Nikel wrote:
> The following snippet of code:
>
> $query = "select * from auth where username='$username' and
> password=password('$password')";
> $result = mysql_query($query, $db_conn);
> $num = mysql_num_rows($result);
> echo $num;
>
> produces the following result:
>
> Warning: mysql_num_rows(): supplied argument is not a valid MySQL
> result resource in prototype4\admin.php on line 14
This means the mysql_query() call produced /something/ that is not valid
for mysql_num_rows() (probably your call has the same effect as
$result = false;
and you can't do mysql_num_rows(false);).
> I've searched high and low and cannot find a reason why this isn't
> working.
I can't tell what's wrong either -- but why not let PHP/MySQL tell you?
$result = mysql_query($query, $db_conn) or die(mysql_error() . ' on ' . $query);
> I am however, a beginner to PHP, so please forgive me if
> there's an obvious mistake!
Maybe $username and $password are not what you think they are?
Are these variables 'sanitized'? You don't want to pass "Mc'Donald" to
the query "as is".
Except for the lack of error-checking (and possibly making the variables
safe) I see nothing wrong.
> Thanks in advance for any help anyone can give
You're welcome. Hope this helps.
--
--= my mail box only accepts =--
--= Content-Type: text/plain =--
--= Size below 10001 bytes =--
- Previous message: Geoff Berrow: "Re: Beginners issue with mysql_num_rows()"
- In reply to: David Nikel: "Beginners issue with mysql_num_rows()"
- Next in thread: Tom Thackrey: "Re: Beginners issue with mysql_num_rows()"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|