View Full Version : num_rows()?
sabret00the
02-12-2005, 02:49 PM
why won't this work?
$totalquery = $DB_site->query_first("SELECT* FROM grps WHERE title LIKE '%" . addslashes($search) . "%' ORdescription LIKE '%" . addslashes($search) . "%'");
$totalresults = number_format($DB_site->num_rows($totalquery));
the error i'm getting is
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in \includes\db_mysql.php on line 312
$totalquery = $DB_site->query("SELECT * FROM grps WHERE title LIKE '%".addslashes($search)."%' OR description LIKE '%".addslashes($search)."%'");
$totalresults = number_format($DB_site->num_rows($totalquery));
?
noppid
02-12-2005, 02:58 PM
Using query fiirst returns the first row, not the identifier.
Edited:
filburt1
02-12-2005, 03:45 PM
You should use COUNT(), not SELECT *.
SELECT COUNT(unique id column name) AS totalcount FROM grps WHERE title LIKE "expression%
It will return a single result row with a column name of totalcount containing the number of matching rows.
Don't forget TABLE_PREFIX.
deathemperor
02-12-2005, 04:26 PM
it's because he wrote "SELECT*" instead of "SELECT *"
sabret00the
02-12-2005, 05:48 PM
You should use COUNT(), not SELECT *.
SELECT COUNT(unique id column name) AS totalcount FROM grps WHERE title LIKE "expression%
It will return a single result row with a column name of totalcount containing the number of matching rows.
Don't forget TABLE_PREFIX.
thanks that fixed it perfectly
Using query fiirst returns the first row, not the identifier.
Edited:
seems i should've used query, didn't think of that.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.