Forum Moderators: coopster

Message Too Old, No Replies

PHP problem

syntax error, unexpected T_STRING

         

qijiayang

4:00 pm on Apr 24, 2005 (gmt 0)

10+ Year Member



Hello,
The following function is in my pagedisplay.inc file, when I run home.php which includes pagedisplay.inc file, I got error "Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in C:\Inetpub\wwwroot\MyWeb\pagedisplay.inc on line 86". line 86 is: echo "<table width=\"100%\" bgcolor=white".
I pasted this line to another php file, it worked very well. I tried hard to figure out the problem, but still haven't got any clues. I highly appreciate any help from anyone.
function DisplayMenu($buttons){
echo "<table width=\"100%\" bgcolor=white"
." cellpadding=4 cellspacing=4>\n";
echo "<tr>\n";

//calculate button size
$width=100/count($buttons);
while(list($name,$url)=each($buttons))
{
$this->DisplayButton($width, $name, $url,
!$this->IsURLCurrentPage($url));

}
echo "</tr>\n";
echo "</table>\n";

}

Amy

jatar_k

5:07 pm on Apr 24, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld qijiayang,

maybe try changing that line to

echo "<table width=\"100%\" bgcolor=white cellpadding=4 cellspacing=4>\n<tr>\n";

then see if it still reports an error

qijiayang

5:56 pm on Apr 24, 2005 (gmt 0)

10+ Year Member



Thank you for your reply, but still got the same error. I am just wondering if this is related to file extension, why the same statement works in php file, but doesn't work in .inc file.
I am fairly new to PHP, really appreciate your help.

Amy

IamStang

6:21 pm on Apr 24, 2005 (gmt 0)

10+ Year Member



I cut and pasted your code as it is. It returned errors of course. But not the one in question.

I have ran into this before, as everyone has, and it seems to always be (atleast for me) due to a missing ; further up in the script.

It's worth a look anyway.

Hope it helps,
IamStang

ergophobe

7:44 pm on Apr 24, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month




I am just wondering if this is related to file extension,

If you are getting a PHP error message, that means that the script is being processed by PHP. I would put my money with IamStang, since the code looks fine, there's probably something (not necessarily a semi-colon) missing further up.

In fact, if I had to put money on it, I would guess that you have a mismatched quote further up in your script. The first quote of the line in question is thus closing the quoted string rather than opening a new one, and that causes things to blow up. Just a guess.

mcibor

9:14 pm on Apr 24, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you encounter this error it means that the ";" is missing, possibly few lines above.

Therefore or put here a little more above lines, or try to find the error.

Best wishes
Michal Cibor

qijiayang

9:30 pm on Apr 24, 2005 (gmt 0)

10+ Year Member




Hi IamStang,

Thank you for your suggestion! I checked the file again, there is no missing ";", but I did find one statement missing quotation mark at the end. After I added that quotation mark, my program works fine.

Thank you so much!

Amy