Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我的 php 脚本中有一个 sql 查询,其中包含以下行:
WHERE beerStyle = \"$styleName\" AND rating > 0
正在查找的样式名称是:
Fresh "Wet" Hop Ale
准确存储的内容已经写在我的数据库中。我的问题是我认为当它在数据库中查找时,引号会以某种方式混淆,所以它认为现在有具有该名称的样式。
利用mysqli_real_escape_string()
mysqli_real_escape_string()
$styleName=mysqli_real_escape_string($styleName);
你的查询就像。
WHERE beerStyle = $styleName AND rating > 0
也许你可以试试
$query = "SELECT * FROM beers WHERE beerStyle = '" .$styleName. "'";