Parse error: syntax error, unexpected T_LNUMBER, expecting T_VARIABLE or '$'

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

  1. #1
     <!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>Habitual Darkness</title>
    <link href="css/style.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
    <center>
    <div id="wrapper">
        <div id="header"></div>
    
    
    
    
    <?php include("menu.php"); ?>
    
    
    
    
    
    
    
    
        <div id="content">
    
    
    
    
        <div class="newstitle"><p class="margin"><u>Signup</u></p></div>
        <div class="newscontent">
        <p class="margin">
        
    
    
        <div id="form">
    
    
    <?php
    include("dbsettings.php"); ?>
    <?php
    // Connect to server and select database.
    mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
    mysql_select_db("$db_name")or die("cannot select DB");
    
    
    // Get values from form
    
    
    $charName=$_POST['charName'];
    $charRace=$_POST['charRace'];
    $charClass=$_POST['charClass'];
    $charLvl=$_POST['charLvl'];
    $prof1=$_POST['charprofession1'];
    $prof2=$_POST['charprofession2'];
    $email=$_POST['email'];
    $password=$_POST['password'];
    $2pass=$_POST['2password'];
    $md5pass= md5 ('$password');
    
    
    if($password!=$2pass)
    {
    echo "Password fields did not match. Please try again";
    }
    
    
    if($prof1==$prof2)
    {
    echo "You cannot have the same profession twice";
    }
    
    
    
    
    
    
    // Insert data into mysql 
    $sql="INSERT INTO $tbl_name(charName, charRace, charClass, charLvl, charprofession1, charprofession2, email, password)
    VALUES('$charName', '$charRace', '$charClass', '$charLvl', '$prof1', '$prof2', '$email', '$md5pass')";
    
    
    $result=mysql_query($sql) or die(mysql_error());
    
    
    // if successfully insert data into database, displays message "Successful". 
    if($result){
    echo "Successful";
    echo "<BR>";
    echo "Congratulations you are now registered with Habitual Darkness.";
    echo "<BR>";
    echo"You will be redirected to login form.";
    }
    
    
    else {
    echo "There was a problem with the database. We'll fix this as soon as possible.";
    }
    
    
    // close connection 
    mysql_close();
    ?>
    
    
        
    
    
    </div>
    
    
    <br/>
    </p>
    <br/></div>
    
    
    
    
        
    
    
    </div>
       
    
    
    
    
        <div id="footer">Copyright (c) 2011 <a href="index.php">Habitual Darkness</a></div>
    </center>
    <br/>
    </body>
    </html>
    
    Code (markup):

     
    mcf1992, Sep 4, 2011 IP
  2. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,908
    Likes Received:
    37
    Best Answers:
    51
    Trophy Points:
    125
    #2
    The error message should include a line number. If we had that we wouldn't have to parse every character of your code to try to find your error.

    Also, the error could be in the included files, so we wouldn't find it unless we saw the code for the file it occurs in.
     
    Rukbat, Sep 4, 2011 IP
  3. mcf1992

    mcf1992 Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    line 46. --> $2pass=$_POST['2password'];
     
    mcf1992, Sep 4, 2011 IP
  4. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,908
    Likes Received:
    37
    Best Answers:
    51
    Trophy Points:
    125
    #4
    PHP variables can't start with numbers. $2pass isn't legal, change it to $pass2 or something.
     
    Rukbat, Sep 4, 2011 IP