Timing Out, PHP/MySQLi

I am trying to run a script that requires a lot of time to process and I don’t have access to any configuration files on the shared server. Would appreciate advice or suggestions of how to get this done the best way.
Code:

[php]

<?PHP include('objconnect.php'); (I know, I will update to "improved" very soon.) $strSQL = "SELECT id, price FROM products ORDER BY id"; $objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]"); while($objResult = mysql_fetch_array($objQuery)){ $id=$objResult["id"]; $origprice=$objResult["price"]; $url='http://site.com/'.$id; include('simple_html_dom.php'); include('funcextract.php'); $fp=file_get_contents($url); $html = str_get_html($fp); $string = $html->find("div",8); $cost = extract_unit($string, 'Price>','query("UPDATE products SET price='$sellprice' WHERE id= '$id' ");} if(!$results){echo mysqli_error($link);} ?> <? mysqli_close($link); ?> <? } echo 'Done'; ?>

[/php]

How many rows are returned?
Put the include statements outside of the loop.

I would use a timer function to findout what is taking the time. Then, you could refactor the code to process faster; Optimize the database; or look at why it is taking as long as it is.

Secondly, drop the mysql_ functions and start using prepared statements. Bad practices to avoid now will save you time later.

Sponsor our Newsletter | Privacy Policy | Terms of Service