SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Thread: syntax error

  1. #1
    SitePoint Addict
    Join Date
    Oct 2010
    Posts
    323
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    syntax error

    it says on line 32
    PHP Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
      <head>
        <title>Reacheasy - Foremost website for easy reach of things globally</title>
        <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
    <link href="reasy.css" rel="stylesheet" type="text/css"/>  
    </head>
      <body>
    <div id="outer">
    <div id="page">
    <div id="header">

    <h1>Reacheasy <span style="font-size:small;"><?php echo $_SESSION['username'];?></span></h1> 
      <ul id="nav">
        <li class="current"><a href="index.php">Home</a></li>
         <li><a href="women.php">Women</a></li>
         <li><a href="men.php">Men</a></li>
         <li><a href="children.php">Children</a></li>
         <li><a href="homeandappliances.php">Home&amp;Appliances</a></li>
         <li><a href="visionandsound.php">Vision&amp;Sounds</a></li>
          <li><a href="motoring.php">Motoring</a></li>
          <li><a href="homemore.php">More</a></li>
          <li><a href="homecontact.php">Contact us</a></li>
      </ul>
    </div> <!--end of navigation div -->
    </div>
    <div id="navigation">
     //user and non user nav
    <?php
    [COLOR="#00FF00"]if($_SESSION['username'])[/COLOR]

    echo 
    "$_SESSION['username']";<br>
    echo 
    "<h2>Your Account</h2>";<br>
    echo 
    "<a href='relogout.php'>Log out</a>";
    }else{
      <
    div>
        <
    form action='relogin.php' method='POST' class='rl'>
            <
    fieldset>
            <
    legend>Login</legend>
            <
    div>
            <
    label for='username' class='fixedwidth'>Username</label>
            <
    input type='text' name='username' id='username'/>
            </
    div>
            <
    div>
            <
    label for='password' class='fixedwidth'>Password</label>
            <
    input type='password' name='password' id='password'/>
            </
    div>
            <
    div class='buttonarea'>
            <
    input type='submit' value='Log in'>
            </
    div>
        </
    form>
            <
    p>
            <
    a href='reregister.php'>Register </a>
            </
    p>
            </
    div>
            </
    fieldset>
    }
    ?>

    <div id="advert">
    <ul>
    <li><iframe src="http://rcm-uk.amazon.co.uk/e/cm?t=r0ab-21&o=2&p=20&l=ur1&category=generic&banner=0YCR1B12KQC9EA34FF02&f=ifr" width="120" height="90" scrolling="no" border="0" marginwidth="0" style="border:none;" frameborder="0"></iframe></li>
     <li><iframe src="http://rcm-uk.amazon.co.uk/e/cm?t=r0ab-21&o=2&p=11&l=ur1&category=endless&banner=1BXHM01F8MNJJGXPV2R2&m=endless&f=ifr" width="150" height="600" scrolling="no" border="0" marginwidth="0" style="border:none;" frameborder="0"></iframe></li>
    </ul>
    </div>
    </div> <!--end of navigation div -->

  2. #2
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,508
    Mentioned
    163 Post(s)
    Tagged
    4 Thread(s)
    What does it say on line 32?
    And which line is line 32?

  3. #3
    SitePoint Addict
    Join Date
    Oct 2010
    Posts
    323
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    it says
    Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/reachea2/public_html/include/header.php on line 32,
    line 32 = echo "$_SESSION['username']";<br>
    and as advised in the article on the php common errors, i have checked the line above it but couldnt see if i miss anything there

  4. #4
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,508
    Mentioned
    163 Post(s)
    Tagged
    4 Thread(s)
    PHP Code:
    <?php
    if($_SESSION['username'])

      echo 
    "$_SESSION['username']";<br>
      echo 
    "<h2>Your Account</h2>";<br>
      echo 
    "<a href='relogout.php'>Log out</a>";
    }else{
      <
    div
        <
    form action='relogin.php' method='POST' class='rl'>
            <
    fieldset>
            <
    legend>Login</legend>
            <
    div>
            <
    label for='username' class='fixedwidth'>Username</label>
            <
    input type='text' name='username' id='username'/>
            </
    div>
            <
    div>
            <
    label for='password' class='fixedwidth'>Password</label>
            <
    input type='password' name='password' id='password'/>
            </
    div>
            <
    div class='buttonarea'>
            <
    input type='submit' value='Log in'>
            </
    div>
        </
    form>
            <
    p>
            <
    a href='reregister.php'>Register </a>
            </
    p>
            </
    div>
            </
    fieldset>
    }
    ?>

    <div id="advert">
    You are mixing php code and html code here. If you want to echo html code, then you'll have to put it all between quotes. And if you want to switch between php and html (for example in the 'else' part) then you'll have to close the php script part with the ?> tag:
    PHP Code:
    <?php
    if($_SESSION['username'])

      echo 
    "$_SESSION['username'] <br>";
      echo 
    "<h2>Your Account</h2><br>";
      echo 
    "<a href='relogout.php'>Log out</a>";
    }else{
    ?>
      <div> 
        <form action='relogin.php' method='POST' class='rl'>
            <fieldset>
            <legend>Login</legend>
            <div>
            <label for='username' class='fixedwidth'>Username</label>
            <input type='text' name='username' id='username'/>
            </div>
            <div>
            <label for='password' class='fixedwidth'>Password</label>
            <input type='password' name='password' id='password'/>
            </div>
            <div class='buttonarea'>
            <input type='submit' value='Log in'>
            </div>
        </form>
            <p>
            <a href='reregister.php'>Register </a>
            </p>
            </div>
            </fieldset>
    <?php
    }
    ?>

    <div id="advert">

  5. #5
    SitePoint Addict
    Join Date
    Oct 2010
    Posts
    323
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    i have corrected as advised, but it still comes up with the same error

  6. #6
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,508
    Mentioned
    163 Post(s)
    Tagged
    4 Thread(s)
    Try this:
    PHP Code:
    echo "{$_SESSION['username']}<br>"


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •