| | |
syntax error, unexpected $end in ndex.php on line 127
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Oct 2006
Posts: 164
Reputation:
Solved Threads: 3
Hey everyone. I just got my server up and running and I programed my database, or so I thought. I tried uploading it and running it but my index.php gives me "syntax error, unexpected $end in index.php on line 127". My code is below. Can anyone help?? Thanks!
PHP Syntax (Toggle Plain Text)
<? /** * index.php * * This is the main layout of the page. */ include("includes/session.php"); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Online Game</title> <!-- Web Site: www.onlinegame.com Description: --> <link rel="stylesheet" type="text/css" href="css/layout.css" /> <link rel="stylesheet" type="text/css" href="css/presentation.css" /> </head> <body> <!-- header div --> <div id="hdr">Header Content Here</div> <!-- center column --> <div id="c-block"> <div id="c-col"> <h3 align="center"> </h3> <!---<div align="center" style="color:red;">Ver 2.3</div>---> </div> <!-- end of center column --> </div> <!-- end c-block --> <div id="ftr" align="center">Footer Div - Copyright Information </div> <!-- left column --> <div id="lh-col"><br /> <h4 align="left">Left Column</h4> <? if( $session->logged_in ) { echo "<h1>Logged In</h1>"; echo "Welcome <b>$session->username</b>, you are logged in. <br><br>" ."[<a href=\"userinfo.php?user=$session->username\">My Account</a>]<br>" ."[<a href=\"useredit.php\">Edit Account</a>] <br>"; if( $session->isAdmin() ) { echo "[<a href=\"admin/admin.php\">Admin Center</a>]<br>"; } echo "<br><br><br>"; echo "[<a href=\"process.php\">Logout</a>]"; } else { ?> <!--- User not logged in, show login form. If errors occur, they will be displayed ---> <h1>Login</h1> <? if( $form->num_errors > 0 ) { echo "Invalid username/password combination. Please try again"; //echo "<font size=\"2\" color=\"#ff0000\">".$form->num_errors." error(s) found</font>" } ?> <form action="process.php" method="POST"> <table align="left" border="0" cellspacing="0" cellpadding="3"> <tr><td>Username:</td><td> <input type="text" name="username" maxlength="30" value="<? echo $form->value("username"); ?>"></td><td> <? echo $form->error("username"); ?></td></tr> <tr><td>Password:</td><td> <input type="password" name="password" maxlength="30" value="<? echo $form->value("password"); ?>"></td><td> <? echo $form->error("password"); ?></td></tr> <tr><td colspan="2" align="left"> <input type="checkbox" name="remember" <? if( $form->value("remember") != "" ) ?> > { <? echo "checked"; ?> } <font size="2">Remember me next time </font> <input type="hidden" name="sublogin" value="1"> <input type="submit" value="Login"></td></tr> <!--- <tr><td colspan="2" align="left"><br><font size="2">[<a href="forgotpass.php">Forgot Password?</a>]</font></td><td align="right"></td></tr> ---> <tr><td colspan="2" align="left"><br>Not registered? <a href="register.php">Sign-Up!</a></td></tr> </table> </form> } </div> <!-- end of left column --> <!-- right column --> <div id="rh-col"><br /> <h4 align="center">Right Column</h4> <p align="center">More links?<br /> Advertisements</p> </div> <!-- end of right column --> </body> </html>
Last edited by Barefootsanders; Mar 20th, 2007 at 9:39 pm.
Just some small errors in placements of your php open and close tags you have some php code outside of the tags, and some HTML tags in wrong spots.: change the end to this and it should work for you.
PHP Syntax (Toggle Plain Text)
<tr><td colspan="2" align="left"> <input type="checkbox" name="remember" <? if( $form->value("remember") != "" ) { echo "checked"; } ?> > <font size="2">Remember me next time </font> <input type="hidden" name="sublogin" value="1"> <input type="submit" value="Login"></td></tr> <!--- <tr><td colspan="2" align="left"><br><font size="2">[<a href="forgotpass.php">Forgot Password?</a>]</font></td><td align="right"></td></tr> ---> <tr><td colspan="2" align="left"><br>Not registered? <a href="register.php">Sign-Up!</a></td></tr> </table> </form> <? } ?> </div> <!-- end of left column --> <!-- right column --> <div id="rh-col"><br /> <h4 align="center">Right Column</h4> <p align="center">More links?<br /> Advertisements</p> </div> <!-- end of right column --> </body> </html>
•
•
Join Date: Oct 2006
Posts: 164
Reputation:
Solved Threads: 3
Ahh thank you. That fixed it up. But now I have another error. Its in my file that creates a PHP session.
It gives me this error:
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in session.php on line 59
And line 59 looks like this:
Any suggestions? Thanks.
It gives me this error:
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in session.php on line 59
And line 59 looks like this:
PHP Syntax (Toggle Plain Text)
$this->username = $_SESSION['username'] = GUEST_NAME;
Any suggestions? Thanks.
It looks like the GUEST_NAME is supposed to be a variable... if so you need a $ in front of it.
$this->username = $_SESSION['username'] = $GUEST_NAME;•
•
•
•
Ahh thank you. That fixed it up. But now I have another error. Its in my file that creates a PHP session.
It gives me this error:
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in session.php on line 59
And line 59 looks like this:
PHP Syntax (Toggle Plain Text)
$this->username = $_SESSION['username'] = GUEST_NAME;
Any suggestions? Thanks.
The code:
PHP Syntax (Toggle Plain Text)
$this->username = $_SESSION['username'] = GUEST_NAME;
looks ok. GUEST_NAME should be a constant. The only error that could be thrown by that line is if GUEST_NAME is not defined. It would be an E_NOTICE level error though which means its a precaution.
www.fijiwebdesign.com - web design and development and fun
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
•
•
Join Date: Dec 2006
Posts: 7
Reputation:
Solved Threads: 0
ok but i dont think so its because of the defined variable. if you think it is because it is not defined then try to trap it :
if (defined('GUEST_NAME')) { $this->username = $_SESSION['username'] = GUEST_NAME; }else{ // place the event here }
Last edited by tintinz; Mar 22nd, 2007 at 11:45 pm.
GliderPilot, GUEST_NAME is inteneded to be a constant. It is not a varaible.
The error is probably before line 59, as has already been mentioned.
The error is probably before line 59, as has already been mentioned.
Last edited by DanceInstructor; Mar 26th, 2007 at 5:56 pm.
My bad for repostng my suggestion I miss read the page. I saw the quote and though BareFoot posted that it had fixed it but she got same error elsewhere. Hence why I resuggested what I had mentioned earlier.
P.S. No need for the personal attacks I was just trying to help out.
I did mention that I THINK it is a variable if it is suppose to be a constant than I am odviosuly wrong. I agree that the error may be just before the quoted line.
P.S. No need for the personal attacks I was just trying to help out.
I did mention that I THINK it is a variable if it is suppose to be a constant than I am odviosuly wrong. I agree that the error may be just before the quoted line. •
•
•
•
My bad for repostng my suggestion I miss read the page. I saw the quote and though BareFoot posted that it had fixed it but she got same error elsewhere. Hence why I resuggested what I had mentioned earlier.
P.S. No need for the personal attacks I was just trying to help out.I did mention that I THINK it is a variable if it is suppose to be a constant than I am odviosuly wrong. I agree that the error may be just before the quoted line.
![]() |
Other Threads in the PHP Forum
- Previous Thread: Calling Audio Conversion Tool with PHP on Win 2003
- Next Thread: please help me on creating library system
| Thread Tools | Search this Thread |
ajax apache api array beginner binary body broken cakephp checkbox class cms code cron curl database date date/time display dynamic echo email error file files folder form forms function functions gc_maxlifetime global google host href htaccess html image include insert integration ip java javascript joomla limit link list login mail memmory menu mlm msqli_multi_query multiple mycodeisbad mysql navigation oop parameter parsing paypal pdf php problem query radio random recourse recursion regex registrationform remote script search seo server sessions sms snippet soap source space sql static syntax system table tutorial update upload url validator variable video web webdesign wordpress xml youtube






