View Full Version : PHP Warning Error relating to a MYSQL Query, Basic Help needed, Pls

03-05-2010, 10:18 AM
Hi Everyone,
I keep getting this error in my error_log within my server for a MYSQL query that i'm using on a page. The pages pull the data fro DB and displays it fine but i keep getting these errors, and would like to clean it up. if anyone can see what i s wrong that would be great.

PHP Warning: mysql_numrows(): supplied argument is not a valid MySQL result resource in /home/blahblah/public_html/domain.com/tags.php on line 66

$page = ($_SERVER['REQUEST_URI']);
$table= "table1";
$site= "site1";
$keyword = $_GET['search'];

<div>All stuff Tagged With <? echo"$keyword" ?><br />


if(!isset($start)) $start = 0;

if ($keyword <> ""){

require ('connect/globals.php');
@mysql_select_db($database) or die( "Unable to select database");

$query="SELECT * FROM $table WHERE info LIKE '%$keyword%' ORDER BY id ASC LIMIT $start , 3";
$query2="SELECT * FROM $table WHERE info LIKE '%$keyword%' ORDER BY id ASC ";

LINE 66 $num=mysql_numrows($result);

if ($numrows == 0)

echo "Sorry , nothing found";
echo "<br />";


while ($i < $num) {
$udesc = urlencode($desc);
$firstPart = 'http://domain.com/download.php?';
$unencodedP = "id=$fileID&table=$table&page=$page&site=$site";
$urlToUse = $firstPart . '&amp;p=' . urlencode($unencodedP);
$rawurl = str_replace(' ', '%20', $url);

echo "<img src='thumb/$picbig' alt='test' width='120' height='120'/><a href='$urlToUse&amp;ct=$udesc'><img src='../images/button.gif' alt='test' width='40' height='30'/></a><br/><div class='subtext3'><a href='$urlToUse&amp;ct=$udesc+Video'>$desc <br/></a></div><div class='linebreak'></div>";

Thankyou in-advance

03-05-2010, 10:24 AM
the SQL query fails, and then mysql_query() returns false, which is not the parameter type mysql_num_rows() expects.

can be avoided by

$result = mysql_query($query) or die(mysql_error());

03-05-2010, 06:49 PM
This code


needs to be changed to this one


03-05-2010, 07:21 PM
Yes, that should be updated to mysql_num_rows; however, it should be noted that mysql_numrows does actually exist. Its been retained for all that 10+ish year old code to allow backwards compatibility. So yeah, its been deprecated for like, 10 years now O.o
The error itself indicates that the query has failed.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum