TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 02-23-2009, 11:35 AM   #1 (permalink)
The Wanderer
 
paulOr's Avatar
 
Join Date: Nov 2007
Location: Edinburgh
Posts: 21
Thanks: 1
paulOr is on a distinguished road
Default preg_match problem.

PHP Code:
<?php

        $domain 
"http://twitter.com/paulor";

        
$ch curl_init() or die(curl_error());
        
curl_setopt($chCURLOPT_URL,$domain);
        
curl_setopt($chCURLOPT_RETURNTRANSFER1);
        
$data1=curl_exec($ch) or die(curl_error());
        echo 
curl_error($ch);
        
curl_close($ch);

        
$regex '/<span id="following_count" class="stats_count numeric">(.+?)</span>"/';
        
preg_match($regex,$data1,$match);
        echo 
$match[1];

?>
Getting this error:
Quote:
Warning: preg_match() [function.preg-match]: Unknown modifier 'p' on line 15
line 15 is the regex btw

anyone know whats wrong?
__________________
paulOr.net
paulOr is offline  
Reply With Quote
Old 02-23-2009, 11:50 AM   #2 (permalink)
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
Salathe is on a distinguished road
Default

The regex pattern contains the string </span>. Since your delimiter is the forward slash, the pattern parser tries to stop read a pattern at the second forward slash which in this case is actually part of the closing span tag and not really the end of your pattern! Since the parser thinks the pattern has ended at that forward slash, it starts looking for modifiers. s is a valid one (which is why no error is raised there) but p isn't.

Solutions:
1. Use a different delimiter which won't be used in your pattern (popularly tilde ~mypattern~modifiers).
2. Escape the delimiter in your pattern: </span> becomes <\/span>
Salathe is offline  
Reply With Quote
Old 02-23-2009, 11:52 AM   #3 (permalink)
The Wanderer
 
paulOr's Avatar
 
Join Date: Nov 2007
Location: Edinburgh
Posts: 21
Thanks: 1
paulOr is on a distinguished road
Default

thank you sir!
__________________
paulOr.net
paulOr is offline  
Reply With Quote
Old 02-23-2009, 12:14 PM   #4 (permalink)
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
Salathe is on a distinguished road
Default

Also, it's not really related to the question but you can get the follower information through Twitter's API: http://twitter.com/users/show/paulor.xml
Salathe is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
problem getting data on the html table.... jetnet1 General 2 11-24-2008 06:55 PM
Huge Session Problem Killswitch General 1 11-17-2008 02:36 AM
A serious curl checkbox problem bedri Advanced PHP Programming 1 05-22-2008 04:25 PM
A bug or a cache problem?! yazid Advanced PHP Programming 0 05-22-2008 08:40 AM
ÅÄÖ (charset=iso-8859-1) problem cthemaaan Advanced PHP Programming 6 03-28-2008 11:08 AM


All times are GMT. The time now is 05:40 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design