เปลี่ยนโค้ด mysql เป็น mysqli แล้วโปรแกรมแจ้งข้อผิดพลาดว่า Warning: mysqli_real_escape_string() expects exactly 2 parameters, 1 given
โค้ดที่เขียน
<?php require_once('Connections/tcal_cal.php'); ?>
<?php require_once('Connections/tcal_test.php'); ?>
<?php
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;
}
}
error ที่เจอ
Warning: mysqli_real_escape_string() expects exactly 2 parameters, 1 given in C:\xampp\htdocs\tcal\tracking.php on line 11
Warning: mysqli_real_escape_string() expects exactly 2 parameters, 1 given in C:\xampp\htdocs\tcal\tracking.php on line 11
Warning: mysqli_real_escape_string() expects exactly 2 parameters, 1 given in C:\xampp\htdocs\tcal\tracking.php on line 11
Warning: mysqli_real_escape_string() expects exactly 2 parameters, 1 given in C:\xampp\htdocs\tcal\tracking.php on line 11Tag : PHP, MySQL, HTML, CSS, Apache, XAMPP
Date :
2018-11-29 10:37:06
By :
cheerleadez
View :
2245
Reply :
2
ถ้าเป็น mysqli มี function นี้แน่นอนครับ ไม่ต้องตรวจสอบก็ได้
Code (PHP)
$theValue = $connection->real_escape_string($theValue);
และแนะนำไปใช้คำสั่ง mysqli::prepare ครับ สั้น ปลอดภัย ใช้ง่าย
Date :
2018-11-29 12:45:35
By :
Chaidhanan
Load balance : Server 05