[英]Php insert from Array to database
我正在將剪貼的鏈接插入到數據庫中,但是當我在數據庫中簽入時,自動增量記錄的數量是正確的,但是cado字段仍然為空。 當我在$results_urls[$separate_result]
插入默認值“ test”時,記錄將被填充。 我做錯了什么
$separate_results = explode("<td class=\"image\">", $results_page); // Expploding the results into separate parts into an array
// For each separate result, scrape the URL
foreach ($separate_results as $separate_result) {
if ($separate_result != "") {
$results_urls[] = "http://www.imdb.com" . scrape_between($separate_result, "href=\"", "\" title="); // Scraping the page ID number and appending to the IMDb URL - Adding this URL to our URL array
$add = "INSERT INTO pourqui(
cado
) VALUES (
'$results_urls[$separate_result]'
)";
$result_add = mysql_query($add);
if (!$result_add) {
die("Database query failed: " . mysql_error());
}
}
使用{}
從數組插入數據
$add = "INSERT INTO pourqui(cado) VALUES ('{$results_urls[$separate_result]}')";
^ ^
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.