Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New to the CF scene
    Join Date
    Nov 2009
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Preg_Match error

    I'm trying to get this MySpace train script to work, and I've been trying to use preg_match, to fetch the picture so it will post the user, and add their picture to the MySQL Database, to show on the train.

    But, when I do it, it cannot find a match, so it won't register correctly.

    Any idea what's wrong?

    Preg_Match:
    Code:
    		preg_match("/<a type=\"text\/javascript\" id=\"ctl00_cpMain_ctl00_UserBasicInformation1_hlDefaultImage\" rel=\"searchMonkey-photo\" href=\"http:\/\/viewmorepics.myspace.com\/index\.cfm\?fuseaction=user\..*?friendID=$fid\">.*?<\s*img [^\>]*src=\"([^\">]+)/is",$hold,$match);
    Full Code:
    Code:
    define ("profile_url","http://profile.myspace.com/index.cfm?fuseaction=user.viewprofile&friendID=" );
    $full_file_path = profile_url.$fid;
    $handle = fopen($full_file_path,"r");
    	if (!$handle){
        	echo "<p>Sorry Myspace Is Slow Try Again.\n";
        	$arr = 0; }
    	else {
    	$timeout = 300;
    	ini_set('max_execution_time','120');
    	set_time_limit(120);
    	ini_set('default_socket_timeout','120');
    	while($contents = fread($handle,'1024'))
    	{ $hold .= $contents; }
    	preg_match("/<a id=\"ctl00_cpMain_ctl00_UserBasicInformation1_hlDefaultImage\" rel=\"searchMonkey-photo\" href=\"http:\/\/viewmorepics.myspace.com\/index\.cfm\?fuseaction=user\..*?friendID=$fid\">.*?<\s*img [^\>]*src=\"([^\">]+)/is",$hold,$match);
    	$pic_url = $match[1];
    preg_match("/<span class=\"nametext\">(.*)<br \/>/",$hold,$match);
    $name = $match[1];
    		if(empty($pic_url))
    		{
    		preg_match("/<a type=\"text\/javascript\" id=\"ctl00_cpMain_ctl00_UserBasicInformation1_hlDefaultImage\" rel=\"searchMonkey-photo\" href=\"http:\/\/viewmorepics.myspace.com\/index\.cfm\?fuseaction=user\..*?friendID=$fid\">.*?<\s*img [^\>]*src=\"([^\">]+)/is",$hold,$match);
    
    		$pic_url = $match[1];
    		}
    		if(empty($name))
    		{
    		preg_match("/<span class=\"nametext\">(.*)<\/span>/",$hold,$match);
    		$name = $match[1];
    		}
    		
    		fclose($handle);
    		ini_restore('max_execution_time');
    		ini_restore('default_socket_timeout');
    		if(empty($pic_url))
    		{ ?>
    <script language="javascript"><!--
    alert("Invalid ID!")
    location.replace("index.php")
    //-->
    Any help would be appreciated!

  • #2
    Senior Coder
    Join Date
    Aug 2009
    Location
    Mansfield, Nottinghamshire, UK
    Posts
    1,555
    Thanks
    57
    Thanked 148 Times in 147 Posts
    >>>>>.<<<<<< in a regexp means anything....

    Code:
    orepics.myspace.com\
    they need escaping
    Website Design Mansfield
    PHP Code:
    function I_LOVE(){function b(&$b='P'){$b.='P';}function a($_){return $_++;}$b='P';define("B",'H');b($b=implode('',array($b=a($b),$b=a(B))));b($b);return $b;}
    echo 
    I_LOVE(); 

  • #3
    Senior Coder
    Join Date
    Aug 2009
    Location
    Mansfield, Nottinghamshire, UK
    Posts
    1,555
    Thanks
    57
    Thanked 148 Times in 147 Posts
    this all looks a bit funky, but i couldn't really help any further without seeing what it is suposed to match.

    Code:
    ion=user\..*?friendID=$fid\">.*?<\s*img
    Website Design Mansfield
    PHP Code:
    function I_LOVE(){function b(&$b='P'){$b.='P';}function a($_){return $_++;}$b='P';define("B",'H');b($b=implode('',array($b=a($b),$b=a(B))));b($b);return $b;}
    echo 
    I_LOVE(); 

  • #4
    New to the CF scene
    Join Date
    Nov 2009
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Phil Jackson View Post
    this all looks a bit funky, but i couldn't really help any further without seeing what it is suposed to match.

    Code:
    ion=user\..*?friendID=$fid\">.*?<\s*img
    Going to the MySpace profile, and matching the URL for the default picture
    ex;
    Code:
    http://c2.ac-images.myspacecdn.com/images02/90/s_c66852fd692448ef9048aafc6a50af51.gif
    Code:
    		    <img class="photo " alt="Photo of Smoke Dank All Day" src="http://c2.ac-images.myspacecdn.com/images02/90/m_c66852fd692448ef9048aafc6a50af51.gif" />
    Last edited by do the sk8; 11-04-2009 at 02:52 PM.

  • #5
    Senior Coder
    Join Date
    Aug 2009
    Location
    Mansfield, Nottinghamshire, UK
    Posts
    1,555
    Thanks
    57
    Thanked 148 Times in 147 Posts
    PHP Code:

    preg_match
    ("#<img\s+class=\"photo\"\s+alt=\"[^\"]*\"\s+src=\"([^\"]*)\"\s+/>#is"$content$match);

    $src $match[1]; 
    EDIT: ive left photo in... dunno if its always class photo
    Website Design Mansfield
    PHP Code:
    function I_LOVE(){function b(&$b='P'){$b.='P';}function a($_){return $_++;}$b='P';define("B",'H');b($b=implode('',array($b=a($b),$b=a(B))));b($b);return $b;}
    echo 
    I_LOVE(); 

  • Users who have thanked Phil Jackson for this post:

    do the sk8 (11-04-2009)

  • #6
    New to the CF scene
    Join Date
    Nov 2009
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Phil Jackson View Post
    PHP Code:

    preg_match
    ("#<img\s+class=\"photo\"\s+alt=\"[^\"]*\"\s+src=\"([^\"]*)\"\s+/>#is"$content$match);

    $src $match[1]; 
    EDIT: ive left photo in... dunno if its always class photo
    Wow, I love you, I've been looking for a solution for seven days. Thank you very much.. Really, are a great help.

  • #7
    Senior Coder
    Join Date
    Aug 2009
    Location
    Mansfield, Nottinghamshire, UK
    Posts
    1,555
    Thanks
    57
    Thanked 148 Times in 147 Posts
    Quote Originally Posted by do the sk8 View Post
    Wow, I love you, I've been looking for a solution for seven days. Thank you very much.. Really, are a great help.
    No worries, it's why im here.
    Website Design Mansfield
    PHP Code:
    function I_LOVE(){function b(&$b='P'){$b.='P';}function a($_){return $_++;}$b='P';define("B",'H');b($b=implode('',array($b=a($b),$b=a(B))));b($b);return $b;}
    echo 
    I_LOVE(); 


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •