Jump to content


This topic is now archived and is closed to further replies.


CURL Scripting error

Recommended Posts

//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]


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

Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.