I am using following code which is not working for me.
$con=mysqli_connect(\"localhost\",\"root\",\"\",\"my_db\");
$check=\"SELECT COUNT(*) FROM persons WHER
mysqli_query function returns a resultset handle. You then need to read the rows from it:
$rs = mysqli_query($con,$check);
$data = mysqli_fetch_array($rs, MYSQLI_NUM);
if($data[0] > 1) {
//user exists;
}
Also note that SELECT count(1) FROM ... will be faster than SELECT count(*) FROM ... You won't see much of a difference in a small table, but with a large table of several hundred thousand rows, the difference may be significant.