我无法执行查询
if (!mysql_query("SELECT `title`,LEFT(`description`,70) as `description`,`url`
FROM `articles`
WHERE `keywords` LIKE '%blog%'"))
{
echo 'Failed';
}
如果我将相同的查询直接复制并运行到本地主机的 SQL 菜单中,它会成功运行。
最佳答案
为什么不用这个
$sql = mysql_query("SELECT `title`,LEFT(`description`,70) as `description`,`url`
FROM `articles`
WHERE `keywords` LIKE '%blog%'") or die (mysql_error());
//^^^^^^^^^^^^^^^---better use this instead of "failed" to debug, if want change it do it like that **or die ('failed');**
它像 if 一样工作,它会被这样解释:
execute my query please or if its not true my query please die and echo the error.
This cant be used in production but only during development for not passing technical error messages to the user, can give them important hints on detecting and/or exploiting vulnerabilities
关于php - 无法使用 mysql_query() 执行查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21797882/