Page 1 of 1

Parse error: syntax error, unexpected '('

Posted: Tue Jun 08, 2010 10:57 pm
by mayanktalwar1988

Code: Select all

<?php
include("config.php");
function extracter($crawledurl)
{
$contents1 = file_get_contents($crawledurl);
preg_match_all("/(http:\/\/)?(www.)?rapidshare\.com\/[0-9A-Za-z]+\/[0-9A-Za-z]+\/[0-9A-Za-z_.]+/",$contents1,$out1);
$len1=count($out1[0]);
if($len1>1)
$down=implode(",",$out1[0]);
preg_match_all("/(?<=<[tT][iI][tT][lL][eE]>).*(?=<\/[tT][iI][tT][lL][eE]>)/",$contents1,$out2);

preg_match_all("/<a href="(http:\/\/)?(www.)?[0-9A-Za-z]+\.com\/[0-9A-Za-z\s]+\/\?cat=[0-9]+" title="[a-zA-Z0-9\s]+" rel="[a-zA-Z\s]+">[a-zA-Z0-9\s]+<\/a>/",$contents1,$out3);
$len3=count($out3[0]);
if($len3>1)
$cat=implode(",",$out3[0]);
$exquery="insert into downloads('title','downloadlink','pagelink','category') values('".$out2[0][0]."',$down,$crawledurl,$cat)";
mysql_query($exquery) or die (mysql_error());


}
$query="select * from crawler";
$result=mysql_query($query) or die(mysql_error());
set_time_limit(10000);
while($extracter=mysql_fetch_array($result,MYSQL_BOTH))
{
extracter($extracter['links']);
}
?>
Parse error: syntax error, unexpected '(' in C:\xampp\htdocs\extracter.php on line 12

this is line 12

Code: Select all

preg_match_all("/<a href="(http:\/\/)?(www.)?[0-9A-Za-z]+\.com\/[0-9A-Za-z\s]+\/\?cat=[0-9]+" title="[a-zA-Z0-9\s]+" rel="[a-zA-Z\s]+">[a-zA-Z0-9\s]+<\/a>/",$contents1,$out3);
not able to figure it out where is the error?

Re: Parse error: syntax error, unexpected '('

Posted: Tue Jun 08, 2010 11:59 pm
by requinix
mayanktalwar1988 wrote:not able to figure it out where is the error?
Have you looked at your post? At the code you posted. At the highlighting. Does anything about it seem odd to you?

Re: Parse error: syntax error, unexpected '('

Posted: Wed Jun 09, 2010 1:47 am
by mayanktalwar1988
well its seems like i have to escape inverted commas :)

Re: Parse error: syntax error, unexpected '('

Posted: Wed Jun 09, 2010 2:31 am
by requinix
See how the highlighting starts blue, then goes back to black, then blue again, then black... switching when it finds a quotation mark? The black means the string ended.

Which isn't what you want. You want the string to keep going but with a literal " inside of it.

Take a look at the manual and see if something there seems applicable.