php:Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource

我的代码
<body>
<?php
$link = mysql_connect("localhost","root","212325") or die("连接数据失败!".mysql_error());
$db_inserted = mysql_query("juan",$link);
if($db_inserted){
echo"数据库连接成功!";
}
?>

<center>
<strong>录入月份:</strong>
<input name="Entry_Date" type="text" id="Entry_Date"><p>
<strong>城市编码:</strong>
<input name="City_Code" type="text" id="City_Code"><p>
<strong>产品编码:</strong>
<input name="Product_Code" type="text" id="Product_Code"><p>
<strong>出账类型编码:</strong>
<input name="Import_Code" type="text" id="Import_Code"><p>
<strong>收入金额:</strong>
<input name="Entry_Amount" type="text" id="Entry_Amount"><p>
<strong>稽核类型:</strong>
<input name="Checked_Code" type="text" id="Checked_Code"><p>
<input type="submit" name="Submit" value="提交">
</center>

<?php
$sql = mysql_query("select * from `Out_Check`");
$info = mysql_fetch_array($aql);
if($_POST[Submit]=="提交"){
$Entru_Date = $_POST[Entry_Date];
$City_Code = $_POST[City_Code];
$Product_Code = $_POST[Product_Code];
$Import_Code = $_POST[Import_Code];
$Entry_Amount = $_POST[Entry_Amount];
$Checked_Code = $_POST[Checked_Code];
$sql = mysql_query("insert into Out_Check values('$Entru_Date','$City_Code','$Product_Code','$Import_Code',$Entry_Amount'','$Checked_Code')",$link);
$info = mysql_fect_array($sql);
}
?>
</body>
$info = mysql_fetch_array($aql);
不知错在什么什么地方了,有些急,求解!

第1个回答  2012-10-26
sql语法错误
$sql = mysql_query("select * from `Out_Check`");
$info = mysql_fetch_array($aql);
改成:
$sql = mysql_query("select * from `Out_Check` where 1");
$info = mysql_fetch_array($sql);

你下面也有错误:
$info = mysql_fect_array($sql); 改成 mysql_fetch_array(); //fetch单词写错追问

查询有了 * 就可以不用where 了,所以那句没有语法错误的
$aql改成$sql也不对

追答

报什么错
1、如果数据库连接没问题,应该就是语句的问题,
通常你可以把这条语句打印出来,再把到命令行或phpmyadmin下去运行
2、如果你的数据表中数据为空内容,也会出现这样的错误,把mysql_fetch_array前面加个 “@”

追问

额 好像是空的,那加@会有影响吗?

追答

没啥,就是避免这种报错。
问题应该就是数据表中没数据,你手动在数据表中加几条数据在测试下,应该问题不大了

追问

刚查了数据表里 是有数据的,o(╯□╰)o

追答

这种问题一般都是sql错误导致的,你一步一步的打印

$sql = "select * from `Out_Check` where 1 ";
$query = mysql_query($sql);
echo $query; //看看这个的值
$info = mysql_fetch_array($query);
print_R($info ); //打印

本回答被提问者采纳
第2个回答  2012-10-26
$aql
$sql
一个字母之差追问

该过来了也不对的

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网