Parse error: syntax error, unexpected '('

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mayanktalwar1988
Forum Contributor
Posts: 133
Joined: Wed Jul 08, 2009 2:44 am

Parse error: syntax error, unexpected '('

Post 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?
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

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

Post 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?
mayanktalwar1988
Forum Contributor
Posts: 133
Joined: Wed Jul 08, 2009 2:44 am

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

Post by mayanktalwar1988 »

well its seems like i have to escape inverted commas :)
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

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

Post 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.
Post Reply