error using mysql_num_rows()
Posted by: alanmarcel (---.user.veloxzone.com.br)
Date: November 03, 2006 03:20PM

I am using the function mysql_num_rows() and I have received the Warning:

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\wamp\www\final\resultUsers.php on line 32


Look at my code:

mysql_select_db('item');
$query = "SELECT * FROM item WHERE ".$tipoProcura." LIKE '%".$termoProcura."%'";
$result = mysql_query($query);

$num_results = mysql_num_rows($result); <------------
echo '<p> NĂºmero de itens encontrados: '.$num_results.'</p>';


I think it's a PHP5's problem..

Options: ReplyQuote
Re: error using mysql_num_rows()
Posted by: CyberSpatium (71.237.217.---)
Date: November 03, 2006 08:18PM

$conn = mysql_connect ('localhost', 'username', 'password');

mysql_select_db('item', $conn);

$query = "SELECT * FROM item WHERE ".$tipoProcura." LIKE '%".$termoProcura."%'";

$result = mysql_query($query, $conn);

$num_results = mysql_num_rows($result);



CyberSpatium
WAMP English Forum Admin

Options: ReplyQuote
Re: error using mysql_num_rows()
Posted by: Andre Rotband (---.PAEMT705.e.brasiltelecom.net.br)
Date: November 03, 2006 09:00PM

Try to print your $query variable.

mysql_select_db('item');
$query = "SELECT * FROM item WHERE ".$tipoProcura." LIKE '%".$termoProcura."%'";
print $query;
$result = mysql_query($query);

And try:

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

to see if your query have a error.



Post Edited (11-03-06 21:02)

Options: ReplyQuote


Sorry, only registered users may post in this forum.