hasek522 Posted August 11, 2008 Share Posted August 11, 2008 I am trying to create an update statement but cannot seem to get it to work. If some one could take a look at it for me I would greatly appreciate it. $sql = "UPDATE stylists SET 'firstname=". $firstname . "', 'lastname=" . $lastname. "', 'address=" . $address. "', 'city=" . $city. "', 'state=" . $state. "', 'zip=" . $zip. "', 'salon=" . $salon. "', 'specialty=" . $specialty. "', 'education=" . $education. "', 'experience=" . $experience. "', 'phone=" . $phone. "', 'email=" . $email. "', 'website=" . $website. "', 'description=" . $description . "' WHERE id=".$_SESSION['USERID'].")"; mysql_query($sql) or die(mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/119218-solved-sql-update-in-php/ Share on other sites More sharing options...
DarkWater Posted August 11, 2008 Share Posted August 11, 2008 Any errors? Quote Link to comment https://forums.phpfreaks.com/topic/119218-solved-sql-update-in-php/#findComment-614024 Share on other sites More sharing options...
hasek522 Posted August 11, 2008 Author Share Posted August 11, 2008 ya sorry, here is the error: 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 ''firstname=Jason', ' lastname=Hedrick', ' address=4937 Briggs Ave', ' city=La Cr' at line 2 Quote Link to comment https://forums.phpfreaks.com/topic/119218-solved-sql-update-in-php/#findComment-614026 Share on other sites More sharing options...
Daniel0 Posted August 11, 2008 Share Posted August 11, 2008 The query is completely malformed and the quotes are screwed up. Try to echo the query and you'll see what I mean. Quote Link to comment https://forums.phpfreaks.com/topic/119218-solved-sql-update-in-php/#findComment-614027 Share on other sites More sharing options...
hasek522 Posted August 11, 2008 Author Share Posted August 11, 2008 hmmm i echo'd it and kind of see what you mean, not exactly sure how to go about fixing it tho. Quote Link to comment https://forums.phpfreaks.com/topic/119218-solved-sql-update-in-php/#findComment-614029 Share on other sites More sharing options...
Daniel0 Posted August 11, 2008 Share Posted August 11, 2008 Just rewrite it: $sql = "UPDATE stylists SET firstname='{$firstname}', lastname='{$lastname}', [...]"; Quote Link to comment https://forums.phpfreaks.com/topic/119218-solved-sql-update-in-php/#findComment-614030 Share on other sites More sharing options...
hasek522 Posted August 11, 2008 Author Share Posted August 11, 2008 Ok heres my new statement : $sql = "UPDATE stylists SET firstname='{$firstname}', lastname='{$lastname}', address='{$address}', city='{$city}', $state='{$state}', zip='{$zip}', salon='{$salon}', specialty='{$specialty}', education='{$education}', experience='{$experience}', phone='{$phone}', website='{$website}', description='{$description}' WHERE id=".$_SESSION['USERID']; Here is the error: Unknown column 'California' in 'field list' Quote Link to comment https://forums.phpfreaks.com/topic/119218-solved-sql-update-in-php/#findComment-614040 Share on other sites More sharing options...
hasek522 Posted August 11, 2008 Author Share Posted August 11, 2008 nvm i fixed it. Thanks all for the help. Quote Link to comment https://forums.phpfreaks.com/topic/119218-solved-sql-update-in-php/#findComment-614041 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.