kecai_cale 发表于 2011-04-23 14:03

请教mysql_fetch_array问题出在那!

<?php
require_once ("./config/link.php");
mysql_select_db("nx00", $con);
$result = mysql_query("select * from nx00 order by id desc");
while($row = mysql_fetch_array($result))
{
echo $row['id'] . " " . $row['num'];
echo "<br />";
}
?>

link.php是数据库链接文件

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /usr/local/www/apache22/data/twweb/find.php on line 8

hq8318 发表于 2011-04-23 23:43

$result = mysql_query("select * from nx00 order by id desc")
    or die("Invalid query: " . mysql_error());
echo $result;

看看什么提示。

kecai_cale 发表于 2011-04-24 10:58

Invalid query:No database selected
为啥会这样~~

kecai_cale 发表于 2011-04-24 11:07

我把这个改为:   mysql_select_db("数据库名字", $con);

Resource id #5

kecai_cale 发表于 2011-04-24 11:07

我把这个改为:   mysql_select_db("数据库名字", $con);
结果为
Resource id #5

紫月亮 发表于 2011-04-24 12:04

没连上数据库。。。

hq8318 发表于 2011-04-24 18:42

$result 为:Resource id #5,就对了。能查询到数据吗?

surpass_li 发表于 2011-04-25 08:52

a.a 发表于 2011-04-25 13:44

紫月亮已经说了,没有连接数据库。缺少了mysql_connect .

stabilization 发表于 2011-04-25 17:38

没有连接数据库怎么查询:em05:
页: [1] 2
查看完整版本: 请教mysql_fetch_array问题出在那!