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. ??? 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 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 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. 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
Archived
This topic is now archived and is closed to further replies.