在mysql中创建的行没有错误,但没有插入数据

时间:2013-09-16 05:39:09

标签: php mysql

非常新的。我提交输入表单,没有错误。当我去检查myphpadmin的条目时,创建了一行,但所有字段都是空白的。

不知道发生了什么,因为我的文本代码只有4个条目有效。

<?php

$subscribingcompany= $_POST["subscribingcompany"];
$biztype= $_POST["biztype"];
$sitename= $_POST["sitename"];
$siteadd1= $_POST["siteadd1"];
$city1= $_POST["city1"];
$zip1= $_POST["zip1"];
$state1= $_POST["state1"];
$country1= $_POST["country1"];
$biladd1= $_POST["biladd1"];
$city2= $_POST["city2"];
$zip2= $_POST["zip2"];
$state2= $_POST["state2"];
$country2= $_POST["country2"];
$fename= $_POST["fename"];
$lename= $_POST["lename"];
$email1= $_POST["email1"];
$phone1= $_POST["phone1"];
$foname= $_POST["foname"];
$loname= $_POST["loname"];
$email2= $_POST["email2"];
$phone2= $_POST["phone2"];
$effdate= $_POST["effdate"];
$camquantity= $_POST["camquantity"];
$currency= $_POST["currency"];
$quantity= $_POST["quantity"];

$database="greenguy_cbrsandbox";
$table="DesignPartner"; 

//Create connection and select database 
$con= mysql_connect("example.com", "greenguy_ccb", "password88") or         die(mysql_error());
echo "connected";  
mysql_select_db("$database", $con) or die(mysql_error());
echo"database found";

 //Insert into Table
 $insert =  "INSERT INTO $table 
            (id, subscribingcompany, biztype, sitename, siteadd1,   city1, zip1, state1, country1, biladd1, city2, zip2, state2, country2, fename, lename, email1, phone1, foname, loname, email2, phone2, effdate, camquantity, currency, quantity) 
        VALUES  
            (DEFAULT,'$subscribingcompany','$biztype','$sitename','$siteadd1','$city1','$zip1','$state1','$country1','$biladd1','$city2','$zip2','$state2','$country2','$fename','$lename','$email1','$phone1','$foname','$loname','$email2','$phone2','$effdate','$camquantity','$currency','$quantity')";

$results =mysql_query($insert) or die(mysql_error());

echo"data inserted succesfully";    

mysql_close($con); 
  ?>

1 个答案:

答案 0 :(得分:0)

您插入查询正常工作,因为您已提供自动增量功能   行已创建,但其余值未插入,请在执行期间回显您的查询。

使用 echo $ insert 来了解执行查询时插入的内容。