Unexpected T_STRING error

Discussion in 'PHP' started by chosenlight, Feb 2, 2011.

  1. #1
    hi everyone. I've programmed a lot in coldfusion, but i am pretty new to php. Can anyone look at the following code tell me what the heck i am doing wrong.

    <?php
    $FirstName = $_POST['FirstName'];
    $LastName = $_POST['LastName'];
    $Email = $_POST['Email'];
    mysql_connect ("johnxxx","ejohnxxx,"johnxxx") or die (mysql_error())

    mysql_select_db("johnxxx");

    $query="INSERT INTO AllUsers (FirstName, LastName, Email)VALUES ('".$FirstName."','".$LastName."','".$Email."')";

    mysql_query($query) or die ('Error updating database');

    echo "Database Updated With: " .$FirstName. " ".$LastName." ".$Email." ;



    ?>

    The database conection is correct - I know this 'cause i use the same line to create a table in that data base which i confirmed in the phpadmin panal
     
    Last edited: Feb 2, 2011
    chosenlight, Feb 2, 2011 IP
  2. moads

    moads Member

    Messages:
    115
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    28
    #2
    mysql_connect ("johnxxx","ejohnxxx,"johnxxx") or die (mysql_error())

    you're missing a ";"
     
    moads, Feb 2, 2011 IP
  3. G3n3s!s

    G3n3s!s Active Member

    Messages:
    325
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    80
    #3
    I added & repaired your code. As moads told, you're missing ;

    <?php
    $FirstName = mysql_real_escape_string($_POST['FirstName']);
    $LastName = mysql_real_escape_string($_POST['LastName']);
    $Email =  mysql_real_escape_string($_POST['Email']);
    mysql_connect ("johnxxx","ejohnxxx,"johnxxx") or die (mysql_error());
    mysql_select_db("johnxxx");
    
    $query="INSERT INTO AllUsers (FirstName, LastName, Email)VALUES ('".$FirstName."','".$LastName."','".$Email."')";
    mysql_query($query) or die ('Error updating database');
    
    echo "Database Updated With: " .$FirstName. " ".$LastName." ".$Email." ;
    
    PHP:
    (?> on the end isn't neccesary)
     
    G3n3s!s, Feb 2, 2011 IP