0

I am inserting scraped link to my database but when i check in database the number of auto increment records is correct but cado field remains blank. When i insert a default value "test" @ $results_urls[$separate_result] the records is filled. what mistake have i done

$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()); 
        }
    }
1
  • Please read the first question and answer in the related column to the right before you continue. Commented Jun 20, 2013 at 7:11

1 Answer 1

1

use {} for inserting data from array

$add = "INSERT INTO pourqui(cado) VALUES ('{$results_urls[$separate_result]}')";
                                           ^                               ^
Sign up to request clarification or add additional context in comments.

2 Comments

following your answer : $add = "INSERT INTO table_name(table_column) VALUES ('{$results_urls[$separate_result]}')"; but dbase still empty
@Dimitri Because you are assigning the value to 0th element and accessing it using associative array. Assign it in this way $results_urls[$separate_result] = "http://www.imdb.co.....

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.