我一直試圖插入表格中的數據在兩張表中,但我沒有得到幸運,最後我嘗試了第一張表插入,但第二張表是空的,沒有什麼插入它,下面是我的查詢代碼:我想能夠從兩個表中的表格插入數據
$query1=mysql_query("INSERT INTO $Tname (tnumber2, results, idate, iaddress, tstatus, saddress, scountry, ddate, daddress) VALUES('$tnumber2','$results','$idate','$iaddress','$tstatus','$saddress','$scountry','$ddate','$daddress')");
$id = mysql_insert_id();
$query2=mysql_query("INSERT INTO $UPname (tnumber2, pdate, act, paddress, up) VALUES('$tnumber2','$pdate','$act','$paddress','$up')");
我收到此錯誤:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'update (tnumber2, pdate, act, paddress, up) VALUES('59644039299744','59644039299' at line 1
您從第一個查詢中獲得'$ id',但在第二個查詢中沒有做任何處理。我建議將調用添加到'mysql_error()'來查看是否有任何錯誤被數據庫返回。 – andrewsi
這裏是錯誤...........你的SQL語法有錯誤;檢查與您的MySQL服務器版本相對應的手冊,以便在'update(tnumber2,pdate,act,paddress,up)附近使用正確的語法。VALUES('59644039299744','59644039299'at line 1 – Wilson