i cant understand why this error commimng up

<?php

$mysql_host="xxxx.xxxxxx.xxxx";
$mysql_user="anuncios";
$mysql_password="xxxxxxx";
$mysql_db = "suecia"; 

$conn = mysql_connect("$mysql_host","$mysql_user","$mysql_password")
or die("Could not connect : " . mysql_error());

mysql_select_db("$mysql_db",$conn)
 
or die("Select database failed"); 
 
$code = mysql_query("Select * from jos_call  where code = '".@$_REQUEST['nombre']."'",@$conn);

if (mysql_num_rows($conn)==0){                        //error here//

echo @$_REQUEST['nombre'].' - Codigo correcto';

}else{

echo @$_REQUEST['nombre'].' - Codigo falso';

mysql_close($conn);
}

?>

Recommended Answers

All 7 Replies

What is the warning? Also, using error suppression is usually bad practice unless absolutely necessary. You should create cases if the variables don't exist so you can easily handle it either way.

the error is :

Warning: mysql_num_rows(): supplied resource is not a valid MySQL result resource in /xxxx/xxxx/xxxx
comprueba.php on line 20

i have add this and the error is the same: $code = mysql_query("Select * from jos_call where code = '".@$_REQUEST['nombre']."'",@$conn) or die (mysql_error());

oh, heh, you're giving mysql_num_rows the connection, you should be giving it the result.

mysql_num_rows($code)

oh, heh, you're giving mysql_num_rows the connection, you should be giving it the result.

mysql_num_rows($code)

hi

i have tested with your suggestion
but i have received the same error .

Warning: mysql_num_rows(): supplied resource is not a valid MySQL result resource in

Hii..

Try this..

if (mysql_num_rows($code)==0)
{

You should put the result set from mysql_query i.e. $code in mysql_num_rows...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.