gpt4 book ai didi

php - Warning : mysqli_real_escape_string() expects exactly 2 parameters, 1 given in... fatal error :调用成员函数 query() on null in

转载 作者:搜寻专家 更新时间:2023-10-30 19:59:11 24 4
gpt4 key购买 nike

<分区>

我的数据库连接有问题,我真的不明白我应该做什么。谁能帮帮我?

Warning: mysqli_real_escape_string() expects exactly 2 parameters, 1 given in /customers/f/4/7/zebratv.se/httpd.www/classes/db.php on line 47 Fatal error: Call to a member function query() on null in /customers/f/4/7/zebratv.se/httpd.www/classes/db.php on line 61

<?php
class db
{

public function __construct()
{
global $CONFIG;
$mysqli = $CONFIG->get("database");
$this->dbconn($mysqli["host"], $mysqli["username"], $mysqli["password"], $mysqli["database"]);

}
private function dbconn($mysqli_host, $mysqli_user, $mysqli_pass, $mysqli_db)
{


if (!($conn = new mysqli($mysqli_host, $mysqli_user, $mysqli_pass)))
{
switch (mysqli_errno($conn))
{
case 1040:
case 2002:
if ($_SERVER[REQUEST_METHOD] == "GET")
die("<html><head><meta http-equiv=refresh content=\"5 $_SERVER[REQUEST_URI]\"></head><body><table border=0 width=100% height=100%><tr><td><h3 align=center>The server load is very high at the moment. Retrying, please wait...</h3></td></tr></table></body></html>");
else
die("Too many users. Please press the Refresh button in your browser to retry.");
default:
die("[" . mysqli_errno($conn) . "] dbconn: mysqli_connect: " . mysqli_error($conn));
}
}
mysqli_select_db($conn, $mysqli_db)
or die('dbconn: mysqli_select_db: ' + mysqli_error($conn));

usercontrol::userlogin();
}
public function sql_query($query)
{
@++$_SESSION['totalqueries'];
return $conn->query($query);
}

public function sanitize($var)
{
return($this->sqlesc((htmlspecialchars($var))));
}
function sqlesc($x) {
return "'".mysqli_real_escape_string($x)."'";
}
public function sqlerr($file = '', $line = '')
{
print("<table border=0 bgcolor=blue align=left cellspacing=0 cellpadding=10 style='background: blue'>" .
"<tr><td class=embedded><font color=white><h1>SQL Error</h1>\n" .
"<b>" . mysqli_error() . ($file != '' && $line != '' ? "<p>in $file, line $line</p>" : "") . "</b></font></td></tr></table>");
die;
}
public function get_row_count($table, $suffix = "")
{
if ($suffix)
$suffix = " $suffix";
$query = "SELECT COUNT(*) FROM ".$table."".$suffix;
$r = $conn->query($query) or die(mysqli_error());
$a = $conn->fetch_row($r) or die(mysqli_error());
return $a[0];
}

}
$DB = new db;
?>

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