TGWSE_GY Posted April 17, 2009 Share Posted April 17, 2009 Hi Guys, Okay I have a table `basic_profile` and it has 12 columns (CustID, Headline, Country, ZipCode, State, Gender, Birthdate, Sexuality, InterestedIn, RelationshipStatus, HIVStatus, Ethnicity). Until the user fills in their profile the only thing that is in the table is the CustID, what I am wanting to do is an INSERT statement WHERE CustID = "$varCustID" and skipping CustID in the table and writing to the remaining fields in that record. How would I achieve this what I have right now is mysql_query("INSERT INTO profile_basic WHERE CustID = '$varCustID' ( Headline,Country,ZipCode,State,Gender,Birthdate,Sexuality,InterestedIn,RelationshipStatus,HIVStatus,Ethnicity ) VALUE ('$varHeadline', '$varCountry', '$varZipCode', '$varState', '$varGender', '$varBirthdate', '$varSexuality', '$varInterestedIn', '$varRelationshipStatus', '$varHIVStatus', '$varEthnicity')"); But obviously its not working. I have tested the $varCustID and it does echo the correct value. Any help would be most appreciated, thanks guys. ??? Quote Link to comment https://forums.phpfreaks.com/topic/154519-solved-inserting-one-item-into-a-table/ Share on other sites More sharing options...
kickstart Posted April 17, 2009 Share Posted April 17, 2009 Hi Sounds like what you are trying to do is update an existing record. Hence use the UPDATE command instead of INSERT. All the best Keith Quote Link to comment https://forums.phpfreaks.com/topic/154519-solved-inserting-one-item-into-a-table/#findComment-812425 Share on other sites More sharing options...
TGWSE_GY Posted April 17, 2009 Author Share Posted April 17, 2009 mysql_query("UPDATE profile_basic SET Headline=$varHeadline, Country=$varCountry, ZipCode=$varZipCode, State=$varState, Gender=$varGender, Birthdate=$varBirthdate, Sexuality=$varSexuality, InterestedIn=$varInterestedIn, RelationshipStatus=$varRelationshipStatus, HIVStatus=$varHIVStatus, Ethnicity=$varEthnicity WHERE CustID='$varCustID'") would that be correct? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/154519-solved-inserting-one-item-into-a-table/#findComment-812454 Share on other sites More sharing options...
TGWSE_GY Posted April 17, 2009 Author Share Posted April 17, 2009 Fixed it the statement above was correct I was just forgetting the single quotes around my variables. Quote Link to comment https://forums.phpfreaks.com/topic/154519-solved-inserting-one-item-into-a-table/#findComment-812466 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.