-1

i am just checking wheather the name or the nick already exists or not. here is the code.m using mysql 5.5.24 with php 5.3.13 with apache 2.2.22.

$query="SELECT realname,nick FROM main WHERE `nick`='$nick' OR `email`='$email'";
$res=mysql_query($query);
if(mysql_num_rows($res)==0){

if it returns 0 thn the connection string follows and the insert statement. the problem is i am getting an error with mysql_num_rows statement

 Warning: mysql_num_rows() expects parameter 1 to be resource, boolean

everythng was working fine but later some updates changed. do i need to switch to mysqli if so how.

gen_Eric
  • 214,658
  • 40
  • 293
  • 332
black
  • 719
  • 5
  • 12
  • 27

1 Answers1

1

Use error checking first for $res to know the specific error

if($res){
   if(mysql_num_rows($res)==0){.......}
}
else{
echo mysql_error();
}
Tim Knox
  • 114
  • 5