gpt4 book ai didi

php - 从 MYSQL 转换为 MYSQLI

转载 作者:行者123 更新时间:2023-12-01 00:23:20 24 4
gpt4 key购买 nike

<分区>

我正在尝试将旧站点转换为使用 mysqli 而不是 mysql。

这段代码遇到了一些障碍

if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}

$theValue = function_exists("mysqli_real_escape_string") ? mysqli_real_escape_string($theValue) : mysqli_escape_string($theValue);

switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}

我不断收到错误

Warning:  mysqli_real_escape_string() expects exactly 2 parameters, 1 given in 

Warning: mysqli_real_escape_string() expects exactly 2 parameters, 1 given in

如果我像这样添加连接

$theValue = function_exists("mysqli_real_escape_string") ? mysqli_real_escape_string($test,$theValue) : mysqli_escape_string($test,$theValue);

得到错误

Warning:  mysqli_real_escape_string() expects parameter 1 to be mysqli, null given



Warning: mysqli_real_escape_string() expects parameter 1 to be mysqli, null given

谁能告诉我我做错了什么

非常感谢

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