Page 1 of 1

This INSERT query isn't working correctly; need set of eyes

Posted: Thu Jun 05, 2003 6:34 pm
by Moonspell
Hello. Here's the insert statement which I'm executing:

mysql_query("INSERT INTO CustomerEntry (ClientSalesID, ClientNameID, FName, LName, StreetNum, StreetName, Zip, Telephone, Email, GuessNumber, GuessDate, CurrVehicleYr, CurrVehicleMake, CurrVehicleModel, LastVehiclePurchase, VehicleType, CurrPayment, MostImportantNewCar, Marketing) values ('$FName', '$LName', '$StreetNum', '$StreetName', '$Zip', '$Telephone', '$Email', '$GuessNumber', '$DateOfSubmit', '$CurrVehicleYear', '$CurrVehicleMake', '$CurrVehicleModel', '$VehiclePurchase', '$CurrVehicleType', '$CurrPayment', '$MostImportantNewCar', '$Marketing')");
[Admin Edit: added some spaces to the SQL statement to allow it to wrap]

I have a connection to MySQL, because a previous query works fine. Here's the fields I have in the MySQL table, called CustomerEntry

CustomerEntryID, ClientSalesID, ClientNameID, FName, LName, StreetNum, StreetName, Zip, Telephone, Email, GuessNumber, GuessDate, CurrVehicleYr, CurrVehicleMake, CurrVehicleModel, LastVehiclePurchase, VehicleType, CurrPayment, MostImportantNewCar and Marketing

Do you see any typo? Nothing is inserted.

Posted: Thu Jun 05, 2003 7:44 pm
by redhair
I had the same problem yesterday...
Forgot to putt cell 'user_id' on auto increment then only one value will be added...and the rest goes byebye

Posted: Thu Jun 05, 2003 7:55 pm
by redhair
btw.....ClientSalesID, ClientNameID is not beeing added in your code

i think you should try:

Code: Select all

<?php
mysql_query("INSERT INTO CustomerEntry (ClientNameID, FName, LName, StreetNum, StreetName, Zip, Telephone, Email, GuessNumber, GuessDate, CurrVehicleYr, CurrVehicleMake, CurrVehicleModel, LastVehiclePurchase, VehicleType, CurrPayment, MostImportantNewCar, Marketing) values ('$ClientNameID', '$FName', '$LName', '$StreetNum', '$StreetName', '$Zip', '$Telephone', '$Email', '$GuessNumber', '$DateOfSubmit', '$CurrVehicleYear', '$CurrVehicleMake', '$CurrVehicleModel', '$VehiclePurchase', '$CurrVehicleType', '$CurrPayment', '$MostImportantNewCar', '$Marketing')");
?>
[Admin Edit: Added some spaces to the SQL statement to allow it to wrap]

i left ClientSalesID emty...if you have that cell on auto increment and primary key in your database it will automaticaly add a number if you add something to the database