データベース内の2つのテーブルにデータを挿入しようとしていますが、2つのクエリの1つは同じでも機能し、列名とデータベース名のみが変更されます。
これが挿入のコードです...
$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(title、url、memory、design、database、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構文にエラーがあります。1行目の「database、accountid、deptname、contactname、contactnum、contactemail、startdate」の近くで使用する正しい構文については、MySQLサーバーのバージョンに対応するマニュアルを確認してください。