-1
我試圖填充數據庫。下面的代碼在循環中執行以填充一些相關的表。當循環運行17次時,「pubmedarticle」和「pubmedarticle_belongsto_user」表填充17條記錄。然而,「抽象」表填充10條記錄,其他表包含16條記錄!循環運行沒有限制,運行17次,循環後所有表應包含17條記錄。我無法找到爲什麼插入到數據庫中有一些缺失。我很欣賞你的想法。使用php將數據插入到mysql時記錄丟失
這裏是主鍵:
pubmedarticle: pubmedArticleId
pubmedarticle_belongsto_user: userId, pubmedArticleId
article: articleId, pubmedArticleId
abstract: abstractId, articleId , pubmedArticleId
pagination: paginationId, articleId, pubmedArticleId
我檢查mysqli_error,我收到此結果6次(有6人失蹤!):錯誤說明:您的SQL語法錯誤;檢查與您的MySQL服務器版本相對應的手冊,以找到正確的語法,以便在迄今爲止最全面的地震災難演練中使用。半結構化面試」,在1號線
這是代碼:
mysqli_query($con,"INSERT INTO pubmedarticle (pubmedId) VALUES ('$pmid')");
//------------
$result_last_row = mysqli_query($con, "SELECT pubmedArticleId from pubmedarticle order by pubmedArticleId desc limit 1");
while($row2 = mysqli_fetch_array($result_last_row)) {
$last_userID = $row2['pubmedArticleId'];
}
mysqli_query($con,"INSERT INTO pubmedarticle_belongsto_user (userId, pubmedArticleId) VALUES ('$userId','$last_userID')");
//------------
mysqli_query($con,"INSERT INTO article (pubmedArticleId, articleTitle, articleDate) VALUES ('$last_userID', '$title', '$year_final')");
$result_last_row2 = mysqli_query($con, "SELECT articleId from article order by articleId desc limit 1");
while($row3 = mysqli_fetch_array($result_last_row2)) {
$last_userID_article = $row3['articleId'];
}
if (!mysqli_query($con,"INSERT INTO abstract (articleId, pubmedArticleId, abstractText) VALUES ('$last_userID_article','$last_userID', '$abstract')")){
echo("Error description: " . mysqli_error($con));
echo "</br>";
}
mysqli_query($con,"INSERT INTO pagination (articleId, pubmedArticleId, medlinePgn) VALUES ('$last_userID_article','$last_userID', '$medlinepgn')");
mysqli_query($con,"INSERT INTO publicationtype (articleId, pubmedArticleId, publicationType) VALUES ('$last_userID_article','$last_userID', '$publicationtype')");
mysqli_query($con,"INSERT INTO journal (articleId, pubmedArticleId, issn, journalIssuePubDate, volume, issue, journalTitle, isoAbbreviation)
VALUES ('$last_userID_article','$last_userID', '$issn', '$year_final','$volume', '$issue', '$journalTitle', '$isoAbbreviation')");
表中的主鍵是什麼? mysqli_error在每個查詢後會給出什麼輸出? – Jim
我將主鍵添加到我的解釋中。順便說一句,我沒有收到任何錯誤! – user1811758
我檢查mysqli_error,我收到這樣的結果6次: \t錯誤說明:您的SQL語法錯誤;檢查與您的MySQL服務器版本相對應的手冊,以找到正確的語法,以便在迄今爲止最全面的地震災難演練中使用。半結構化面試」,在1號線 – user1811758