Home > Backend Development > PHP Tutorial > php 数据库添加失败

php 数据库添加失败

WBOY
Release: 2016-06-23 13:50:16
Original
1635 people have browsed it

添加数据库这里总是出问题

	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"&nbsp添加编号为:$num  的商品:</br>			<form action='admfun.php?fun=$nums' method='post'>			<table border='1'>				  			<tr><td>商品名称:</td><td><input class='input' type='text' name='iproName'></td></tr>			<tr><td>关键字:</td><td><input class='input' type='text' name='iproKey'></td></tr>  			<tr><td>价格:</td><td><input class='input' type='text' name='iproPrice'></td></tr> 		    <tr><td>生产地:</td><td><input class='input' type='text' name='iproPlace'></tr> 	 			<tr><td>库存量:</td><td><input class='input' type='text' name='isumNum'></td></tr> 			<tr><td>是否含糖:</td><td><input class='input' type='text' name='isugar'></td></tr>			<tr><td>是否包邮:</td><td><input class='input' type='text' name='ifee'></td></tr>			<tr><td>卡路里:</td><td><input class='input' type='text' name='icalorie'></td> </tr>			<tr><td>图片路径:</td><td><input class='input' type='text' name='ipicture'></td></tr>  						<tr><td>净含量:</td><td><input class='input' type='text' name='iproWeight'></td></tr>			<tr><td>分类:</td><td><input class='input' type='text' name='iproType'></td></tr>		 		    </table>			<input type='submit' value='添加' class='submitBtn'/>			</form>";		} 
Copy after login

	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"<font size=5>&nbsp添加失败!!</font>";		else echo"<font size=5>&nbsp添加成功!!</font>";	}
Copy after login

数据库:


回复讨论(解决方案)

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());

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