paulc8481 Posted December 23, 2011 Share Posted December 23, 2011 Can someone please explain to me why I cant seem to get my mysql update line to work. I have been trying for a while an still nothing. I am new in php and need some help getting this to work. Please be gentle. a good explaination in newbie talk would be appreciated. The session variable I echoed out does work so I know I am reading the variable in from the other page. thanks <?php session_start(); /* Server side scripting with php CISS 225 Lab # Final Project */ //This section will create variables collected from information sent //by the post method on the createUserProcess. /* $_SESSION['city'] = $_POST['city']; $_SESSION['state'] = $_POST['state']; $_SESSION['zipCode'] = $_POST['zipCode']; $_SESSION['profession'] = $_POST['profession']; $_SESSION['activities'] = $_POST['activities']; $_SESSION['hobbies'] = $_POST['hobbies']; */ $city = $_POST['city']; $state = $_POST['state']; $zipCode = $_POST['zipCode']; $profession = $_POST['profession']; $activities = $_POST['activities']; $hobbies = $_POST['hobbies']; $db = mysql_connect("localhost", "root", ""); mysql_select_db("accountprofile",$db); echo $_SESSION['Email']; //$query = "UPDATE accountprofile SET city = '$city', state = '$state', zipcode = '$zipCode', profession = '$profession', " . " //activities = '$activities', hobbies = '$hobbies' WHERE lastName = 'Hildebrand'"; $query = "UPDATE accountprofile SET city = '$city', state = '$state', zipcode = '$zipCode', profession = '$profession', activities = '$activities', hobbies = '$hobbies' WHERE userName = " .$_SESSION['Email'].""; mysql_query($query,$db); if (mysql_error()) { echo "$query<br />"; echo mysql_error(); } echo "THANK YOU!<br />"; echo "Your profile has been completed!<br />"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/253722-trouble-with-session-string-for-mysql/ Share on other sites More sharing options...
requinix Posted December 23, 2011 Share Posted December 23, 2011 You didn't put any quotes around the email. Quote Link to comment https://forums.phpfreaks.com/topic/253722-trouble-with-session-string-for-mysql/#findComment-1300737 Share on other sites More sharing options...
paulc8481 Posted December 23, 2011 Author Share Posted December 23, 2011 Tried putting quotes aroung email in different ways but still nothing! Quote Link to comment https://forums.phpfreaks.com/topic/253722-trouble-with-session-string-for-mysql/#findComment-1300818 Share on other sites More sharing options...
PFMaBiSmAd Posted December 23, 2011 Share Posted December 23, 2011 $query = "UPDATE accountprofile SET city = '$city', state = '$state', zipcode = '$zipCode', profession = '$profession', activities = '$activities', hobbies = '$hobbies' WHERE userName = '" .$_SESSION['Email']."'"; or more simply (less error prone, less typing) - $query = "UPDATE accountprofile SET city = '$city', state = '$state', zipcode = '$zipCode', profession = '$profession', activities = '$activities', hobbies = '$hobbies' WHERE userName = '{$_SESSION['Email']}'"; Are you sure your userName column contains email addresses? Quote Link to comment https://forums.phpfreaks.com/topic/253722-trouble-with-session-string-for-mysql/#findComment-1300819 Share on other sites More sharing options...
paulc8481 Posted December 23, 2011 Author Share Posted December 23, 2011 Your second sting of code worked! thanks so much. I have spent alot of time trying to get this done. and yes I am making the users Email their userName. Thanks paul Quote Link to comment https://forums.phpfreaks.com/topic/253722-trouble-with-session-string-for-mysql/#findComment-1300825 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.