我收到查询错误,我使用类似LIKE sql函数来搜索用户提交的名称。
但msqli_query如果我删除LIKE函数它会发生错误但是不能用LIKE函数
<!DOCTYPE html>
<html>
<head>
<title>Search Users</title>
</head>
<body>
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"method="GET">
Name: <input type="text" name="name"></input>
<input type="submit" name="searchusers" value="Submit"></input> </br>
</body>
</html>
<?php require('connect.php');
$name = @$_GET['name'];
if ($_SERVER["REQUEST_METHOD"] == "GET")
{
$select123 ="SELECT username FROM users WHERE username LIKE ='%".$name."%'";
$check = mysqli_query($conn, $select123) or die("query error");
mysqli_num_rows($check) or die("Couldnt not find the Specified username");
}
?>
请帮忙
答案 0 :(得分:0)
删除关键字=
附近的like
:
$select123 ="SELECT username FROM users WHERE username LIKE '%".$name."%'";