xwishmasterx Posted April 12, 2011 Share Posted April 12, 2011 I am trying to create a simple form for inserting to a database table. It seems the data from the form are passed through the "insert" script, but nothing is added to the table. My question is: what is required to insert new data to a table? must all fields have a value for the new data to be added? Quote Link to comment https://forums.phpfreaks.com/topic/233534-insert-into-a-few-questions/ Share on other sites More sharing options...
dcro2 Posted April 12, 2011 Share Posted April 12, 2011 If you want to insert a row with only some fields set, use a syntax like this: INSERT INTO table (field1, field2, field3) VALUES ('value1', 'value2', 'value3') Check for errors in your queries by specifying something like this: $result = mysql_query($sql) or die("MySQL Error: ".mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/233534-insert-into-a-few-questions/#findComment-1200809 Share on other sites More sharing options...
xwishmasterx Posted April 12, 2011 Author Share Posted April 12, 2011 PHP can surprise me sometime. I added your line: $result = mysql_query($sql) or die("MySQL Error: ".mysql_error()); And now it works fine thanks Quote Link to comment https://forums.phpfreaks.com/topic/233534-insert-into-a-few-questions/#findComment-1200815 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.