Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-04-2009, 06:09 AM   PM User | #1
do the sk8
New to the CF scene

 
Join Date: Nov 2009
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
do the sk8 is an unknown quantity at this point
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!
do the sk8 is offline   Reply With Quote
Old 11-04-2009, 08:46 AM   PM User | #2
Phil Jackson
Senior Coder

 
Join Date: Aug 2009
Location: Mansfield, Nottinghamshire, UK
Posts: 1,547
Thanks: 57
Thanked 148 Times in 147 Posts
Phil Jackson is on a distinguished road
>>>>>.<<<<<< 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(); 
Phil Jackson is offline   Reply With Quote
Old 11-04-2009, 08:48 AM   PM User | #3
Phil Jackson
Senior Coder

 
Join Date: Aug 2009
Location: Mansfield, Nottinghamshire, UK
Posts: 1,547
Thanks: 57
Thanked 148 Times in 147 Posts
Phil Jackson is on a distinguished road
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(); 
Phil Jackson is offline   Reply With Quote
Old 11-04-2009, 01:47 PM   PM User | #4
do the sk8
New to the CF scene

 
Join Date: Nov 2009
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
do the sk8 is an unknown quantity at this point
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 01:52 PM..
do the sk8 is offline   Reply With Quote
Old 11-04-2009, 04:59 PM   PM User | #5
Phil Jackson
Senior Coder

 
Join Date: Aug 2009
Location: Mansfield, Nottinghamshire, UK
Posts: 1,547
Thanks: 57
Thanked 148 Times in 147 Posts
Phil Jackson is on a distinguished road
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(); 
Phil Jackson is offline   Reply With Quote
Users who have thanked Phil Jackson for this post:
do the sk8 (11-04-2009)
Old 11-04-2009, 06:17 PM   PM User | #6
do the sk8
New to the CF scene

 
Join Date: Nov 2009
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
do the sk8 is an unknown quantity at this point
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.
do the sk8 is offline   Reply With Quote
Old 11-04-2009, 08:16 PM   PM User | #7
Phil Jackson
Senior Coder

 
Join Date: Aug 2009
Location: Mansfield, Nottinghamshire, UK
Posts: 1,547
Thanks: 57
Thanked 148 Times in 147 Posts
Phil Jackson is on a distinguished road
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(); 
Phil Jackson is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:42 AM.


Advertisement
Log in to turn off these ads.