0

我正在将抓取的链接插入到我的数据库,但是当我签入数据库时​​,自动增量记录的数量是正确的,但 cado 字段保持空白。当我插入默认值“test”@$results_urls[$separate_result]时,记录已填充。我犯了什么错误

$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()); 
        }
    }
4

1 回答 1

1

用于{}从数组中插入数据

$add = "INSERT INTO pourqui(cado) VALUES ('{$results_urls[$separate_result]}')";
                                           ^                               ^
于 2013-06-20T07:11:24.613 回答