Jump to content

Parse Error: Syntax Error, Unexpected T_string


himesh

Recommended Posts

HiIm creating a website for a project and have come across this error and cant figure it out! In my right hand bar, i want the login form to appear if the user has not logged in. Im trying to do this with an if else statment but have been stuck on this one line for ages now. If somebody could shed some light, it would be much appreciated!The line im getting an error on is 172, the error message is "Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/himeshs/public_html/communicate/index.php on line 172"Thanks

<?php//initialize the sessionif(!isset($_SESSION['userid'])){// session not logged in so display form}else{// session logged }?><?php require_once('Connections/conn_comm.php'); ?><?phpif (!function_exists("GetSQLValueString")) {function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") {  if (PHP_VERSION < 6) {	$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;  }  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);  switch ($theType) {	case "text":	  $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";	  break;		case "long":	case "int":	  $theValue = ($theValue != "") ? intval($theValue) : "NULL";	  break;	case "double":	  $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";	  break;	case "date":	  $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";	  break;	case "defined":	  $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;	  break;  }  return $theValue;}}mysql_select_db($database_conn_comm, $conn_comm);$query_Search_all = "SELECT producttype, manufacturer, modelnumber, price, quantity, image FROM tblproduct ORDER BY manufacturer ASC";$Search_all = mysql_query($query_Search_all, $conn_comm) or die(mysql_error());$row_Search_all = mysql_fetch_assoc($Search_all);$totalRows_Search_all = mysql_num_rows($Search_all);?><?php// *** Validate request to login to this site.if (!isset($_SESSION)) {  session_start();}$loginFormAction = $_SERVER['PHP_SELF'];if (isset($_GET['accesscheck'])) {  $_SESSION['PrevUrl'] = $_GET['accesscheck'];}if (isset($_POST['username'])) {  $loginUsername=$_POST['username'];  $password=$_POST['password'];  $MM_fldUserAuthorization = "";  $MM_redirectLoginSuccess = "loggedin.php";  $MM_redirectLoginFailed = "sorry.php";  $MM_redirecttoReferrer = false;  mysql_select_db($database_conn_comm, $conn_comm);    $LoginRS__query=sprintf("SELECT username, password FROM tbluser WHERE username=%s AND password=%s",	GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));      $LoginRS = mysql_query($LoginRS__query, $conn_comm) or die(mysql_error());  $loginFoundUser = mysql_num_rows($LoginRS);  if ($loginFoundUser) {	 $loginStrGroup = "";		//declare two session variables and assign them	$_SESSION['MM_Username'] = $loginUsername;	$_SESSION['MM_UserGroup'] = $loginStrGroup;		  	if (isset($_SESSION['PrevUrl']) && false) {	  $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];		}	header("Location: " . $MM_redirectLoginSuccess );  }  else {	header("Location: ". $MM_redirectLoginFailed );  }}?><?php session_start();?><!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=utf-8" /><title>Communicate - the best in mobile communications</title><link rel="stylesheet" type="text/css" href="_css/main.css" /><link rel="stylesheet" type="text/css" href="_css/style.css" />	<script src="jquery-1.2.1.min.js" type="text/javascript"></script>	<script src="menu.js" type="text/javascript"></script><!--[if IE]><style type="text/css"> /* place css fixes for all versions of IE in this conditional comment */.thrColElsHdr #sidebar1, .thrColElsHdr #sidebar2 { padding-top: 30px; }.thrColElsHdr #mainContent { zoom: 1; padding-top: 15px; }/* the above proprietary zoom property gives IE the hasLayout it needs to avoid several bugs */</style><![endif]--></head><body class="thrColElsHdr"><div id="container">  <div id="header">   <div id="search">   <input name="search" type="text" id="search" value="<?php echo $row_Search_all['']; ?>" />   </div>     <!-- end #header -->  </div>      <div id="sidebar1"><ul id="menu">						<li><a href="http://www.himeshs.co.uk/communicate/index.php">Home</a></li>									 														<li>							<a href="#">Manufacturer</a>							<ul> 							  <li><a href="http://www.himeshs.co.uk/communicate/allmanufacturer.php">All</a></li> 							<li><a href="http://www.himeshs.co.uk/communicate/se.php">Sony Ericsson</a></li> 							<li><a href="http://www.himeshs.co.uk/communicate/apple.php">Apple</a></li> 							<li><a href="http://www.himeshs.co.uk/communicate/nokia.php">Nokia</a></li> 							<li><a href="http://www.himeshs.co.uk/communicate/samsung.php">Samsung</a></li> 							</ul> 						</li>													 <li>							<a href="#">Type</a>								<ul> 							<li><a href="http://www.himeshs.co.uk/communicate/alltype.php">All</a></li> 							<li><a href="http://www.himeshs.co.uk/communicate/slide.php">Slide</a></li> 							<li><a href="http://www.himeshs.co.uk/communicate/candy.php">Candy Bar</a></li> 							<li><a href="http://www.himeshs.co.uk/communicate/flip.php">Flip</a></li>					  							</ul> 	  </li>																  <li>							<a href="#">Features</a>							<ul> 							<li><a href="http://www.himeshs.co.uk/communicate/camera.php">Camera</a></li> 							<li><a href="http://www.himeshs.co.uk/communicate/music.php">Music</a></li> 							<li><a href="http://www.himeshs.co.uk/communicate/internet.php">Internet</a></li>												  							</ul> 						</li>									<li><a href="http://www.himeshs.co.uk/communicate/aboutus.php">About us</a></li>							<li><a href="http://www.himeshs.co.uk/communicate/contact.php">Contact us</a></li>	</ul>  <!-- end #sidebar1 -->  </div>      <div id="sidebar2">    <?if(isset($session)){  // Member is logged in so we have to display welcome message with userid and one logout linkecho $_SESSION['MM_Username']  ;}else {  // Member has not logged in so we can display the login form allowing member to login with user id and passwordecho "	  <form id="form1" name="form1" method="POST" action="<?php echo $loginFormAction; ?>">";			 <input type="text" name="username" id="username" />	  <br />	  Password<br />	<input type="password" name="password" id="password" /> <br /><input name="Submit" type="submit" value="Submit" /></form>"};?>          <!-- end #sidebar2 --></div>      <div id="mainContent">	<h1> Main Content </h1>	<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Praesent aliquam,  justo convallis luctus rutrum, erat nulla fermentum diam, at nonummy quam  ante ac quam. Maecenas urna purus, fermentum id, molestie in, commodo  porttitor, felis. Nam blandit quam ut lacus. </p>	<p>Quisque ornare risus quis  ligula. Phasellus tristique purus a augue condimentum adipiscing. Aenean  sagittis. Etiam leo pede, rhoncus venenatis, tristique in, vulputate at,  odio. Donec et ipsum et sapien vehicula nonummy. Suspendisse potenti. Fusce  varius urna id quam. Sed neque mi, varius eget, tincidunt nec, suscipit id,  libero. </p>	<h2>H2 level heading </h2>	<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Praesent aliquam,  justo convallis luctus rutrum, erat nulla fermentum diam, at nonummy quam  ante ac quam. Maecenas urna purus, fermentum id, molestie in, commodo  porttitor, felis. Nam blandit quam ut lacus. Quisque ornare risus quis  ligula. Phasellus tristique purus a augue condimentum adipiscing. Aenean  sagittis. Etiam leo pede, rhoncus venenatis, tristique in, vulputate at, odio.</p>	<!-- end #mainContent -->  </div>		<!-- This clearing element should immediately follow the #mainContent div in order to force the #container div to contain all child floats --><br class="clearfloat" />   <div id="footer">	<p>Footer</p>  <!-- end #footer --></div><!-- end #container --></div></body></html><?phpmysql_free_result($Search_all);?>

Link to comment
Share on other sites

Can you declare these lines like this?1. case "long":2. if (isset($_SESSION['PrevUrl']) && false) {1. Has no semi-colon and doesn't do anything?2. What is false?

Link to comment
Share on other sites

1. case "long":
That's part of a switch statement:http://www.php.net/manual/en/control-structures.switch.phpThis:
  switch ($theType) {	case "long":	case "int":

Means to execute the following block of code (until a break statement) if $theType is either "long" or "int".

2. if (isset($_SESSION['PrevUrl']) && false) {
It's legal to make a statement like that, but it will never be true. The "and false" means that regardless of whether or not the $_SESSION variable is set, the if statement will still evaluate to false. Programmers sometimes add "and false" to temporarily disable something.This is what the parse error is talking about:
echo "	  <form id="form1" name="form1" method="POST" action="<?php echo $loginFormAction; ?>">";...

The double quote in "form1" ends the string, so you either need to escape all of your double quotes in the string or it's generally easier to use the heredoc syntax for long strings:http://www.php.net/manual/en/language.type....syntax.heredoce.g.:

echo <<<END_OF_HTML	  <form id="form1" name="form1" method="POST" action="{$loginFormAction}">			 <input type="text" name="username" id="username" />...END_OF_HTML;

Link to comment
Share on other sites

HiThanks for your help! That worked a treat... until I tried to do the same for the first part of the if statement, I wanted the sidebar to display the cart and a welcome message when the user is logged in. I am now getting this message and cant figure it out. Parse error: syntax error, unexpected T_SL in /home/himeshs/public_html/communicate/index.php on line 191This is line 191 of my code.

echo <<<END_OF_HTML

It is just under

  <?phpif(isset($session)){

<?php//initialize the sessionif(!isset($_SESSION['userid'])){// session not logged in so display form}else{// session logged }?><?php require_once('Connections/conn_comm.php'); ?><?phpif (!function_exists("GetSQLValueString")) {function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") {  if (PHP_VERSION < 6) {	$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;  }  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);  switch ($theType) {	case "text":	  $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";	  break;		case "long":	case "int":	  $theValue = ($theValue != "") ? intval($theValue) : "NULL";	  break;	case "double":	  $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";	  break;	case "date":	  $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";	  break;	case "defined":	  $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;	  break;  }  return $theValue;}}mysql_select_db($database_conn_comm, $conn_comm);$query_Search_all = "SELECT producttype, manufacturer, modelnumber, price, quantity, image FROM tblproduct ORDER BY manufacturer ASC";$Search_all = mysql_query($query_Search_all, $conn_comm) or die(mysql_error());$row_Search_all = mysql_fetch_assoc($Search_all);$totalRows_Search_all = mysql_num_rows($Search_all);$maxRows_cart = 1;$pageNum_cart = 0;if (isset($_GET['pageNum_cart'])) {  $pageNum_cart = $_GET['pageNum_cart'];}$startRow_cart = $pageNum_cart * $maxRows_cart;$colname_cart = "-1";if (isset($_GET['MM_Username'])) {  $colname_cart = $_GET['MM_Username'];}mysql_select_db($database_conn_comm, $conn_comm);$query_cart = sprintf("SELECT * FROM tblcart WHERE username = %s", GetSQLValueString($colname_cart, "text"));$query_limit_cart = sprintf("%s LIMIT %d, %d", $query_cart, $startRow_cart, $maxRows_cart);$cart = mysql_query($query_limit_cart, $conn_comm) or die(mysql_error());$row_cart = mysql_fetch_assoc($cart);if (isset($_GET['totalRows_cart'])) {  $totalRows_cart = $_GET['totalRows_cart'];} else {  $all_cart = mysql_query($query_cart);  $totalRows_cart = mysql_num_rows($all_cart);}$totalPages_cart = ceil($totalRows_cart/$maxRows_cart)-1;?><?php// *** Validate request to login to this site.if (!isset($_SESSION)) {  session_start();}$loginFormAction = $_SERVER['PHP_SELF'];if (isset($_GET['accesscheck'])) {  $_SESSION['PrevUrl'] = $_GET['accesscheck'];}if (isset($_POST['username'])) {  $loginUsername=$_POST['username'];  $password=$_POST['password'];  $MM_fldUserAuthorization = "";  $MM_redirectLoginSuccess = "loggedin.php";  $MM_redirectLoginFailed = "sorry.php";  $MM_redirecttoReferrer = false;  mysql_select_db($database_conn_comm, $conn_comm);    $LoginRS__query=sprintf("SELECT username, password FROM tbluser WHERE username=%s AND password=%s",	GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));      $LoginRS = mysql_query($LoginRS__query, $conn_comm) or die(mysql_error());  $loginFoundUser = mysql_num_rows($LoginRS);  if ($loginFoundUser) {	 $loginStrGroup = "";		//declare two session variables and assign them	$_SESSION['MM_Username'] = $loginUsername;	$_SESSION['MM_UserGroup'] = $loginStrGroup;		  	if (isset($_SESSION['PrevUrl']) && false) {	  $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];		}	header("Location: " . $MM_redirectLoginSuccess );  }  else {	header("Location: ". $MM_redirectLoginFailed );  }}?><?php session_start();?><!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=utf-8" /><title>Communicate - the best in mobile communications</title><link rel="stylesheet" type="text/css" href="_css/main.css" /><link rel="stylesheet" type="text/css" href="_css/style.css" />	<script src="jquery-1.2.1.min.js" type="text/javascript"></script>	<script src="menu.js" type="text/javascript"></script><!--[if IE]><style type="text/css"> /* place css fixes for all versions of IE in this conditional comment */.thrColElsHdr #sidebar1, .thrColElsHdr #sidebar2 { padding-top: 30px; }.thrColElsHdr #mainContent { zoom: 1; padding-top: 15px; }/* the above proprietary zoom property gives IE the hasLayout it needs to avoid several bugs */</style><![endif]--></head><body class="thrColElsHdr"><div id="container">  <div id="header">   <div id="search">   <input name="search" type="text" id="search" value="<?php echo $row_Search_all['']; ?>" />   </div>     <!-- end #header -->  </div>      <div id="sidebar1"><ul id="menu">						<li><a href="http://www.himeshs.co.uk/communicate/index.php">Home</a></li>									 														<li>							<a href="#">Manufacturer</a>							<ul> 							  <li><a href="http://www.himeshs.co.uk/communicate/allmanufacturer.php">All</a></li> 							<li><a href="http://www.himeshs.co.uk/communicate/se.php">Sony Ericsson</a></li> 							<li><a href="http://www.himeshs.co.uk/communicate/apple.php">Apple</a></li> 							<li><a href="http://www.himeshs.co.uk/communicate/nokia.php">Nokia</a></li> 							<li><a href="http://www.himeshs.co.uk/communicate/samsung.php">Samsung</a></li> 							</ul> 						</li>													 <li>							<a href="#">Type</a>								<ul> 							<li><a href="http://www.himeshs.co.uk/communicate/alltype.php">All</a></li> 							<li><a href="http://www.himeshs.co.uk/communicate/slide.php">Slide</a></li> 							<li><a href="http://www.himeshs.co.uk/communicate/candy.php">Candy Bar</a></li> 							<li><a href="http://www.himeshs.co.uk/communicate/flip.php">Flip</a></li>					  							</ul> 	  </li>																  <li>							<a href="#">Features</a>							<ul> 							<li><a href="http://www.himeshs.co.uk/communicate/camera.php">Camera</a></li> 							<li><a href="http://www.himeshs.co.uk/communicate/music.php">Music</a></li> 							<li><a href="http://www.himeshs.co.uk/communicate/internet.php">Internet</a></li>												  							</ul> 						</li>									<li><a href="http://www.himeshs.co.uk/communicate/aboutus.php">About us</a></li>							<li><a href="http://www.himeshs.co.uk/communicate/contact.php">Contact us</a></li>	</ul>  <!-- end #sidebar1 -->  </div>      <div id="sidebar2">    <?phpif(isset($session)){  // Member is logged in so we have to display welcome message with userid and one logout linkecho <<<END_OF_HTML $_SESSION['MM_Username']  do { <table border="0">	<tr>	  <td>manufacturer</td>	   <td><?php echo echo $row_cart['manufacturer']; </td>	  </tr>	 	  <tr>	   	<td>modelnumber</td>		<td> echo $row_cart['modelnumber']; </td>		</tr>	  <tr>		<td>quantity</td>		<td> echo $row_cart['quantity']; </td>	  </tr>	  <tr>		 <td>price</td>		 <td> echo echo $row_cart['price']; </td>	  </tr>	   } while ($row_cart = mysql_fetch_assoc($cart));   </table>  END_OF_HTML;} else {  // Member has not logged in so we can display the login form allowing member to login with user id and passwordecho <<<END_OF_HTML	  <form id="form1" name="form1" method="POST" action="{$loginFormAction}">			 <input type="text" name="username" id="username" /><br />	  Password<br />	<input type="password" name="password" id="password" /> <br /><input name="Submit" type="submit" value="Submit" /></form>?>  <!-- end #sidebar2 --></div>      <div id="mainContent">	<h1> Main Content </h1>	<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Praesent aliquam,  justo convallis luctus rutrum, erat nulla fermentum diam, at nonummy quam  ante ac quam. Maecenas urna purus, fermentum id, molestie in, commodo  porttitor, felis. Nam blandit quam ut lacus. </p>	<p>Quisque ornare risus quis  ligula. Phasellus tristique purus a augue condimentum adipiscing. Aenean  sagittis. Etiam leo pede, rhoncus venenatis, tristique in, vulputate at,  odio. Donec et ipsum et sapien vehicula nonummy. Suspendisse potenti. Fusce  varius urna id quam. Sed neque mi, varius eget, tincidunt nec, suscipit id,  libero. </p>	<h2>H2 level heading </h2>	<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Praesent aliquam,  justo convallis luctus rutrum, erat nulla fermentum diam, at nonummy quam  ante ac quam. Maecenas urna purus, fermentum id, molestie in, commodo  porttitor, felis. Nam blandit quam ut lacus. Quisque ornare risus quis  ligula. Phasellus tristique purus a augue condimentum adipiscing. Aenean  sagittis. Etiam leo pede, rhoncus venenatis, tristique in, vulputate at, odio.</p>	<!-- end #mainContent -->  </div>		<!-- This clearing element should immediately follow the #mainContent div in order to force the #container div to contain all child floats --><br class="clearfloat" />   <div id="footer">	<p>Footer</p>  <!-- end #footer --></div><!-- end #container --></div></body></html><?phpmysql_free_result($Search_all);mysql_free_result($cart);?>

Link to comment
Share on other sites

You have PHP code mixed in with the string, like your do loop. The heredoc syntax just defines a string, you don't put executable code into it. You would put the echo statement with the heredoc inside of the do loop, not the other way around. If you want to substitute a variable in the heredoc you just surround it with the curly brackets like I showed:

echo <<<END_OF_HTML	  <form id="form1" name="form1" method="POST" action="{$loginFormAction}">...

For your second heredoc you're also missing the closing token.

Link to comment
Share on other sites

Hi, I think I have misinterpreted what you have said, I am fairly new to php.I have now altered my code to this and am still getting the same error

Parse error: syntax error, unexpected T_SL in /home/himeshs/public_html/communicate/index.php on line 192

.This is what I have altered my code to.

<?phpif(isset($session)){  // Member is logged in so we have to display welcome message with userid and one logout linkdo { echo <<<END_OF_HTML {$_SESSION['MM_Username']}  <table border="0">	<tr>	  <td>manufacturer</td>	   <td> echo {$row_cart['manufacturer']}; </td>	  </tr>	 	  <tr>	   	<td>modelnumber</td>		<td> echo {$row_cart['modelnumber']}; </td>		</tr>	  <tr>		<td>quantity</td>		<td> echo {$row_cart['quantity']}; </td>	  </tr>	  <tr>		 <td>price</td>		 <td> echo {$row_cart['price'];} </td>	  </tr>	   } while {$row_cart = mysql_fetch_assoc{$cart}};   </table>  END_OF_HTML;} else {  // Member has not logged in so we can display the login form allowing member to login with user id and passwordecho <<<END_OF_HTML	  <form id="form1" name="form1" method="POST" action="{$loginFormAction}">			 <input type="text" name="username" id="username" /><br />	  Password<br />	<input type="password" name="password" id="password" /> <br /><input name="Submit" type="submit" value="Submit" /></form>END_OF_HTML;?>

Link to comment
Share on other sites

When you have this in your heredoc:<td> echo {$row_cart['manufacturer']}; </td>If the manufacturer is set to "bob", then you would see that print this in the HTML:<td> echo bob; </td>instead of this:<td> bob </td>Look at how this is structured though:

if(isset($session)){  // Member is logged in so we have to display welcome message with userid and one logout linkdo { echo <<<END_OF_HTML {$_SESSION['MM_Username']}  <table border="0">	<tr>	  <td>manufacturer</td>	   <td> echo {$row_cart['manufacturer']}; </td>	  </tr>	 	  <tr>		   <td>modelnumber</td>		<td> echo {$row_cart['modelnumber']}; </td>		</tr>	  <tr>		<td>quantity</td>		<td> echo {$row_cart['quantity']}; </td>	  </tr>	  <tr>		 <td>price</td>		 <td> echo {$row_cart['price'];} </td>	  </tr>	   } while {$row_cart = mysql_fetch_assoc{$cart}};   </table>  END_OF_HTML;}

You've got the start of the do loop, then the start of the heredoc, then it goes through some stuff and then you have the end of the do loop inside the heredoc, or the end of the heredoc outside of the do loop. Since the heredoc starts inside the do loop, it also needs to end inside the do loop, it can't start inside the loop and end outside the loop. You need to move the ending while statement outside of the heredoc.The parse error seems to be indicating something else, but I think that's the problem.

Link to comment
Share on other sites

Hi againI have changed my code to the following and am still getting the same error

Parse error: syntax error, unexpected T_SL in /home/himeshs/public_html/communicate/index.php on line 192

  <?phpif(isset($session)){  // Member is logged in so we have to display welcome message with userid and one logout linkdo { echo <<<END_OF_HTML {$_SESSION['MM_Username']}  <table border="0">	<tr>	  <td>manufacturer</td>	   <td> {$row_cart['manufacturer']}; </td>	  </tr>	 	  <tr>	   	<td>modelnumber</td>		<td>  {$row_cart['modelnumber']}; </td>		</tr>	  <tr>		<td>quantity</td>		<td>  {$row_cart['quantity']}; </td>	  </tr>	  <tr>		 <td>price</td>		 <td> {$row_cart['price'];} </td>	  </tr>	     </table>  END_OF_HTML;} while ($row_cart = mysql_fetch_assoc($cart)); } else {  // Member has not logged in so we can display the login form allowing member to login with user id and passwordecho <<<END_OF_HTML	  <form id="form1" name="form1" method="POST" action="{$loginFormAction}">			 <input type="text" name="username" id="username" /><br />	  Password<br />	<input type="password" name="password" id="password" /> <br /><input name="Submit" type="submit" value="Submit" /></form>END_OF_HTML;?>

Link to comment
Share on other sites

It sees the << token in the <<< and thinks you're trying to do something else. Maybe put it in a variable and then print the variable:

if(isset($session)){  // Member is logged in so we have to display welcome message with userid and one logout linkdo { $html = <<<END_OF_HTML {$_SESSION['MM_Username']}  <table border="0">	<tr>	  <td>manufacturer</td>	   <td> {$row_cart['manufacturer']}; </td>	  </tr>	 	  <tr>		   <td>modelnumber</td>		<td>  {$row_cart['modelnumber']}; </td>		</tr>	  <tr>		<td>quantity</td>		<td>  {$row_cart['quantity']}; </td>	  </tr>	  <tr>		 <td>price</td>		 <td> {$row_cart['price'];} </td>	  </tr>	     </table>  END_OF_HTML;  echo $html;} while ($row_cart = mysql_fetch_assoc($cart)); }

Link to comment
Share on other sites

Turns out the problem was a space after the <<<END_OF_HTML :) Now there are no errors apart from the if statement is not recognising that the user if logged in. However it is possible to log in and the username will appear on the next page to prove that it is logged in. The website that it is currently hosted on is here. The loggedin.php has a line of code that displays the user that is logged in. The username is himesh and the password is password.Do you have any more suggestions that could make this happen? Thanks for your help so far, it has been appreciated!

<?php//initialize the sessionif(!isset($_SESSION['MM_Username'])){// session not logged in so display form}else{// session logged }?><?php require_once('Connections/conn_comm.php'); ?><?phpif (!function_exists("GetSQLValueString")) {function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") {  if (PHP_VERSION < 6) {	$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;  }  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);  switch ($theType) {	case "text":	  $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";	  break;		case "long":	case "int":	  $theValue = ($theValue != "") ? intval($theValue) : "NULL";	  break;	case "double":	  $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";	  break;	case "date":	  $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";	  break;	case "defined":	  $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;	  break;  }  return $theValue;}}mysql_select_db($database_conn_comm, $conn_comm);$query_Search_all = "SELECT producttype, manufacturer, modelnumber, price, quantity, image FROM tblproduct ORDER BY manufacturer ASC";$Search_all = mysql_query($query_Search_all, $conn_comm) or die(mysql_error());$row_Search_all = mysql_fetch_assoc($Search_all);$totalRows_Search_all = mysql_num_rows($Search_all);$maxRows_cart = 1;$pageNum_cart = 0;if (isset($_GET['pageNum_cart'])) {  $pageNum_cart = $_GET['pageNum_cart'];}$startRow_cart = $pageNum_cart * $maxRows_cart;$colname_cart = "-1";if (isset($_GET['MM_Username'])) {  $colname_cart = $_GET['MM_Username'];}mysql_select_db($database_conn_comm, $conn_comm);$query_cart = sprintf("SELECT * FROM tblcart WHERE username = %s", GetSQLValueString($colname_cart, "text"));$query_limit_cart = sprintf("%s LIMIT %d, %d", $query_cart, $startRow_cart, $maxRows_cart);$cart = mysql_query($query_limit_cart, $conn_comm) or die(mysql_error());$row_cart = mysql_fetch_assoc($cart);if (isset($_GET['totalRows_cart'])) {  $totalRows_cart = $_GET['totalRows_cart'];} else {  $all_cart = mysql_query($query_cart);  $totalRows_cart = mysql_num_rows($all_cart);}$totalPages_cart = ceil($totalRows_cart/$maxRows_cart)-1;?><?php// *** Validate request to login to this site.if (!isset($_SESSION)) {  session_start();}$loginFormAction = $_SERVER['PHP_SELF'];if (isset($_GET['accesscheck'])) {  $_SESSION['PrevUrl'] = $_GET['accesscheck'];}if (isset($_POST['username'])) {  $loginUsername=$_POST['username'];  $password=$_POST['password'];  $MM_fldUserAuthorization = "";  $MM_redirectLoginSuccess = "loggedin.php";  $MM_redirectLoginFailed = "sorry.php";  $MM_redirecttoReferrer = false;  mysql_select_db($database_conn_comm, $conn_comm);    $LoginRS__query=sprintf("SELECT username, password FROM tbluser WHERE username=%s AND password=%s",	GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));      $LoginRS = mysql_query($LoginRS__query, $conn_comm) or die(mysql_error());  $loginFoundUser = mysql_num_rows($LoginRS);  if ($loginFoundUser) {	 $loginStrGroup = "";		//declare two session variables and assign them	$_SESSION['MM_Username'] = $loginUsername;	$_SESSION['MM_UserGroup'] = $loginStrGroup;		  	if (isset($_SESSION['PrevUrl']) && false) {	  $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];		}	header("Location: " . $MM_redirectLoginSuccess );  }  else {	header("Location: ". $MM_redirectLoginFailed );  }}?><?php session_start();?><!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=utf-8" /><title>Communicate - the best in mobile communications</title><link rel="stylesheet" type="text/css" href="_css/main.css" /><link rel="stylesheet" type="text/css" href="_css/style.css" />	<script src="jquery-1.2.1.min.js" type="text/javascript"></script>	<script src="menu.js" type="text/javascript"></script><!--[if IE]><style type="text/css"> /* place css fixes for all versions of IE in this conditional comment */.thrColElsHdr #sidebar1, .thrColElsHdr #sidebar2 { padding-top: 30px; }.thrColElsHdr #mainContent { zoom: 1; padding-top: 15px; }/* the above proprietary zoom property gives IE the hasLayout it needs to avoid several bugs */</style><![endif]--></head><body class="thrColElsHdr"><div id="container">  <div id="header">   <div id="search">   <input name="search" type="text" id="search" value="<?php echo $row_Search_all['']; ?>" />   </div>     <!-- end #header -->  </div>      <div id="sidebar1"><ul id="menu">						<li><a href="http://www.himeshs.co.uk/communicate/index.php">Home</a></li>									 														<li>							<a href="#">Manufacturer</a>							<ul> 							  <li><a href="http://www.himeshs.co.uk/communicate/allmanufacturer.php">All</a></li> 							<li><a href="http://www.himeshs.co.uk/communicate/se.php">Sony Ericsson</a></li> 							<li><a href="http://www.himeshs.co.uk/communicate/apple.php">Apple</a></li> 							<li><a href="http://www.himeshs.co.uk/communicate/nokia.php">Nokia</a></li> 							<li><a href="http://www.himeshs.co.uk/communicate/samsung.php">Samsung</a></li> 							</ul> 						</li>													 <li>							<a href="#">Type</a>								<ul> 							<li><a href="http://www.himeshs.co.uk/communicate/alltype.php">All</a></li> 							<li><a href="http://www.himeshs.co.uk/communicate/slide.php">Slide</a></li> 							<li><a href="http://www.himeshs.co.uk/communicate/candy.php">Candy Bar</a></li> 							<li><a href="http://www.himeshs.co.uk/communicate/flip.php">Flip</a></li>					  							</ul> 	  </li>																  <li>							<a href="#">Features</a>							<ul> 							<li><a href="http://www.himeshs.co.uk/communicate/camera.php">Camera</a></li> 							<li><a href="http://www.himeshs.co.uk/communicate/music.php">Music</a></li> 							<li><a href="http://www.himeshs.co.uk/communicate/internet.php">Internet</a></li>												  							</ul> 						</li>									<li><a href="http://www.himeshs.co.uk/communicate/aboutus.php">About us</a></li>							<li><a href="http://www.himeshs.co.uk/communicate/contact.php">Contact us</a></li>	</ul>  <!-- end #sidebar1 -->  </div>      <div id="sidebar2">    <?phpif(isset($session)){  // Member is logged in so we have to display welcome message with userid and one logout linkdo { $html = <<<END_OF_HTML{$_SESSION['MM_Username']}  <table border="0">	<tr>	  <td>manufacturer</td>	   <td> {$row_cart['manufacturer']}; </td>	  </tr>	 	  <tr>	   	<td>modelnumber</td>		<td>  {$row_cart['modelnumber']}; </td>		</tr>	  <tr>		<td>quantity</td>		<td>  {$row_cart['quantity']}; </td>	  </tr>	  <tr>		 <td>price</td>		 <td> {$row_cart['price']}; </td>	  </tr>	     </table>  END_OF_HTML;	echo $html;} while ($row_cart = mysql_fetch_assoc($cart)); } else {  // Member has not logged in so we can display the login form allowing member to login with user id and passwordecho <<<END_OF_HTML	  <form id="form1" name="form1" method="POST" action="{$loginFormAction}">			 <input type="text" name="username" id="username" /><br />	  Password<br />	<input type="password" name="password" id="password" /> <br /><input name="Submit" type="submit" value="Submit" /></form>END_OF_HTML;}?>  <!-- end #sidebar2 --></div>      <div id="mainContent">	<h1> Main Content </h1>	<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Praesent aliquam,  justo convallis luctus rutrum, erat nulla fermentum diam, at nonummy quam  ante ac quam. Maecenas urna purus, fermentum id, molestie in, commodo  porttitor, felis. Nam blandit quam ut lacus. </p>	<p>Quisque ornare risus quis  ligula. Phasellus tristique purus a augue condimentum adipiscing. Aenean  sagittis. Etiam leo pede, rhoncus venenatis, tristique in, vulputate at,  odio. Donec et ipsum et sapien vehicula nonummy. Suspendisse potenti. Fusce  varius urna id quam. Sed neque mi, varius eget, tincidunt nec, suscipit id,  libero. </p>	<h2>H2 level heading </h2>	<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Praesent aliquam,  justo convallis luctus rutrum, erat nulla fermentum diam, at nonummy quam  ante ac quam. Maecenas urna purus, fermentum id, molestie in, commodo  porttitor, felis. Nam blandit quam ut lacus. Quisque ornare risus quis  ligula. Phasellus tristique purus a augue condimentum adipiscing. Aenean  sagittis. Etiam leo pede, rhoncus venenatis, tristique in, vulputate at, odio.</p>	<!-- end #mainContent -->  </div>		<!-- This clearing element should immediately follow the #mainContent div in order to force the #container div to contain all child floats --><br class="clearfloat" />   <div id="footer">	<p>Footer</p>  <!-- end #footer --></div><!-- end #container --></div></body></html><?phpmysql_free_result($Search_all);mysql_free_result($cart);?>

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...