PHP/MySQL Database Error

Discussion in 'macOS' started by shreydesai, Mar 19, 2012.

  1. shreydesai macrumors member

    shreydesai

    Joined:
    Mar 15, 2012
    Location:
    California
    #1
    With Dreamweaver and PHP, I am trying to use an HTML form that I created to add tables to my MySQL database, but it's just not adding! The MySQL Database is called 'login' and the table is called 'users', and here is the code I put into Dreamweaver:

    $query = mysql_query("INSERT INTO users VALUES ('','$name','$username','$enc_password')")

    Any suggestions?
     
  2. ct2k7, Mar 20, 2012
    Last edited: Mar 20, 2012

    ct2k7 macrumors 603

    ct2k7

    Joined:
    Aug 29, 2008
    Location:
    London or Florida
    #2
    Use this syntax, it's clearer:

    INSERT into USERS ('ID','name','username','password') VALUES (NULL,'$name','$username','$enc_password')

    I do hope that you are escaping each string using mysql->real_escape_string.

    I also suggest you use mysqli over mysql.

    maybe you can tell us more if there are any error using:

    $query = mysql_query("INSERT into USERS ('ID','name','username','password') VALUES (NULL,'$name','$username','$enc_password')") or die(mysql_error());

    I have assumed that the first field is an ID field.
     

Share This Page