Forum Moderators: coopster
I am just starting out in PHP and the tutorials I have read seem inappropriate for what I would like to do and I have no idea what to read up on.
I would like to make a script which sets a variable based on a string value in another website.
For example, a website I use states if someone is online/offline in text. I would like to make a script for my site, which can search this website and bring back a value of whether the person is online/offline.
I would just like some advice into what areas I need to learn, or any basic principle on how i would go about doing this.
Thanks alot
Most of those script are based on timestamp
and some on cookies
we had a similar question HERE [webmasterworld.com]
If you may start writing something and come back with questions
Could anyone let me know why?
<?php
$url = “http://”;
$page = file_get_contents($url);
echo $page;
$pattern = ‘/ <B CLASS=green>online</B>/’;
preg_match_all($pattern, $file, $results, PREG_PATTERN_ORDER );
echo $results;
?>
Even if I chop the last part off and only echo the $page, it doesn't display the html string from the URL I set.
(I removed the website in "$url = “http://”;" for this example, not in my actual script.
Cheers
Now I get this error:
Warning: preg_match_all() [function.preg-match-all]: Unknown modifier 'B' in C:\wamp\www\mft.php on line 5
I had altered the script slightly:
<?php
$url = 'http://#*$!';
$page = file_get_contents($url);
$pattern = '/<B CLASS=green>online</B>/';
preg_match_all($pattern, $file, $results, PREG_PATTERN_ORDER );
echo $results;
?>
I managed to get to this:
<?php
$url = 'http://www.example.com/community/?subtopic=characters&name=Tejenuj';
$page = file_get_contents($url);
$pattern = '/<B CLASS=green>(online)<\/B>/';
preg_match_all($pattern, $file, $results, PREG_PATTERN_ORDER);
$online = $results[0][1];
echo $online;
?>
But it doesn't print out the value of $online, which should be a string "online".
[edited by: coopster at 5:14 pm (utc) on Jan. 2, 2008]
[edit reason] generalized domain [/edit]