0
我在寫一個腳本,它使用用戶的數據創建一個頁面併爲創建的頁面創建一個數據庫條目。不幸的是,儘管我使用的查詢是由phpmyadmin
生成的,但插入操作並未成功。PHP - mysqli_query不提供錯誤
我試圖對所有的函數調用都使用mysql
和mysqli
(不是很明顯),但是無論如何都收到了相同的結果。
雖然我很想理解插入失敗的原因,但更緊迫的問題是沒有錯誤產生。
錯誤條件將被輸入,但mysql_error()
和mysqli_error()
最終爲空。
這是發生錯誤的代碼段:
$result = mysqli_query($pvcon,"'INSERT INTO content
(content.post_type_id,
content.content_title,
content.content_description,
content.content_link,
content.user_id,
content.content_image_path,
content.date_posted)
values (\'".$post_type."\',
\'".$title."\',
\'".$description."\',
\'".$content_link."\',
\'".$user_id."\',
\'".urlencode($article_image)."\',
now())'");
if (!$result) {
echo "DB Error, could not list tables\n";
echo 'MySQL Error: ' . mysqli_error();
exit;
}
我發現有類似地雷,但沒有這些解決方案都爲我工作這使我相信,有一些多個問題我忽略了一個簡單的步驟。
就是這樣。非常感謝你! – user3326473