我有這段代碼在PHP中,並使用PostgreSQL作爲數據庫。我從GET獲取所有參數。已通過打印進行檢查。形成的查詢在Postgres終端上執行,但是PHP腳本失敗。更新查詢php postgres無故失敗
這是一段代碼。
<?php
$link = pg_connect("host=localhost dbname=postgres user=postgres password=password") or die('connection failed');
# Building the query
$newq=sprintf("update purchase_info set ....... comments=%s where id=%s",......,$comm,$id);
print $newq; // This query runs on the postgres terminal
$query=addslashes($newq); // to escape "" as one of my fields is comments
$result=pg_query($link,$newq);
if (!$result) {
echo "An error occured.\n";
}
pg_close($link);
?>
其他查詢在同一個腳本中運行。這條SQL語句有大約14個字段正在更新。
什麼問題聽到。 感謝幫助!
沒有任何失敗「無故」。 – Brad 2012-04-19 21:19:03