Home  >  Article  >  Backend Development  >  like 查询,报错,求指点

like 查询,报错,求指点

WBOY
WBOYOriginal
2016-06-23 14:13:401053browse

      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);    }

报错信息:

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\34\test.php on line 19


回复讨论(解决方案)

$result = mysql_query("SELECT * FROM user where username like '%admin%'");

肯定是SQL语句的问题,echo 你的sql语句,拿到数据库去运行就知道什么原因了。
$result = mysql_query("SELECT * FROM user where username like '%admin%'");
试一试。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn