Jump to content

[SOLVED] inserting to mysql database issue


Rogue_Phoenix

Recommended Posts

Sorry if this has been asked before but i had a quick look and couldnt see anything.

When i have been coding on mysql 4 servers i never had this issue, but since i moved to 5 i have found a problem adding data to the database.

Can anyone help.

 

The code im trying to use is as follows:

//------------- Fascia additiion ----------------//

$add_item= "INSERT INTO fascia (fasciaid, carid, partno, type) VALUES ('', '$_POST[carid]', '$_POST[partfas]', '$_POST[fascia]')";

//execute query
mysql_query($add_item,$conn) or die(mysql_error());


//---------- Cellular addition ---------------//

$add_cellular= "INSERT INTO cellular VALUES ('', '$_POST[carid]', '$_POST[sot]', '$_POST[relayed]', '$_POST[direct]', '$_POST[additionals]' )";

// execute query
mysql_query($add_cellular,$conn) or die(mysql_error());

//--------- Aerial Addition ---------------//

$add_aerial= "INSERT INTO aerial VALUES ('', '$_POST[carid]', '$_POST[aerial]', '$_POST[fmmod]' )";

//execute query
mysql_query($add_aerial,$conn) or die(mysql_error());

//--------- Harness Addition -------------//

$add_harness= "INSERT INTO harness VALUES ('', '$_POST[carid]', '$_POST[rca]', '$_POST[canbus]' )";

//execute query
mysql_query($add_harness,$conn) or die(mysql_error());

//--------- Connectivity Addition ---------------//

$add_connectivity= "INSERT INTO connectivity VALUES ('', '$_POST[carid]', '$_POST[cdchanger]', '$_POST[ipod]', '$_POST[mostinterface]' )";

//execute query
mysql_query($add_connectivity,$conn) or die(mysql_error());

//--------- Speaker Addition ---------------//

$add_speaker= "INSERT INTO speakers VALUES ('', '$_POST[carid]', '$_POST[dualdash]', '$_POST[kickpanel]', '$_POST[frontdoor]', '$_POST[reardoor]', '$_POST[rearseatside]', '$_POST[reardeck]', '$_POST[rearside]', '$_POST[rearhatch]', '$_POST[other]' )";

//execute query
mysql_query($add_speaker,$conn) or die(mysql_error());

 

I receive the following error from the database

Incorrect integer value: '' for column 'fasciaid' at row 1

Im sure that if i solve the problem on the first one it wil replicate itself on the later queries.

Any help would be appreciated.

Link to comment
Share on other sites

Do you have fasciaid set to Auto Increment in your DB?

 

If so, you can change this line

 

$add_item= "INSERT INTO fascia (fasciaid, carid, partno, type) VALUES ('', '$_POST[carid]', '$_POST[partfas]', '$_POST[fascia]')";

to

 

$add_item= "INSERT INTO fascia (carid, partno, type) VALUES ('$_POST[carid]', '$_POST[partfas]', '$_POST[fascia]')";

If not, you need to set a value for it since its probably set to not null and int

 

 

 

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.