Home > Database > Mysql Tutorial > body text

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

WBOY
Release: 2016-06-07 17:51:11
Original
1006 people have browsed it

查询数据库出现错误提示: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");

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!