Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE

Discussion in 'PHP' started by mcf1992, Sep 17, 2011.

  1. #1
    Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in path/account.php on line 31

    <?php session_start(); ?>  <html xmlns="http://www.w3.org/1999/xhtml">  <head>  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />  <title>Account Dashboard</title>  </head>  <body>  <?php  include('dbsettings.php');  
    $con = mysql_connect("$host","$user","$password");  if (!$con)    {    die('Could not connect: ' . mysql_error());    }  
    mysql_select_db("$db_name", $con);  $username= $_SESSION['username']; // Editted 
    $sql="SELECT * FROM `user` WHERE `username`='{$username}'";  
    $result = mysql_query("$sql");  
    while($row = mysql_fetch_array($result))    {  echo "Welcome, ";   echo $row['firstname'] . " " . $row['lastname'];  echo "Account Profile: "; echo "<BR />"; echo "Account"; echo "$row['account']"; echo "Billing Address"; echo "$row['address']";      }    
    mysql_close($con);  ?>  <a href="logout.php"> Log Out </a>  </body>  </html>
    PHP:

     
    mcf1992, Sep 17, 2011 IP
  2. Oli3L

    Oli3L Active Member

    Messages:
    207
    Likes Received:
    3
    Best Answers:
    1
    Trophy Points:
    70
    #2
    which of the lines here is line 31?
     
    Oli3L, Sep 18, 2011 IP
  3. dplover147

    dplover147 Member

    Messages:
    120
    Likes Received:
    0
    Best Answers:
    1
    Trophy Points:
    36
    #3
    Here is the error free code.

    
    <?php session_start(); ?>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Account Dashboard</title>
    </head>
    <body>
    <?php 
    include('dbsettings.php');  
    $con = mysql_connect($host,$user,$password);
    if (!$con){
        die('Could not connect: ' . mysql_error());
    }  
    mysql_select_db($db_name, $con);
    $username= $_SESSION['username']; // Editted 
    $sql="SELECT * FROM user WHERE username='{$username}'";
    $result = mysql_query($sql);  
    while($row = mysql_fetch_array($result))
    {
        echo "Welcome, ";
        echo $row['firstname'] . " " . $row['lastname'];
        echo "Account Profile: ";
        echo "<BR />"; 
        echo "Account"; 
        echo $row['account']; 
        echo "Billing Address"; 
        echo $row['address'];
    }    
    mysql_close($con);
    ?>
     <a href="logout.php"> Log Out </a>
    </body>
    </html>
    
    PHP:
     
    Last edited: Sep 18, 2011
    dplover147, Sep 18, 2011 IP
  4. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,908
    Likes Received:
    37
    Best Answers:
    51
    Trophy Points:
    125
    #4
    Which line is line 31? Since the interpreter ignores line endings, you could have broken the code up any number of ways. (The way I break it, there are only 30 lines.)
     
    Rukbat, Sep 18, 2011 IP