mysql_fetch_array(): supplied argument is not a valid MySQL result resource解决方法

WBOY
Release: 2016-06-13 10:12:06
Original
1060 people have browsed it

mysql_fetch_array(): supplied argument is not a valid MySQL result resource
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in D:\myapacheweb\test\self_info.php on line 7

PHP code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->mysql_connect("localhost","root","1");     $query="select id from computer where user ='test2'";    $result=mysql_query($query);        echo "test2 使用了<br>";    while($row = mysql_fetch_array($result))    {        echo $row['id']."开始时间".$row[starttime]."<br>";    }
Copy after login

求助啊

------解决方案--------------------
$query="select id from computer where user ='test2'";

echo 一下$query 

把得到的SQL语句放在数据库里去执行一下,看能有没有数据。

这种问题一般都是 
SQL语句有错误,
或者数据库里没有这个数据造成的


------解决方案--------------------
SQL语句错了!
------解决方案--------------------
我一般是把
$result=mysql_query($query);
写成:
$result=mysql_query($query,$conn);


------解决方案--------------------
你没有指定数据库吧?- -
$result=mysql_query($query);
这个改成
$result=mysql_db_query('数据库名',$query);

------解决方案--------------------
探讨

我一般是把
$result=mysql_query($query);
写成:
$result=mysql_query($query,$conn);
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