gpt4 book ai didi

php - 我在 PHP 中执行 mysql 查询时不断收到 MySql 错误

转载 作者:行者123 更新时间:2023-11-29 21:55:09 24 4
gpt4 key购买 nike

我的简单 PHP 代码:

$query = "SELECT 'food', 'calories' FROM 'food'";

if($query_run = mysql_query($query)){
echo 'Query success';
}else {
echo mysql_error();
}

我的错误消息:

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 ''food'' at line 1

实在无法找出问题所在,请帮忙吗?

最佳答案

$query = "SELECT food, calories FROM food";

if($query_run = mysql_query($query)){
echo 'Query success';
}else {
echo mysql_error();
}

使用上面的代码。

您确定您的表格名称是食物,并且您有按名称食物和卡路里排列的列吗?

关于php - 我在 PHP 中执行 mysql 查询时不断收到 MySql 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33219956/

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