Note that there are some explanatory texts on larger screens.

plurals
  1. POData is not going into database during loop
    primarykey
    data
    text
    <p>I have written below to extract data from webpage, but this is running continuously with out inserting data into table. How do I split this trancation in below code. </p> <p>I want to insert for each url immediately and commit in loop. This is not working:</p> <pre><code>&lt;?php // example of how to use basic selector to retrieve HTML contents ini_set('log_errors','0'); ini_set('display_errors','1'); error_reporting(2047); include('simple_html_dom.php'); include('parameters.php'); // get DOM from URL or file set_time_limit(0); $site_name="sitename"; mysql_connect($hostname, $user, $pass) or die("Could not connect: " . mysql_error()); mysql_select_db($database); $query="select site_name,category,subcategory,link,first_no,last_no from `search_links` where site_name='".$site_name."'"; echo $query; $res=mysql_query($query); while ($row = mysql_fetch_assoc($res)) { $links[]=array( "site_name"=&gt;$row["site_name"], "category"=&gt;$row["category"], "subcategory"=&gt;$row["subcategory"], "url"=&gt;$row["link"], "first_no"=&gt;$row["first_no"], "last_no"=&gt;$row["last_no"]); } foreach ($links as $link) { for ($i=$link["first_no"];$i&lt;$link["last_no"];$i++) { try { $html = file_get_html($link["url"].$i); $sql = array(); foreach($html-&gt;find('a') as $e) { $sql[] = "('".$e-&gt;href."', '".$site_name."', '".$link["category"]."', '".$link["subcategory"]."','N')"; } #var_dump($sql); mysql_connect($hostname, $user, $pass) or die("Could not connect: " . mysql_error()); mysql_select_db($database); $sql_ext=" ON DUPLICATE KEY update duplicate='Y'"; /*//echo('INSERT INTO table (link,site,category,subcategory, archived) VALUES '.implode(',', $sql));*/ mysql_query( 'INSERT INTO classifieds (link,site,category,subcategory, archived) VALUES '.implode(',', $sql).$sql_ext); mysql_query("COMMIT"); } catch(Exception $e) { echo 'Message: ' .$e-&gt;getMessage(); } } } ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload