Note that there are some explanatory texts on larger screens.

plurals
  1. POintegrating a function
    primarykey
    data
    text
    <p>this is the follow-up to my question about getting a div's content. the second function is the one im having a hard time with. im pretty sure i can call a function from another one, but im not sure about placing them into oneanother like i did here. its obviously a silly attempt to make the code work, since it gives me an error:</p> <p><em>Blackline Frostbyte : in stock. : $139.99</em></p> <p><em>Fatal error: Cannot redeclare get_string_between() (previously declared in /home/rambazar/public_html/cron.php:69) in /home/rambazar/public_html/cron.php on line 69</em></p> <p>as i see this, the code is partially ok, because it gets a products stock info and the price tag, but the code stops and i cant figure out where <em>get_string_between</em> is redeclared, as it is only called. please help me sorting this out, thanks!</p> <pre><code>&lt;?php set_time_limit(1800); include("admin/include/db.php"); error_reporting(E_ALL); $res=mysql_query("select * from products"); while($row=mysql_fetch_array($res)) { $availability=getavailability($row['newegg_productid']); $price=getprice($row['newegg_productid']); echo $row['productname']." : ".$availability." : ".$price."&lt;br /&gt;"; } function getavailability($itemId) { $url=trim("http://www.newegg.com/Product/Product.aspx?Item=".$itemId); $ch = curl_init(); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_VERBOSE, true); curl_setopt($ch, CURLOPT_HEADER, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_TIMEOUT, 20); curl_setopt($ch, CURLOPT_AUTOREFERER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); $content = curl_exec ($ch); curl_close ($ch); $content=strtolower($content); $buff=$content; $isAvailable=false; $pos1=strpos($content,'&lt;p class="note"&gt;')+16; if($pos1==16)return ""; $pos2=strpos($content,'&lt;/p&gt;',$pos1); $availability= trim(substr($content,$pos1,($pos2-$pos1))); return strip_tags($availability); } function getprice($itemId) { function get_string_between($string, $start, $end) { $string = " ".$string; $ini = strpos($string,$start); if ($ini == 0) return ""; $ini += strlen($start); $len = strpos($string,$end,$ini) - $ini; return substr($string,$ini,$len); } $data = file_get_contents("http://www.newegg.com/Product/Product.aspx?Item=".$itemId); $pricediv = get_string_between($data, '&lt;div class="current" id="singleFinalPrice"&gt;&lt;span class="label"&gt;Now:', '&lt;/div'); $price = strip_tags($pricediv); return $price; } ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    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