gpt4 book ai didi

php - MySQL语法错误但没有第114行

转载 作者:行者123 更新时间:2023-11-29 08:29:17 30 4
gpt4 key购买 nike

我收到以下错误

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 114

但我的代码只有 27 行长

<?php
$DB_NAME = 'QCSYSTEM';
$DB_HOST = 'monitor';
$DB_USER = 'QCSYSTEM';
$DB_PASS = '247#Direct';
$mysqli = new mysqli($DB_HOST, $DB_USER, $DB_PASS, $DB_NAME);
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}

// A QUICK QUERY ON A FAKE USER TABLE
$query = "SELECT username FROM `users` WHERE";
$result = $mysqli->query($query) or die($mysqli->error.__LINE__);

// GOING THROUGH THE DATA
if($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
echo stripslashes($row['username']);
}
}
else {
echo 'NO RESULTS';
}
// CLOSE CONNECTION
mysqli_close($mysqli);
?>

最佳答案

您缺少在此处声明您的 WHERE 子句

$query = "SELECT username FROM `users` WHERE";

删除它

$query = "SELECT username FROM `users`";

或应用任何条款

$query = "SELECT username FROM `users` WHERE column = 'something'";

关于php - MySQL语法错误但没有第114行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17099453/

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