我正在尝试将数据插入数据库中的两个表中,两个查询之一即使它们相同,也可以工作,只是更改了列名和数据库名。
这是插入的代码,...
$requesttitle = $_POST["requesttitle"];
$requesturl = $_POST["requesturl"];
$requestcap = $_POST["requestcap"];
$requestdestype = $_POST["requestdestype"];
$requestdbtype = $_POST['requestdbtype'];
$accountid=$_SESSION['username'];
$deptname = $_POST['deptname'];
$contactname = $_POST['contactname'];
$contactnum = $_POST['contactnum'];
$contactemail = $_POST['contactemail'];
$startdate = $_POST['startdate'];
$enddate = $_POST['enddate'];
if(trim($requesttitle)=="") return "<p>Error in submitting request. Request Title is empty!</p>";
if(trim($requesturl)=="") return "<p>Error in submitting request. Request URL is empty!</p>";
if(trim($requestcap)=="") return "<p>Error in submitting request. Storage Capacity is empty!</p>";
if(trim($requestdestype)=="") return "<p>Error in submitting request. Design Type is empty!</p>";
if(trim($requestdbtype)=="") return "<p>Error in submitting request. Database Type is empty!</p>";
if(trim($deptname)=="") return "<p>Error in submitting request. Requesting Department is empty!</p>";
if(trim($contactname)=="") return "<p>Error in submitting request. Contact Person is empty!</p>";
if(trim($contactnum)=="") return "<p>Error in submitting request. Contact Number is empty!</p>";
if(trim($contactemail)=="") return "<p>Error in submitting request. Contact E-mail is empty!</p>";
if(trim($startdate)=="") return "<p>Error in submitting request. Contact E-mail is empty!</p>";
if(trim($enddate)=="") return "<p>Error in submitting request. Contact E-mail is empty!</p>";
//$sql = "insert into webhostrequest (requesttitle, requesturl, requestcap, requestdestype, requestdbtype, accountid, deptname, contactname, contactnum, contactemail, startdate, enddate, recentact) values ('$requesttitle', '$requesturl', '$requestcap', '$requestdestype', '$requestdbtype', '$accountid', '$deptname', '$contactname', '$contactnum', '$contactemail', '$startdate', '$enddate', now())";
//$result = mysql_query($sql) or die ("Error in submitting request. $sql".mysql_error());
$sql2 = "insert into req_servicerequest (title, url, memory, design, database, accountid, deptname, contactname, contactnum, contactemail, startdate, enddate, recentact) values ('$requesttitle', '$requesturl', '$requestcap', '$requestdestype', '$requestdbtype', '$accountid', '$deptname', '$contactname', '$contactnum', '$contactemail', '$startdate', '$enddate', now())";
$result2 = mysql_query($sql2) or die ("Error in submitting request. $sql2".mysql_error());
这是错误,...
提交请求时出错。插入 req_servicerequest(标题、url、内存、设计、数据库、accountid、deptname、contactname、contactnum、contactemail、startdate、enddate、recentact)值('A'、'http://www.kimbra.org/'、' 500'、'HTML/XHML/XML'、'DB2'、'test'、'UST - Steps'、'james'、'09151273507'、'test@reply.mail'、'2012-04-10'、' 2012-05-24', 'now()') 你的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以在第 1 行的“数据库、帐户 ID、部门名称、联系人名称、联系人编号、联系人电子邮件、开始日期”附近使用正确的语法