foreverhex Posted July 18, 2006 Share Posted July 18, 2006 I have made this code and Im still new at MySQL so I apoligize if it looks buggy. But when you go to submit the info it wont switch any thing and makes the name value 0? Here is the code, any ideas why?[code]<?phpinclude 'db.php';//Grab the reviewed user info$user = $_POST['user'];$password = $_POST['password'];$name = $_POST['name'];$email = $_POST['email'];$age = $_POST['age'];$sex = $_POST['sex'];$location = $_POST['location'];$medium = $_POST['medium'];$interests = $_POST['interests'];$homepage = $_POST['homepage'];//New Password checkif ((!$password)) {$sql = mysql_query("UPDATE users SET name='$name' AND email='$email' AND age='$age' AND sex='$sex' AND location='$location' AND medium='$medium' AND interests='$interests' WHERE user='$user'");}else {$newpassword =md5($password);$sql = mysql_query("UPDATE users SET password='$newpassword' AND name='$name' AND email='$email' AND age='$age' AND sex='$sex' AND location='$location' AND medium='$medium' AND interests='$interests' WHERE user='$user'");if(!$sql) {echo "There has been an error while trying to modify your account. Please report a bug in the forums or try again later.";}}echo 'You information has been updated!';?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/14914-problem-with-putting-info-in-mysql/ Share on other sites More sharing options...
toplay Posted July 18, 2006 Share Posted July 18, 2006 Replace all the 'AND' in the update with commas. See the UPDATE syntax in the manual:http://dev.mysql.com/doc/refman/4.1/en/update.html Quote Link to comment https://forums.phpfreaks.com/topic/14914-problem-with-putting-info-in-mysql/#findComment-59794 Share on other sites More sharing options...
foreverhex Posted July 18, 2006 Author Share Posted July 18, 2006 So you never want to put AND 's? That worked thanks! Quote Link to comment https://forums.phpfreaks.com/topic/14914-problem-with-putting-info-in-mysql/#findComment-59881 Share on other sites More sharing options...
wildteen88 Posted July 18, 2006 Share Posted July 18, 2006 You only to use AND in a query you are comparing somthing to something else, such as within a WHERE clause Quote Link to comment https://forums.phpfreaks.com/topic/14914-problem-with-putting-info-in-mysql/#findComment-59904 Share on other sites More sharing options...
foreverhex Posted July 18, 2006 Author Share Posted July 18, 2006 AHH! I see, so an example would be WHERE user='$user' AND email='$email' . Thats good to know thanks! Quote Link to comment https://forums.phpfreaks.com/topic/14914-problem-with-putting-info-in-mysql/#findComment-60108 Share on other sites More sharing options...
Chevy Posted July 18, 2006 Share Posted July 18, 2006 Yup and you can use it in any other statementexampleif ($user==Bob AND password==bobby){ Quote Link to comment https://forums.phpfreaks.com/topic/14914-problem-with-putting-info-in-mysql/#findComment-60113 Share on other sites More sharing options...
foreverhex Posted July 18, 2006 Author Share Posted July 18, 2006 Kick ass! There are some many things I still need to learn but I need to screw up to figure out that I need to know these things. Quote Link to comment https://forums.phpfreaks.com/topic/14914-problem-with-putting-info-in-mysql/#findComment-60122 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.