Home  >  Article  >  Database  >  错误提示:Warning: mysql_fetch_array() expects parameter

错误提示:Warning: mysql_fetch_array() expects parameter

WBOY
WBOYOriginal
2016-06-07 17:51:111009browse

查询数据库出现错误提示:Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in E:\\PHP\\wamp\\www\\lsr\\lsr.php on line 42

 代码如下 复制代码

$conn=_connect("localhost","root","") or die ("mysql连接失败");
mysql__db("lsr",$conn) or die ("选择失败");
mysql_query("net name gbk");
$sql="SELECT * FROM 'important'";
$query=mysql_query($sql,$conn);
while ($row=mysql_fetch_array($query)){
    echo $row[gamename];
}

 代码如下 复制代码
$sql="SELECT * FROM 'important'";
这句应该是
$sql = "SELECT * FROM `important` ";

注意下不是单引号,是Esc下面和波浪线一个键的那个字符。

问题二

 代码如下 复制代码

mysql_query("net name gbk");
这个写错了mysql_query("set names gbk");

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