Jump to content


Photo

CURL Scripting error


  • Please log in to reply
No replies to this topic

#1 Iryk

Iryk
  • Members
  • PipPip
  • Member
  • 25 posts

Posted 21 June 2006 - 05:43 AM

<?php 
//featured game 
//initiate curl 
$ch = curl_init(); 
 
//give curl the url to visit 
curl_setopt($ch, CURLOPT_URL,"http://www.neopets.com/weather.phtml"); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); 
//load the page into a variable 
$result=curl_exec ($ch); 
//close the connection 
curl_close ($ch);
//split each line into a value in an array 
$lines = explode("\n", $result); 
 
//cycle through each line in the array until we find a specific pattern 
foreach ($lines as $line_num => $line) { 
//get image and url 
$pattern = 'Average temperature today is \<b>([^\']*)\<\/b> degrees C (\<b>([^\']*)\<\/b> degrees F)\<p>\<center>\<img src=\'([^\']*)\' width=150 height=150 border=0>/';
if (preg_match($pattern, $line, $matches)) {  
$temp = $matches[1]; 
$image = $matches[3];
}
}
echo "$tempĀ° C<br><img src='$image'>";
?>

What am i doing wrong here is the url to the page:

[a href=\"http://majestic-neo.com/v.3/portal/\" target=\"_blank\"]http://majestic-neo.com/v.3/portal/[/a]

Error:

Warning: preg_match() [function.preg-match]: Delimiter must not be alphanumeric or backslash in /fpgs/fpgshttpd/majestic-neo/v.3/portal/weather.php on line 20




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users