dongmeiran609914 2011-06-14 18:15
浏览 68

$ query =“INSERT INTO

I'm still getting used to PHP and what it can do. I have designed a register.php page. I have it working, however it is only posting empty fields into the table.

This is the code I am using:

$query = "
    INSERT INTO users (`id`, `fname`, `lname`, `username`, `email`, `password`)
    VALUES ('', '".$fname."','".$lname."','".$username."','".$email."','".$password."')";

The data I post to the database isn't being entered, but blank fields are, so something is happening.

I tried to run:

echo `$query`; 

And this is what I get from the output:

INSERT INTO users (`id`, `fname`, `lname`, `username`, `email`, `password`) VALUES ('', '','','','','')

Any hint, tips or help is on this problem are greatly appreciated.

  • 写回答

4条回答 默认 最新

  • douhuan1901 2011-06-14 18:18
    关注

    When doing an insert and not passing a specific ID, it is best to use NULL instead of leaving empty space with a comma... Infact, I am unsure if that is valid syntax at all

    评论

报告相同问题?