Welcome to WebmasterWorld Guest from 54.162.239.134

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)

10+ Year Member



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)

WebmasterWorld Senior Member 10+ Year Member



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)

10+ Year Member



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)

10+ Year Member



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)

WebmasterWorld Senior Member 10+ Year Member



Good call Chroder. :)

Jordan

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

10+ Year Member



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

Featured Threads

Hot Threads This Week

Hot Threads This Month