Jump to content

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE .. .. ..


Irresistable

Recommended Posts

I receive this error..

 

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/jeanie/public_html/member.php on line 7

 

Here is the script

<?php
session_start();
if($_SESSION['s_logged_n'] == 'true'){
include 'process.php';
include 'config.php';

$query = mysql_query("SELECT Admin FROM Users WHERE Username = '$_SESSION['s_logged_n']' LIMIT 1") or die(mysql_error());
$admini = mysql_fetch_array($query);

$admin = $admini['Admin'];
?>
<!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" />
<meta http-equiv="Content-Language" content="en-UK" >
<meta name="description" content="Developers Community is a Community for developers to discuss and provide support for development. We have forums that allow users to participate in polls, giving the support to other users, or you may perhaps share your knowledge so that others can learn from you. Additionally, we have tutorials which cover a wide aspect of all scripts, from HTML to PHP to C++" >
<meta name="keywords" content="script help, script forums, script tutorials, script tutorial, script snippets, script, help, resources, snippets, tutorials, web development, programming, development, community, developers community, php, c++, c#, MySQL, database, databases, VB, Java, Javascript, support" >
<title>Developers Community - Members Area</title>
<link href="styles/twoColLiqRtHdr.css" rel="stylesheet" type="text/css" />
<link href="styles/style.css" rel="stylesheet" type="text/css" />
<link rel="shortcut icon" href="images/favicon.ico">
<link rel="icon" href="images/favicon.ico">
<!--[if IE]>
<style type="text/css"> 
/* place css fixes for all versions of IE in this conditional comment */
.twoColLiqRtHdr #sidebar1 { padding-top: 30px; }
.twoColLiqRtHdr #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="twoColLiqRtHdr">

<div id="container">
  <div id="header">
    <div class="twoColLiqRtHdr" id="logreg">  
<?php if(isset($_SESSION['s_logged_n']))
{
echo('<strong>'.ucwords($_SESSION['s_username']).' - <a href="member.php">My Account</a> - <a href="logout.php">Logout</a></strong>');
} else { ?>
<strong><a href="login.php">login</a> // <a href="register.php">register</a></strong>
<?php } ?>
</div>
  <h1> </h1></div>
  <div>		
  <ul id="navigator">
		<li><a href="/">Home</a></li>
		<li><a href="tutorials.php">Tutorials</a></li>
		<li><a href="jobvac.php">Job Vacancies</a></li>
            <li><a href="contactus.php">Contact Us</a></li>
		<li><a href="forums">Forums</a></li>
<div id="time" style="font-size:12px";>
<script type="text/javascript">
var d=new Date()
var weekday=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
var monthname=new Array("January","February","March","April","May","June","July","August","September","October","November","December")
document.write(weekday[d.getDay()] + " ")
document.write(d.getDate() + " ")
document.write(monthname[d.getMonth()])
</script>
</div>
    </ul>
  <div class="twoColLiqRtHdr" id="topbar"> </div>
  </div>
  <div id="sidebar">
    <div id="updates">
      <h3 style="margin:0px;">Recent News</h3><br />
      <?php include("Updates/updatediv.php"); ?>
      <br />
</div>
<div class="twoColLiqRtHdr" id="advertisement">
  <h2><br />
    <br />
    <br />
    Want your advert here? Contact us.<br />
    <br />
    <br />
    <br />
  </h2>
</div>
  </div>
  <div id="mainContent">

    <div class="twoColLiqRtHdr" id="introduction">
      <h1>Members Area</h1>
      <p>Welcome to the members area, this is where you can change most of your registered details.</p>
      <p>If there is any problems with the Members Control Panel, contact us about the problem, we'll fix it as soon as possible.<br />
      </p>
    </div>
<div id="memarea">
    <div id="subcontainer">
      <? include 'menus.php' ?>
    </div>
    <div id="spacer"> </div>
<div id="memmain">

<center>
<?php

switch($_GET['change']){

case 'password':

	echo '<form action="'.$_SERVER['PHP_SELF'].'" method="post">
	<p>Current password:<br>
	<input name="current" type="password" class="textBox"></p>
	<p>New password:<br>
	<input name="new" type="password" class="textBox"></p>
	<p>Confirm new password:<br>
	<input name="confirm" type="password" class="textBox"></p>
	<p><input type="submit" value="Change Password" name="changepassword"></p>
	</form>
	';

	break;

case 'email':

	echo '<p>
	WARNING! - By changing your email address you will have to re-validate. Make sure you email address is 100% correct.</p>
	<form action="'.$_SERVER['PHP_SELF'].'" method="post">
	<p>Current email:<br>
	<input name="current" type="text" class="textBox"></p>
	<p>New email:<br>
	<input name="new" type="text" class="textBox"></p>
	<p>Confirm new email:<br>
	<input name="confirm" type="text" class="textBox"></p>
	<p><input type="submit" value="Change Email" name="changeemail"></p>
	</form>
	';

	break;

case 'account':

	echo '<p>
	WARNING - By closing your account, you will not be able to login again under this account. Press the button below to confirm you wish to close your account</p>
	<form action="'.$_SERVER['PHP_SELF'].'" method="post">
	<p><input type="submit" value="Close Account" name="closeaccount"></p>
	</form>
	';

                break;

if($admin == 1)
{
case 'admin':

    echo '<p>
	WARNING - This is the Admin Center, take extra care when modifying</p>';

	break;
}

default:

	echo '<p>This is your Control Panel. Here you will be able to edit details of your registered account.</p>';

}

?></center>
</div>
</div>
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
  </p></div>
  <br class="clearfloat" />
  <div id="footer">
    <p>Developers-Community © 2009 - <a href="contactus.php">Contact</a></p>
  <!-- end #footer --></div>
<!-- end #container --> </div>
</body>
</html>
<?php
} else {
/*echo $_SESSION['s_logged_n'].'b';
echo $_SESSION['s_username'].'c';
echo $_SESSION['s_name'].'d';*/
header("Location: login.php");
}
?>

 

This gets Admin value from the database, and on Menus.php it checks

if $Admin == 1

{ *brings the admin link and calls "case admin" }

 

I'm not sure why I recieve that error though...

Could you help?

Link to comment
Share on other sites

I would start by breaking down the problem line since I find that double quotes can cause unnecessary stress.

 

Change

$query = mysql_query("SELECT Admin FROM Users WHERE Username = '$_SESSION['s_logged_n']' LIMIT 1") or die(mysql_error());

 

to

 

$s_logged_n = $_SESSION['s_logged_n']';

$query = mysql_query("SELECT Admin FROM Users WHERE Username = '$s_logged_n' LIMIT 1") or die(mysql_error());

 

 

Link to comment
Share on other sites

$query = mysql_query(sprintf("SELECT Admin FROM Users WHERE Username = '%s' LIMIT 1", mysql_real_escape_string($_SESSION['s_logged_n']))) or die(mysql_error());

 

should fix it.  Essentially, If you look at $_SESSION['s_logged_n'], you're closing the previous string with the apostrophe.  You may want to look at different ways to concatenate strings together.  For MySQL queries, you should perhaps look at preparing your statements (required mysqli extension).  Otherwise you could do as I did above and use sprintf or vsprintf.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.