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
https://forums.phpfreaks.com/topic/79258-solved-inserting-to-mysql-database-issue/
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

 

 

 

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.