Rumah >pembangunan bahagian belakang >tutorial php >like 查询,报错,求指点
mysql_connect("localhost", "root", "123") or die("Could not connect: " . mysql_error()); mysql_select_db("iweibo"); $result = mysql_query("SELECT * FROM user where username like %admin%"); while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { var_dump($row); }
$result = mysql_query("SELECT * FROM user where username like '%admin%'");
肯定是SQL语句的问题,echo 你的sql语句,拿到数据库去运行就知道什么原因了。
$result = mysql_query("SELECT * FROM user where username like '%admin%'");
试一试。