当前位置:Gxlcms > PHP教程 > php数据库添加失败

php数据库添加失败

时间:2021-07-01 10:21:17 帮助过:17人阅读

添加数据库这里总是出问题
	if($fun==3){        $row=mysql_fetch_array(mysql_query("SELECT * FROM production ORDER BY proNo DESC LIMIT 0, 30 "));		$num=$row['proNo'];		$num++; 		$nums=$num*10+3;		echo" 添加编号为:$num  的商品:
"; }

	if($fun%10==3&&$fun!=3){	    $num=$_GET['fun'];$num=($num-3)/10;		$itime=date("Ymd");	    if(!empty($_POST['iproName'])){		echo $itime;        $result="INSERT INTO prodution(proNo,proName,proKey,proPrice,proPlace,sumNum,sugar,fee,calorie,time,picture,proWeight,proType) VALUES  ('$num','$_POST[iproName]','$_POST[iproKey]','$_POST[iproPrice]','$_POST[iproPlace]','$_POST[isumNum]','$_POST[isugar]','$_POST[ifee]','$_POST[icalorie]','$itime','$_POST[ipicture]','$_POST[iproWeight]','$_POST[iproType]')";		}		if (!mysql_query($result,$corn)) echo" 添加失败!!";		else echo" 添加成功!!";	}

数据库:


回复讨论(解决方案)

int型不要加 ' ' 字符型要加 ' ' 你好好查查吧

mysql_error 提供相关错误信息,你不去看,怪哪个?

$result="INSERT INTO prodution(proNo,proName,proKey,proPrice,proPlace,sumNum,sugar,fee,calorie,time,picture,proWeight,proType) VALUES ('$num','$_POST[iproName]','$_POST[iproKey]','$_POST[iproPrice]','$_POST[iproPlace]','$_POST[isumNum]','$_POST[isugar]','$_POST[ifee]','$_POST[icalorie]','$itime','$_POST[ipicture]','$_POST[iproWeight]','$_POST[iproType]')";

echo $result;

输出sql放在mysql工具执行看看

或者

mysql_query($result,$corn) or die(mysql_error());

人气教程排行