how to fix this bug

Discussion in 'PHP' started by barnes, Apr 24, 2007.

  1. #1
    please help me.i unable to find the following error in code
    Parse error: parse error in c:\easyphp1-8\www\insert.php on line 13
    my column names in mysql(db_user)(person)
    firstname
    lastname
    age

    <html>
    <body>
    <form name=frmname" method="post" action="insert.php" enctype="multipart/form-data">
    <table border="0" wodth=200 height=200 align="center">
    <tr><td>Firstname</td><td><input type="text" name="fname"></td></tr>

    <tr><td>Lastname</td><td><input type="text" name="lname"></td></tr>

    <tr><td>age</td><td><input type="text" name="age"></td></tr>


    <tr colspan="2"><td align="center"><input type="submit" value="submit"></td></tr>
    </table>
    </body>
    </html>

    insert.php
    <?php
    $con=mysql_connect("localhost","root","");
    if(!$con)
    {
    die("connection error:".mysql_error());
    }
    else
    {
    mysql_select_db("db_user",$con);
    $qry="INSERT INTO person(firstname,lastname,age)VALUES('$_POST[fname]','$_POST[lname]','$_POST[age]')
    if(!mysql_query($qry,$con));
    {
    die("connection error:".mysql_error());
    }

    echo "record is added";
    mysql_close($con);
    }
    ?>
     
    barnes, Apr 24, 2007 IP
  2. phd

    phd Active Member

    Messages:
    496
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    60
    #2
    there is no need to have enctype as "multipart/form-data"
    one error at html, you forget double quote at name
    another might be u've forget space in $qry and semicolon(;) too.
    it should be
    Is it useful?
     
    phd, Apr 25, 2007 IP
  3. MMJ

    MMJ Guest

    Messages:
    460
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #3
    $qry="INSERT INTO person (firstname, lastname, age) VALUES ('$_POST[fname]','$_POST[lname]','$_POST[age]')";
    PHP:
    You forgot to close the quote, phd. :)
     
    MMJ, Apr 25, 2007 IP