Fuzzy Wobble Posted August 22, 2007 Share Posted August 22, 2007 i try this and i get the error every time. $username is correct and exists is database. something i am missing? $insert = "insert into members_e(country, stateprov, city, birthdate, ownsite) values (\"$country\",\"$stateprov\",\"$city\",\"$birthdate\",\"$ownsite\") where username = '$username'"; You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'where username = 'test'' at line 1 Quote Link to comment https://forums.phpfreaks.com/topic/66093-insert-into-database-simple-error/ Share on other sites More sharing options...
clearstatcache Posted August 22, 2007 Share Posted August 22, 2007 try ds 1.... $insert = "insert into members_e(country, stateprov, city, birthdate, ownsite) values ('$country','$stateprov','$city','$birthdate','$ownsite') where username = '$username'"; if ds still wont work try ds 1 also.. $insert = "insert into members_e(country, stateprov, city, birthdate, ownsite) values ('{$country}','{$stateprov}','{$city}','{$birthdate}','{$ownsite}') where username = '$username'"; Quote Link to comment https://forums.phpfreaks.com/topic/66093-insert-into-database-simple-error/#findComment-330553 Share on other sites More sharing options...
keeB Posted August 22, 2007 Share Posted August 22, 2007 Single quotes inside SQL! " " refers to columns! $insert = "insert into members_e(country, stateprov, city, birthdate, ownsite) values (\"$country\",\"$stateprov\",\"$city\",\"$birthdate\",\"$ownsite\") where username = '$username'"; becomes $insert = "insert into members_e(country, stateprov, city, birthdate, ownsite) values ('$country', '$stateprov', '..', '..' ) where username = '$username' "; Quote Link to comment https://forums.phpfreaks.com/topic/66093-insert-into-database-simple-error/#findComment-330554 Share on other sites More sharing options...
Fuzzy Wobble Posted August 22, 2007 Author Share Posted August 22, 2007 still the same error with this code $insert = "insert into members_e(country, stateprov, city, birthdate, ownsite) values ('$country','$stateprov','$city','$birthdate','$ownsite') where username = '$username' "; Quote Link to comment https://forums.phpfreaks.com/topic/66093-insert-into-database-simple-error/#findComment-330565 Share on other sites More sharing options...
Fuzzy Wobble Posted August 22, 2007 Author Share Posted August 22, 2007 ok i got it going. Quote Link to comment https://forums.phpfreaks.com/topic/66093-insert-into-database-simple-error/#findComment-330568 Share on other sites More sharing options...
Fuzzy Wobble Posted August 22, 2007 Author Share Posted August 22, 2007 nevermind. it still is not working properly. Quote Link to comment https://forums.phpfreaks.com/topic/66093-insert-into-database-simple-error/#findComment-330578 Share on other sites More sharing options...
Hypnos Posted August 22, 2007 Share Posted August 22, 2007 You can't have a WHERE on an INSERT. INSERT means adding a new row from scratch. If you want to modify the row, use UPDATE and SET. Quote Link to comment https://forums.phpfreaks.com/topic/66093-insert-into-database-simple-error/#findComment-330581 Share on other sites More sharing options...
clearstatcache Posted August 22, 2007 Share Posted August 22, 2007 yeah ryt...i haven't noticed it...silly me.....hehehehe Quote Link to comment https://forums.phpfreaks.com/topic/66093-insert-into-database-simple-error/#findComment-330612 Share on other sites More sharing options...
Fuzzy Wobble Posted August 22, 2007 Author Share Posted August 22, 2007 ok thanks Hypnos that sounds accurate. MUCH APPRECIATED! I will try that Quote Link to comment https://forums.phpfreaks.com/topic/66093-insert-into-database-simple-error/#findComment-330940 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.