Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3861
  • Last Modified:

mysql insert statement with data in certain fields


Ok, now I have:

mysql_query("INSERT INTO user VALUES ('$cust_data[0]','$cust_data[1]','$cust_data[2]','$cust_data[3]','$cust_data[4]','$cust_data[5]')");

Which inserts data into a table with six fields.

However....  I have more than six fields in this table, so I get an error.  Each month the table will grow by one field.

How can I change this so that the data will go into the first six fields of the table, and leave the remaining fields (however many there are) empty (data to be added later), without an error?

If needed, the names of the first six fields are: number, brand, account, order date, name, status.

Thanks for any assistance you can provide.  This is the last question for this project, once I have this it will all work!

Chris



0
ChrisAndrews
Asked:
ChrisAndrews
  • 3
1 Solution
 
arjanhCommented:
you can name the columns to put the data in like this:

mysql_query("INSERT INTO user (number, brand, account, order date, name, status) VALUES ('$cust_data[0]','$cust_data[1]','$cust_data[2]','$cust_data[3]','$cust_data[4]','$cust_data[5]')");
0
 
ChrisAndrewsAuthor Commented:

Thank you !

Chris
0
 
HardawayCommented:
Arjanh should have helped you already. I would like to remind you all "additional" fields in the coming future must be nullable field. Otherwise, you would encounter error as non-nullable fields can't contain null values.
0
 
ChrisAndrewsAuthor Commented:

Thank you Arjanh, they are :)

Chris
0
 
ChrisAndrewsAuthor Commented:

oopps, I mean Thank you Hardaway of course -
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now