unistake Posted October 17, 2010 Share Posted October 17, 2010 Hi all, I am trying to write a script where the user can update their details. The html form sends the details across to this php file below. All the php variables echo after the query however the values do not replace the current values in the mysql database. Also for some reason the fname is the only one that changes no matter what the value is. It is entered in to mysql as '0'. I think the problem will be in the php below. As all the information below is echoed correctly, and because the value of 'fname' changes I know the connection is working fine. I guess the error must be in the query I have written, however there is no error that comes up... Hope you can point me in the right direction. Thanks <?php include("../cxn.php"); $fname = $_POST['fname']; $lname = $_POST['lname']; $newemail = $_POST['newemail']; $telephone = $_POST['telephone']; $icao = $_POST['icao']; $newpassword = $_POST['newpassword']; $id = $_POST['id']; $sql = "UPDATE Members SET fname='$fname' AND lname='$lname' AND email='$newemail' AND telephone='$telephone' AND password='$newpassword' AND icao='$icao' WHERE id='$id'"; $result = mysqli_query($cxn,$sql) or die ("Couldn't execute query"); echo "Your new details are: <p>"; echo "$fname <br> $lname <br> $newemail <br> $telephone <br> $icao <br> $newpassword"; ?> Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted October 17, 2010 Share Posted October 17, 2010 invalid SQL syntax should be: $sql = "UPDATE Members SET fname='$fname', lname='$lname', email='$newemail', telephone='$telephone', password='$newpassword', icao='$icao' WHERE id='$id'"; Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted October 17, 2010 Share Posted October 17, 2010 The query syntax is wrong. There is no AND between each value. UPDATE `table` SET `field1` = 'string1', `string2` = 'value2', `field3` = 'string3' WHERE `some_field` = 'some_value' Quote Link to comment Share on other sites More sharing options...
unistake Posted October 17, 2010 Author Share Posted October 17, 2010 great help from you both thanks Quote Link to comment 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.