gpt4 book ai didi

php - 无法使用带有字符串字段的 Where 子句搜索数据库

转载 作者:行者123 更新时间:2023-11-29 06:39:37 25 4
gpt4 key购买 nike

我正在使用以下代码

public static function getRecord($query){ // Gets single record and returns single associative array
db::open();
$result = mysql_query($query) or die(mysql_error());
if(!mysql_num_rows($result)==0){
$recordset = mysql_fetch_assoc($result);
}else{
$recordset = false;
}
db::close();
return ($recordset);
}

$query = "SELECT * FROM callDetails WHERE storeName = " . $name ;

我收到这个错误

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 'E Jewelers LIMIT 0, 50' at line 1

$name 是'A E Jewelers'

最佳答案

$query = "SELECT * FROM callDetails WHERE storeName = '" . $name ."'";  

关于php - 无法使用带有字符串字段的 Where 子句搜索数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22281924/

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