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!

<?
/**
 * 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>] &nbsp;&nbsp;<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 &nbsp;&nbsp;&nbsp;&nbsp; </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>

Recommended Answers

All 14 Replies

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.

<tr><td colspan="2" align="left">
<input type="checkbox" name="remember" <? 
 
if( $form->value("remember") != "" )    
{
        echo "checked";
        
  }
 
 ?> >
    <font size="2">Remember me next time &nbsp;&nbsp;&nbsp;&nbsp; </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>

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:

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

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

$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.

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
}

Same thing as before all your GUEST_NAME variables do not have a $ in front of them.

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.

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.

commented: wrong way .. guy ! -2

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:

probably there is a brace missing for an if else.

hye,
i got the same error too,
its quite make me like crazy to solve it,huhuu
its said..

Parse error: syntax error, unexpected $end in C:\wamp\www\NDE_webpage(NEW)\admin_news2.php on line 154

this my php coding:

<?php
session_start();  //start secure part

echo $_SESSION['id'];
if (!isset($_SESSION['id']))
{
echo "<script type='text/javascript'>window.location = 'errorlogin.htm';</script>";
} //end secure part
?>

<script language="javascript" type="text/javascript" src="datetimepicker.js"></script>

<!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>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Admin-News</title>
<style type="text/css">
<!--
.style1 {
	color: #FFFFFF;
	font-size: medium;
	font-family: Arial, Helvetica, sans-serif;
	font-weight: bold;
}
.style2 {
	font-family: Arial, Helvetica, sans-serif;
	font-weight: bold;
}
.style3 {
	font-family: Arial, Helvetica, sans-serif;
	color: #000000;
}
-->
</style>
</head>

<body bgcolor="#CCCCCC">
<table width="1100" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td colspan="2"><img src="image/header_edit_news2.jpg" width="1100" height="65"></td>
  </tr>
  <tr>
    <td colspan="2" bgcolor="#CC3366">&nbsp;</td>
  </tr>
  <tr>
    <td width="230" rowspan="2" valign="top" bgcolor="#0000FF"><table width="230" border="0" cellspacing="4" cellpadding="0">
      <tr>
        <td bgcolor="#FFFFFF">&nbsp;</td>
      </tr>
      <tr>
        <td bgcolor="#66CCFF">&nbsp;</td>
      </tr>
      <tr>
        <td bgcolor="#FFFFFF">&nbsp;</td>
      </tr>
      <tr>
        <td bgcolor="#66CCFF">&nbsp;</td>
      </tr>
      <tr>
        <td bgcolor="#FFFFFF">&nbsp;</td>
      </tr>
    </table></td>
    <td width="870" valign="top" bgcolor="#FFFFFF"><form id="form_add_news" name="form_add_news" method="post" action="admin_newsB.php">
      <table width="870" border="0" cellspacing="2" cellpadding="0">
        <tr>
          <td colspan="2" bgcolor="#6699FF"><ul>
            <li class="style1">Add new announcement </li>
          </ul></td>
        </tr>
        <tr>
          <td width="82" height="31" bgcolor="#E0FCEA"><span class="style2">Date</span></td>
          <td width="782" bgcolor="#E0FCEA"><label>
            <input name="news_date" type="text" id="news_date" size="22" maxlength="20">
            <a href="javascript:NewCal('news_date','ddmmmyyyy',true,12)"><img src="cal.gif" width="16" height="16" border="0"></a></label></td>
        </tr>
        <tr>
          <td height="31" bgcolor="#E0FCEA"><span class="style2">Title</span></td>
          <td bgcolor="#E0FCEA"><label>
            <input name="news_title" type="text" id="news_title" size="75" maxlength="150">
          </label></td>
        </tr>
        <tr>
          <td height="138" valign="top" bgcolor="#E0FCEA"><span class="style2">Content</span></td>
          <td valign="top" bgcolor="#E0FCEA"><label>
            <textarea name="news_content" cols="60" rows="8" id="news_content"></textarea>
          </label></td>
        </tr>
        <tr>
          <td height="24" colspan="2" valign="top"><label>
            <div align="right">
              <input type="reset" name="Reset" value="Reset">
              <input name="add_news" type="submit" id="add_news" value="Save">
              </div>
          </label></td>
        </tr>
      </table>
            </form>    </td>
  </tr>
  <tr>
    <td height="447" valign="top" bgcolor="#FFFFFF">
	<form action="admin_news2.php" method="post" name="form_news_list" id="form_news_list">
      <table width="870" border="0" cellspacing="2" cellpadding="0">
        <tr>
          <td colspan="3" bgcolor="#6699FF"><ul>
            <li class="style1">List of annoucement </li>
          </ul></td>
        </tr>
        <tr>
          <td width="155" bgcolor="#FFCCCC"><strong><span class="style3">Date</span></strong></td>
          <td width="625" bgcolor="#FFCCCC"><strong><span class="style3">Title</span></strong></td>
          <td width="82" bgcolor="#FFCCCC"><strong><span class="style3">Select</span></strong></td>
        </tr>
 
        <tr>
          <td bgcolor="#E0FCEA">
		  
		      <?php
			  $host="localhost"; // Host name
              $username="root"; // Mysql username
 			  $password=""; // Mysql password
              $db_name="nde_db"; // Database name

         
              mysql_connect("$host", "$username", "$password")or die("cannot connect");
              mysql_select_db("$db_name")or die("Fuck you.cannot select DB");
              //LINK TO THE DATBASE---------------------------------------------------->
              ?>
			  <?
			  $result = mysql_query("SELECT * FROM news_list");
		  			
			  //$row = mysql_fetch_array( $result );
              
              while($row = mysql_fetch_array( $result ))
			  {
			  	$id = $row['id'];
			  ?>
		      <? echo $row['date'];?></td>
              <td bgcolor="#E0FCEA"><a href="#?id=<?=$id?> "><? echo $row['title']; ?></a></td>
              <td bgcolor="#E0FCEA">&nbsp;</td>
		      <? }?>
       
	    </tr>
        <tr>
          <td colspan="3">&nbsp;</td>
        </tr>
      </table>
            </form>
    </td>
  </tr>
  <tr>
    <td colspan="2" bgcolor="#CC3366">&nbsp;</td>
  </tr>
</table>
</body>
</html>

Try replacing your opening PHP tags with <?php instead of <?.

PHP short open tags are only available is specifically enabled in the configuration.

edit:

same for the <?= notation.

can anyone help me with this?...this is the error msg i get. this is my script

<?php

//'send me an email' script



 if ($_POST['submit'])
 {
 //get data from form

    $email = $_POST['email'];   
    $name = $_POST['name'];
    $phone = $_POST['phone'];
    $request = $_POST['request'];
    $details = $_POST['details'];

if ($name&&$email&&$phone&&$request&&$details)//existance check
{

    $namelen=20;
    $emaillen=50;
    $telelen=12;
    $detaillen=150;
if(strlen($name)<=$namelen&&strlen($email)<=emaillen&&strlen($tele)<=telelen&&($detail)<=$detaillen) //lenght check
{
 //everyting is ok!

//set SMPT in php.ini
ini_set("SMTP", "smtpout.secureserver.net");
echo ini_get("SMTP");
die();

 //setup variables
    $Subject = 'EmailMe!';
    $to = "neweraconceptz@partyrebellerz.com";
    $headers = "From: $email\r\n";
    $body = "This is an email from $name\n\n$message";

    mail($to, $subject, $body, $headers); 

    die();


?>
<html>
<form action="/gdform.php" method="post">
<input type="hidden" name="subject" value="Form Submission" />
<input type="hidden" name="redirect" value="thankyou.html" />
<p>Name:<input type="text" name="FirstName" maxlenght="20" /></p>
<p>E-Mail:<input type="text" name="email" maxlength="50" /></p>
<p>Phone Number:<input type="text" name="phonenumber" maxlength="12" /></p>
<p>Request:
  <select name="select" id="select">
    <option selected>--SELECT ONE--</option>
    <option>Website Design</option>
    <option>Banners</option>
    <option>Entry Page</option>
    <option>Logo/Flyer/Teaser/Video Ad</option>
    <option>Event Plannnig</option>
  </select>
</p>
<p>Details:<textarea name="details" cols="40" rows="7" maxlength="150">
Type request here.</textarea></p>
<input name="submit" type="submit" id="submit" value="send info"/>
</form>
</html>

looks like your if statements are not being closed. make sure you close them properly i.e. whenever you have an open brace, {, it has a corresponding }. From a quick look you have 3 open braces without a matching closing brace.

hope that helps.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.