php警告,高手进

来源:百度知道 编辑:UC知道 时间:2024/06/05 19:54:10
警告如下:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in D:\AppServ\www\ImageUpload\sc_kz\sc2\index.php on line 42

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in D:\AppServ\www\ImageUpload\sc_kz\sc2\index.php on line 47
源代码(42行和47行,我已标出)
<?php include "conn/conn.php"; ?>
<form action="" method="post" enctype="multipart/form-data" name="form1">
<input type="hidden" name="hiddenField" size="30000">
<table width="357" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#003333">
<tr>
<td width="357" align="center" bgcolor="#3399CC"><br>
图片1:
<input t

你的语句写错了,不能对SQL进行FETCH的,注意看下面的三行:
$sql=mysql_query("select file from tb_tpsc order by scsj desc LIMIT 5");
$info=mysql_fetch_array($sql); //第42行
do{

应该修改为:
$sql=mysql_query("select file from tb_tpsc order by scsj desc LIMIT 5");
$res=mysql_query($sql);
if (! $res) echo "执行SQL错误,SQL:$sql<br>错误:".mysql_error();
while ($info=mysql_fetch_array($sql)){

下面这一行:
}while($info=mysql_fetch_array($sql)); //第47行
应该修改为:
}

第二行的意思是$sql 并不是一个有效的MYSQL结果集,原因是SQL语句有问题,mysql_query 失败了
你把SQL语句select file from tb_tpsc order by scsj desc LIMIT 5在phpMyAdmin里执行一下看看有什么错吗?

从提示信息来看,是你的数据库里没有数据,
而你的程序并没有显示的错误。
只是缺少了判断.

建议重点检查一下,文件上传是否成功,成功后是否成功把数据写入到数据库里了,还有表结构是否跟程序里的变量一致。

可能是MySQL版本有点旧 不支持函数mysql_fetch_array()
你试试mysql_db_query("table",query,$cn);
table 表
query 查询语句
$cn 连接数据库用的资源
即$cn=$cn=@mysql_connect('localhost'