...

View Full Version : Preg_Match error



do the sk8
11-04-2009, 07:09 AM
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:

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:


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!

Phil Jackson
11-04-2009, 09:46 AM
>>>>>.<<<<<< in a regexp means anything....


orepics.myspace.com\

they need escaping

Phil Jackson
11-04-2009, 09:48 AM
this all looks a bit funky, but i couldn't really help any further without seeing what it is suposed to match.


ion=user\..*?friendID=$fid\">.*?<\s*img

do the sk8
11-04-2009, 02:47 PM
this all looks a bit funky, but i couldn't really help any further without seeing what it is suposed to match.


ion=user\..*?friendID=$fid\">.*?<\s*img

Going to the MySpace profile, and matching the URL for the default picture
ex;
http://c2.ac-images.myspacecdn.com/images02/90/s_c66852fd692448ef9048aafc6a50af51.gif


<img class="photo " alt="Photo of Smoke Dank All Day" src="http://c2.ac-images.myspacecdn.com/images02/90/m_c66852fd692448ef9048aafc6a50af51.gif" />

Phil Jackson
11-04-2009, 05:59 PM
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

do the sk8
11-04-2009, 07:17 PM
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.

Phil Jackson
11-04-2009, 09:16 PM
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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum