致命错误:未捕获错误:调用未定义函数mysql_result() [英] Fatal error: Uncaught Error: Call to undefined function mysql_result() in
本文介绍了致命错误:未捕获错误:调用未定义函数mysql_result()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
从 mysql_result 更改为 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;
}
推荐答案
请勿混用mysql_*
和mysqli_*
.此外,您不能像使用mysql_*
那样使用mysql_result
.只需替换
Do not mix mysql_*
and mysqli_*
. Furthermore you cannot use mysql_result
in the way you use it with mysql_*
. Just replace this
return (mysql_result($query, 0) == 1) ? true : false;
具有以下内容:
if ($query && mysqli_num_rows($query) == 1) {
$row = mysqli_fetch_assoc()['count_val'];
}
因此,您需要在语句中为计数值使用别名,您应该始终这样做:SELECT COUNT(f_id) as count_val ...
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 ...
有关与mysql_*
中的mysql_result
等效的更多信息,请参见本主题:相当于mysql_result()的MySQLi?
See this topic for more information about an equivalent to the mysql_result
in mysql_*
: MySQLi equivalent of mysql_result()?
这篇关于致命错误:未捕获错误:调用未定义函数mysql_result()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文