gpt4 book ai didi

php - fatal error : Call to undefined function mysqli_result() with click counter function

转载 作者:行者123 更新时间:2023-11-30 22:57:43 30 4
gpt4 key购买 nike

这是我计算ips点击次数的函数,

function get_client_ip() {
$ipaddress = '';
if (getenv('HTTP_CLIENT_IP'))
$ipaddress = getenv('HTTP_CLIENT_IP');
else if(getenv('HTTP_X_FORWARDED_FOR'))
$ipaddress = getenv('HTTP_X_FORWARDED_FOR');
else if(getenv('HTTP_X_FORWARDED'))
$ipaddress = getenv('HTTP_X_FORWARDED');
else if(getenv('HTTP_FORWARDED_FOR'))
$ipaddress = getenv('HTTP_FORWARDED_FOR');
else if(getenv('HTTP_FORWARDED'))
$ipaddress = getenv('HTTP_FORWARDED');
else if(getenv('REMOTE_ADDR'))
$ipaddress = getenv('REMOTE_ADDR');
else
$ipaddress = 'UNKNOWN';
return $ipaddress;

和点击计数器

function update_visitas($id,$ip) {
global $dbc;
$sql = "SELECT COUNT(*) FROM ipclicks WHERE ip = " . ip2long($ip) . " and ads = " . $id;

$res=mysqli_query($dbc,$sql);

if (mysqli_result($res, 0)==0){
$sql = "INSERT INTO ipclicks VALUES (" . ip2long($ip) . "," . $id . ")";
#echo $sql;
$res=mysqli_query($dbc,$sql);

$sql = "UPDATE ads SET vistas = vistas +1 WHERE id_ad = " . $id;
#echo $sql;
$res=mysqli_query($dbc,$sql);
}

如何替换此函数中的 mysqli_result 以避免此错误? fatal error :调用未定义函数 mysqli_result()

最佳答案

不推荐使用的 mysql 函数和 mysqli 函数之间没有 1:1 的精确匹配。您必须获取一行作为数组,然后检查其中的一个元素。

例子:

$res = mysqli_query($dbc,$sql);
$row = mysqli_fetch_row($res);
if ($row[0]==0){
. . .

关于php - fatal error : Call to undefined function mysqli_result() with click counter function,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25538635/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com