我写了我的代码,但数据没有存储。我无法弄清楚错误在哪里..你们可以帮助我解决我的问题..我需要一个快速的解决方案..请帮我弄清楚我的下面提到的代码是什么错误。这就是我所做的。
<?
$con=mysql_connect("localhost","root","");
mysql_select_db("store_records",$con);
@$a=$_POST['p_date'];
@$b=$_POST['d_name'];
@$c=$_POST['m_no'];
@$d=$_POST['email'];
@$e=$_POST['payment'];
@$f=$_POST['address1'];
@$g=$_POST['address2'];
if(@$_POST['info'])
{
echo $query="insert into distributor_records(Payment_Date,Distributor_Name,Mobile_No,Email,Payment,Address1,Address2)values('$a','$b','$c','$d','$e','$f','$g')";
echo "Record Successfully stored in DATABASE";
mysql_query($query);
}
?>
<html>
<head>
</head>
<body bgcolor="#CCCCCC">
<center><h1><u>Distributor Payments</u></h1></center>
<form method="post">
<table style=" border:1px solid silver" cellpadding="5px" cellspacing="0px"
align="center" border="0">
<tr>
<td colspan="4" style="background:#0066FF; color:#FFFFFF; fontsize:
20px" align="center">ADD DISTRIBUTOR RECORD</td></tr>
<tr>
<td>Date:</td>
<td><input type="date" name="p_date"/></td>
<tr>
<td>Name:</td>
<td><input type="text" name="d_name" size="50"></td></tr>
<tr>
<td>Mobile No:</td>
<td><input type="text" name="m_no" size="50"></td></tr>
<tr>
<td>Email: </td>
<td><input type="text" name="email" size="50"></td></tr>
<tr>
<td>Payment:</td>
<td><input type="text" name="payment" size="50"></td></tr>
<tr>
<td>Address1</td>
<td><input type="text" name="address1" size="50"></td></tr>
<tr>
<td>Address2</td>
<td><input type="text" name="address2" size="50"></td></tr>
<tr>
<td colspan="4" align="center">
<input type="submit" name="info" style="font-face: 'Comic Sans MS'; font- size: larger; color: teal; background-color: #FFFFC0; border: 3pt ridge lightgrey" value="Add Record"> |
<button type="reset" style="font-face: 'Comic Sans MS'; font-size: larger; color: teal; background-color: #FFFFC0; border: 3pt ridge lightgrey" value="Reset Form">Reset Form</button></td>
</tr>
</table>
</form>
<p align="center"><a href="Distributor Payments.php">Go Back To Main Page</a></p>
</body>
</html>
答案 0 :(得分:0)
试试这个:
if($_POST['info'])
{
$query="insert into distributor_records (Payment_Date,Distributor_Name,Mobile_No,Email,Payment,Address1,Address2)values('".$a."','".$b."','".$c."','".$d."','".$e."','".$f."','".$g."')";
mysql_query($query) or die(mysql_error());
if (mysql_query($query)) {
echo "Record Successfully stored in DATABASE";
} else {
echo mysql_error();
}
希望这有帮助。
和平!的xD