views:

37

answers:

2

Code not inserting into MySQL Database!?!?

Excerpt Register.php

$register = mysql_query("INSTER INTO users VALUE ('','$firstname','$lastname','$username','$password_db','$dob_db','$gender_db')");
                echo "Success!";

Connect.php

    <?php

    //connect

    $error = "Problem connecting to database. Please try again later.";

    $connect = mysql_connect("localhost","root","") or die($error);
    mysql_select_db("upload") or die($error);

?>

It should all work. I don't get any errors when I use connect.php.

What's going on?

Also;

Notice:  Undefined variable: firstname in /opt/lampp/htdocs/imageupload/register.php on line 121

Please help?!

+3  A: 

The first line should read "INSERT INTO users VALUES", try that to start with.

DrLazer
I cannot believe I missed that! Thank you :)
Hugo
It happens to the best of us ;)
DrLazer
A: 

Never assume your queries will succeed. At bare mininum put an or die(mysql_error()) after each query call. Even if your SQL is completely valid, there's too many other reasons a query could fail to just blindly spit out "success!" while leaving a trail of destruction behind.

Marc B