syntax error, unexpected $end in ndex.php on line 127

Reply

Join Date: Oct 2006
Posts: 164
Reputation: Barefootsanders is an unknown quantity at this point 
Solved Threads: 3
Barefootsanders Barefootsanders is offline Offline
Junior Poster

syntax error, unexpected $end in ndex.php on line 127

 
0
  #1
Mar 20th, 2007
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!

  1. <?
  2. /**
  3.  * index.php
  4.  *
  5.  * This is the main layout of the page.
  6.  */
  7. include("includes/session.php");
  8. ?>
  9.  
  10. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  11. <html xmlns="http://www.w3.org/1999/xhtml">
  12. <head>
  13. <title>Online Game</title>
  14. <!--
  15. Web Site: www.onlinegame.com
  16. Description:
  17. -->
  18. <link rel="stylesheet" type="text/css" href="css/layout.css" />
  19. <link rel="stylesheet" type="text/css" href="css/presentation.css" />
  20. </head>
  21.  
  22. <body>
  23.  
  24. <!-- header div -->
  25. <div id="hdr">Header Content Here</div>
  26.  
  27. <!-- center column -->
  28. <div id="c-block">
  29. <div id="c-col">
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38. <h3 align="center"> </h3>
  39. <!---<div align="center" style="color:red;">Ver 2.3</div>--->
  40.  
  41.  
  42.  
  43. </div>
  44. <!-- end of center column -->
  45. </div>
  46. <!-- end c-block -->
  47.  
  48. <div id="ftr" align="center">Footer Div - Copyright Information
  49. </div>
  50.  
  51. <!-- left column -->
  52. <div id="lh-col"><br />
  53. <h4 align="left">Left Column</h4>
  54. <?
  55. if( $session->logged_in )
  56. {
  57. echo "<h1>Logged In</h1>";
  58. echo "Welcome <b>$session->username</b>, you are logged in. <br><br>"
  59. ."[<a href=\"userinfo.php?user=$session->username\">My Account</a>]<br>"
  60. ."[<a href=\"useredit.php\">Edit Account</a>] &nbsp;&nbsp;<br>";
  61. if( $session->isAdmin() )
  62. {
  63. echo "[<a href=\"admin/admin.php\">Admin Center</a>]<br>";
  64. }
  65. echo "<br><br><br>";
  66. echo "[<a href=\"process.php\">Logout</a>]";
  67. }
  68.  
  69.  
  70. else
  71. {
  72. ?>
  73. <!--- User not logged in, show login form. If errors occur, they will be displayed --->
  74. <h1>Login</h1>
  75.  
  76. <?
  77. if( $form->num_errors > 0 )
  78. {
  79. echo "Invalid username/password combination. Please try again";
  80. //echo "<font size=\"2\" color=\"#ff0000\">".$form->num_errors." error(s) found</font>"
  81. }
  82. ?>
  83.  
  84. <form action="process.php" method="POST">
  85. <table align="left" border="0" cellspacing="0" cellpadding="3">
  86. <tr><td>Username:</td><td>
  87. <input type="text" name="username" maxlength="30" value="<? echo $form->value("username"); ?>"></td><td>
  88. <? echo $form->error("username"); ?></td></tr>
  89.  
  90. <tr><td>Password:</td><td>
  91. <input type="password" name="password" maxlength="30" value="<? echo $form->value("password"); ?>"></td><td>
  92. <? echo $form->error("password"); ?></td></tr>
  93.  
  94. <tr><td colspan="2" align="left">
  95. <input type="checkbox" name="remember" <? if( $form->value("remember") != "" ) ?> >
  96. {
  97. <?
  98. echo "checked";
  99. ?>
  100. }
  101. <font size="2">Remember me next time &nbsp;&nbsp;&nbsp;&nbsp; </font>
  102. <input type="hidden" name="sublogin" value="1">
  103. <input type="submit" value="Login"></td></tr>
  104. <!--- <tr><td colspan="2" align="left"><br><font size="2">[<a href="forgotpass.php">Forgot Password?</a>]</font></td><td align="right"></td></tr> --->
  105. <tr><td colspan="2" align="left"><br>Not registered? <a href="register.php">Sign-Up!</a></td></tr>
  106. </table>
  107. </form>
  108.  
  109. }
  110.  
  111.  
  112. </div>
  113. <!-- end of left column -->
  114.  
  115. <!-- right column -->
  116. <div id="rh-col"><br />
  117. <h4 align="center">Right Column</h4>
  118. <p align="center">More links?<br />
  119. Advertisements</p>
  120. </div>
  121. <!-- end of right column -->
  122.  
  123. </body>
  124. </html>
Last edited by Barefootsanders; Mar 20th, 2007 at 9:39 pm.
Reply With Quote Quick reply to this message  
Join Date: Sep 2006
Posts: 57
Reputation: GliderPilot is an unknown quantity at this point 
Solved Threads: 2
GliderPilot's Avatar
GliderPilot GliderPilot is offline Offline
Junior Poster in Training

Re: syntax error, unexpected $end in ndex.php on line 127

 
0
  #2
Mar 20th, 2007
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.


  1.  
  2. <tr><td colspan="2" align="left">
  3. <input type="checkbox" name="remember" <?
  4.  
  5. if( $form->value("remember") != "" )
  6. {
  7. echo "checked";
  8.  
  9. }
  10.  
  11. ?> >
  12. <font size="2">Remember me next time &nbsp;&nbsp;&nbsp;&nbsp; </font>
  13. <input type="hidden" name="sublogin" value="1">
  14. <input type="submit" value="Login"></td></tr>
  15. <!--- <tr><td colspan="2" align="left"><br><font size="2">[<a href="forgotpass.php">Forgot Password?</a>]</font></td><td align="right"></td></tr> --->
  16. <tr><td colspan="2" align="left"><br>Not registered? <a href="register.php">Sign-Up!</a></td></tr>
  17. </table>
  18. </form>
  19.  
  20. <? } ?>
  21.  
  22. </div>
  23. <!-- end of left column -->
  24.  
  25. <!-- right column -->
  26. <div id="rh-col"><br />
  27. <h4 align="center">Right Column</h4>
  28. <p align="center">More links?<br />
  29. Advertisements</p>
  30. </div>
  31. <!-- end of right column -->
  32.  
  33. </body>
  34. </html>
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 164
Reputation: Barefootsanders is an unknown quantity at this point 
Solved Threads: 3
Barefootsanders Barefootsanders is offline Offline
Junior Poster

Re: syntax error, unexpected $end in ndex.php on line 127

 
0
  #3
Mar 20th, 2007
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:
  1. $this->username = $_SESSION['username'] = GUEST_NAME;

Any suggestions? Thanks.
Reply With Quote Quick reply to this message  
Join Date: Sep 2006
Posts: 57
Reputation: GliderPilot is an unknown quantity at this point 
Solved Threads: 2
GliderPilot's Avatar
GliderPilot GliderPilot is offline Offline
Junior Poster in Training

Re: syntax error, unexpected $end in ndex.php on line 127

 
0
  #4
Mar 21st, 2007
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;
Reply With Quote Quick reply to this message  
Join Date: Sep 2005
Posts: 1,075
Reputation: digital-ether is just really nice digital-ether is just really nice digital-ether is just really nice digital-ether is just really nice 
Solved Threads: 66
Moderator
digital-ether's Avatar
digital-ether digital-ether is offline Offline
Veteran Poster

Re: syntax error, unexpected $end in ndex.php on line 127

 
0
  #5
Mar 22nd, 2007
Originally Posted by Barefootsanders View Post
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:
  1. $this->username = $_SESSION['username'] = GUEST_NAME;

Any suggestions? Thanks.
The line numbers given for PHP parse errors are usually incorrect. Most likely the parse error occurred on the line just before the one given (line 58).


The code:

  1. $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!
Reply With Quote Quick reply to this message  
Join Date: Dec 2006
Posts: 7
Reputation: tintinz is an unknown quantity at this point 
Solved Threads: 0
tintinz tintinz is offline Offline
Newbie Poster

Re: syntax error, unexpected $end in ndex.php on line 127

 
0
  #6
Mar 22nd, 2007
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.
Reply With Quote Quick reply to this message  
Join Date: Sep 2006
Posts: 57
Reputation: GliderPilot is an unknown quantity at this point 
Solved Threads: 2
GliderPilot's Avatar
GliderPilot GliderPilot is offline Offline
Junior Poster in Training

Re: syntax error, unexpected $end in ndex.php on line 127

 
0
  #7
Mar 24th, 2007
Same thing as before all your GUEST_NAME variables do not have a $ in front of them.
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 355
Reputation: DanceInstructor is an unknown quantity at this point 
Solved Threads: 14
DanceInstructor's Avatar
DanceInstructor DanceInstructor is offline Offline
Posting Whiz

Re: syntax error, unexpected $end in ndex.php on line 127

 
0
  #8
Mar 26th, 2007
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.
Last edited by DanceInstructor; Mar 26th, 2007 at 5:56 pm.
Clear Mind Hosting and Web Design

If I've helped you please consider adding to my reputation.
Reply With Quote Quick reply to this message  
Join Date: Sep 2006
Posts: 57
Reputation: GliderPilot is an unknown quantity at this point 
Solved Threads: 2
GliderPilot's Avatar
GliderPilot GliderPilot is offline Offline
Junior Poster in Training

Re: syntax error, unexpected $end in ndex.php on line 127

 
0
  #9
Mar 28th, 2007
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.
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 355
Reputation: DanceInstructor is an unknown quantity at this point 
Solved Threads: 14
DanceInstructor's Avatar
DanceInstructor DanceInstructor is offline Offline
Posting Whiz

Re: syntax error, unexpected $end in ndex.php on line 127

 
0
  #10
Mar 30th, 2007
Originally Posted by GliderPilot View Post
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.
You really think that was a personal attack? :eek:
Clear Mind Hosting and Web Design

If I've helped you please consider adding to my reputation.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC