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? 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()); 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 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
Archived
This topic is now archived and is closed to further replies.