Welcome to WebmasterWorld Guest from 54.166.181.126

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

parse error, unexpected T_STRING

What on earth is wrong

     
11:19 pm on Oct 19, 2003 (gmt 0)

Junior Member

10+ Year Member

joined:June 14, 2003
posts:42
votes: 0


I'm fairly new to PHP. I have been puzzling for hours over this;_

I'm getting
Parse error: parse error, unexpected T_STRING, expecting '(' in /usr/www/users/wildsite/ecodating/datread3.php on line 13

Here is the program Any ideas why it does not work?

<html>
<head>
<title> results </title>
<body>
<?php
$filename ="findata.txt";
$myFile = fopen($filename, "r");
$fcontents = file($filename);
while (list ($line_num, $line) = each ($fcontents))
{
echo $line."<br>\n";
$pattern ="/END0/";
if preg_match ("/END0/",$line)
{
echo "DO work":
}

}
fclose($myFile);
?>
</body>
</html>

11:36 pm on Oct 19, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:July 26, 2003
posts:881
votes: 0


If that's your whole file then the problem is on the if preg_match line (which is what I was thinking anyhow) -- try single quoting the pattern or escaping the pound sign, it is probably having trouble parsing it, so it thinks there isn't a closing quote and thus thinks there isn't a closing parenthesis...that would be my best guess.

Jordan

12:05 am on Oct 20, 2003 (gmt 0)

Full Member

10+ Year Member

joined:May 8, 2002
posts:226
votes: 0


You also have a colon instead of a semi-colon at the end of your echo "Do Work" statement.
12:40 am on Oct 20, 2003 (gmt 0)

New User

10+ Year Member

joined:Oct 19, 2003
posts:5
votes: 0


Try

if(preg_match("/END0/",$line))

in place of your current if. (along with fixint what keeper said) :)

2:49 am on Oct 20, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:July 26, 2003
posts:881
votes: 0


Good call Chroder. :)

Jordan

7:18 pm on Oct 22, 2003 (gmt 0)

Junior Member

10+ Year Member

joined:June 14, 2003
posts:42
votes: 0


Duh! Of course. Thanks everybody. It is obvious when you see it. It have been programing in too many different languages recently.
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members