944,149 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 24835
  • PHP RSS
You are currently viewing page 1 of this multi-page discussion thread
Mar 20th, 2007
0

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

Expand Post »
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)
  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.
Reputation Points: 10
Solved Threads: 3
Junior Poster
Barefootsanders is offline Offline
165 posts
since Oct 2006
Mar 20th, 2007
0

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

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)
  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>
Reputation Points: 8
Solved Threads: 2
Junior Poster in Training
GliderPilot is offline Offline
57 posts
since Sep 2006
Mar 20th, 2007
0

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

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)
  1. $this->username = $_SESSION['username'] = GUEST_NAME;

Any suggestions? Thanks.
Reputation Points: 10
Solved Threads: 3
Junior Poster
Barefootsanders is offline Offline
165 posts
since Oct 2006
Mar 21st, 2007
0

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

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;
Reputation Points: 8
Solved Threads: 2
Junior Poster in Training
GliderPilot is offline Offline
57 posts
since Sep 2006
Mar 22nd, 2007
0

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

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)
  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:

PHP Syntax (Toggle Plain Text)
  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.
Moderator
Reputation Points: 457
Solved Threads: 101
Nearly a Posting Virtuoso
digital-ether is offline Offline
1,250 posts
since Sep 2005
Mar 22nd, 2007
0

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

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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
tintinz is offline Offline
7 posts
since Dec 2006
Mar 24th, 2007
0

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

Same thing as before all your GUEST_NAME variables do not have a $ in front of them.
Reputation Points: 8
Solved Threads: 2
Junior Poster in Training
GliderPilot is offline Offline
57 posts
since Sep 2006
Mar 26th, 2007
0

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

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.
Reputation Points: 17
Solved Threads: 14
Posting Whiz
DanceInstructor is offline Offline
355 posts
since Feb 2005
Mar 28th, 2007
-1

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

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.
Reputation Points: 8
Solved Threads: 2
Junior Poster in Training
GliderPilot is offline Offline
57 posts
since Sep 2006
Mar 30th, 2007
0

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

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:
Reputation Points: 17
Solved Threads: 14
Posting Whiz
DanceInstructor is offline Offline
355 posts
since Feb 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: PHP Script Question
Next Thread in PHP Forum Timeline: Updating populated rows with textarea with PHP





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC