错误输出
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '//some values
我有一个这样的查询:
$sql = "SELECT col1, col2 FROM table1
WHERE col1 = " . $row['value'] . "";
但是如果我的查询硬代码是这样的:
$sql = "SELECT col1, col2 FROM table1
WHERE col1 = 'string data (string data too)'";
它按我的预期工作。
请注意,我有一些具有( ) 开括号和闭括号的值,就像我在上面的硬编码查询中一样。
另请注意,$row['value']
返回正确的值,就像我在硬编码查询中测试的那样。
我期待与硬编码查询相同的输出。
如果这个查询有一个字符串数据,那么它必须用引号括起来'
,如下所示。检查这个查询一次。
$sql = "SELECT col1, col2 FROM table1
WHERE col1 = '" . $row['value'] . "'";
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句