mysql_num_rows() supplied argument is not a valid mysql result resource in php -


i want insert values usertable in database , if emailid exist don't want details entered in database , return error client side. code inserts values table if emailid exist.

my code is

<?php $con=mysqli_connect("localhost","username","password","databasename"); // check connection if (mysqli_connect_errno()) {     echo "failed connect mysql: " . mysqli_connect_error(); }  $result = mysqli_query($con,"select * usertable useremail='name@gmail.com'");  $number_of_rows = mysql_num_rows($result);  if ($number_of_rows > 0) {     die('this email exists in database'); } else {     $sql="insert usertable(username, useremail, usertype) values ('newname', 'name@gmail.com', 'usertypeval' )";       if (!mysqli_query($con,$sql))     {         die('error: ' . mysqli_error($con));     }     echo "1 record added"; } mysqli_close($con); ?> 

error:

warning: mysql_num_rows(): supplied argument not valid mysql result resource in /home/applicat/public_html/stampede/new.php on line 14 

record gets added database each time. doing wrong here. please help.

you have use mysqli_num_rows if using mysqli_* functions

$number_of_rows = mysqli_num_rows($result); 

Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -