0
警告接收:解決庫MySQLi空查詢錯誤
警告:mysqli的::查詢():空查詢在C:\瓦帕\ WWW \ OTP-任務\的welcome.php在線路62上
我的數據庫連接是在這裏:
function insertDB($email, $OTP , $phonenumber)
{
$servername = "localhost";
$username = "root";
$password = "";
$db = "dbotp";
$conn = new mysqli($servername, $username, $password, $db);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// insert to db and close the connection, default time attribute is 60 mins
// the table name is onetime and will hold the otp and phonenum and email
$res = mysqli_query($conn, "INSERT INTO onetime (otpnum,email,phoneNum,action) VALUES ('$OTP' , '$email' , '$phonenumber','success')");
// $res = "INSERT INTO onetime (otpnum,email,phoneNum,action) VALUES ('$OTP' , '$email' , '$phonenumber', 'success')";
if ($conn->query($res) === TRUE) {
echo "New record created successfully";
} else {
echo "Error: " . $res . "<br>" . $conn->error;
}
$conn->close();
}
執行查詢兩次產生該錯誤!註釋這一行'\\ if($ conn-> query($ res)=== TRUE)'並使用'if($ res)' – Saty