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

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
Moonspell
Forum Newbie
Posts: 21
Joined: Tue May 13, 2003 4:54 pm

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

Post 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.
User avatar
redhair
Forum Contributor
Posts: 300
Joined: Fri May 30, 2003 4:36 pm
Location: 53.23N-6.57E
Contact:

Post 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
User avatar
redhair
Forum Contributor
Posts: 300
Joined: Fri May 30, 2003 4:36 pm
Location: 53.23N-6.57E
Contact:

Post 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
Post Reply