Jump to content

CURL Scripting error


Iryk

Recommended Posts

[code]<?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'>";
?>[/code]

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
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.