gpt4 book ai didi

php - PHP 中的 “Unexpected T_OBJECT_OPERATOR” 错误

转载 作者:IT老高 更新时间:2023-10-28 23:49:01 26 4
gpt4 key购买 nike

我收到以下错误:

Parse error: syntax error, unexpected T_OBJECT_OPERATOR in.. on line 52.

第 52 行是 if ($result = mysqli->query...。如果我注释掉该行,$mysqli->query("INSERT INTO ...

为什么会报错?

$unique_code = "";
$inserted = false;
while(!$inserted) {
$unique_code = generateCode();
echo $unique_code;

// Check if it exists
if ($result = mysqli->query("SELECT unique_code FROM coming_soon_emails WHERE unique_code = '$unique_code'")) {
// Check no record exists
if ($result->num_rows == 0) {
// Create new record
$mysqli->query("INSERT INTO coming_soon_emails (email,unique_code) VALUES ('" . $mysqli->real_escape_string($_POST['email']) . "','$unique_code')");
// Set inserted to true to ext loop
$inserted = true;
// Close the result object
$result->close();
}
} else {
// Quit if we can't check the database
die('Something went wrong with select');
}
}

最佳答案

你忘记了 $mysqli 之前的美元符号。

关于php - PHP 中的 “Unexpected T_OBJECT_OPERATOR” 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5313705/

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