This question already has an answer here:
- MySQLi equivalent of mysql_result()? 11 answers
I am getting this error while changing from mysql_result to mysqli_result
function f_exists($f_uname) {
$f_uname = sanitize($f_uname);
$conn = @mysqli_connect('localhost','root','','swift') or die($connect_error);
$query = mysqli_query($conn,"SELECT COUNT(`f_id`) FROM `flight_users` WHERE `f_uname`= '$f_uname'") or die(mysqli_error($conn));
//here is the problem
return (mysql_result($query, 0) == 1) ? true : false;
}
Do not mix
mysql_*
andmysqli_*
. Furthermore you cannot usemysql_result
in the way you use it withmysql_*
. Just replace thiswith the following:
Therefore you need to use an alias for your count value in your statement, which you should always do:
SELECT COUNT(f_id) as count_val ...
See this topic for more information about an equivalent to the
mysql_result
inmysql_*
: MySQLi equivalent of mysql_result()?