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 代码:
$serName = $_GET['username']; // Code for sanitation here // [...] $sql = "SELECT NAME FROM PLAYERS WHERE NAME LIKE '%$serName%'";
我得到除法错误,如何在两边都带有通配符的查询中使用变量?
正确查询
SELECT NAME FROM PLAYERS WHERE NAME LIKE '%{$serName}%'
你应该使用准备好的语句
$sql = "SELECT NAME FROM PLAYERS WHERE NAME LIKE '%" .$serName. "%'";