note 5093 deleted from mysql_num_rows by ronabop

From: Date: Sat, 19 Aug 2000 04:13:27 +0000
Subject: note 5093 deleted from mysql_num_rows by ronabop
Groups: php.notes 
Request: Send a blank email to php-notes+get-2623@lists.php.net to get a copy of this message
Why can't I get this to give me the number of rows that match the select statement? The first query is just telling me if it was a valid search. Using this code: $query = "SELECT * FROM $userstable where username = '$username' and password = '$password'"; $query2 = "SELECT COUNT(*) FROM $userstable where username = '$username' and password = '$password'"; $result = MYSQL_QUERY($query); $result2=MYSQL_NUM_ROWS($query2); echo "Search result of query 1: ".$result."<BR><BR>"; echo "Number of rows found: ".$result2; Gives me this result: This is what we are searching for: TORY and SMITH Warning: 0 is not a MySQL result index in /Local/Library/WebServer/Documents/search.php3 on line 33 Search result of query 1: 2 Number of rows found: Authority Level: User Name: Password: 2 Tory Smith If I take out the "COUNT(*)" and use "SELECT *" I still get the error. Please help.

« previous php.notes (#2623) next »