PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
$user = mysql_real_escape_string($_SESSION['username']);
$password = addslashes($_POST['userPassword']);
$query = "INSERT INTO user(userPassword) VALUES ('$password') WHERE username = '$user'";
$result = mysql_query($query) or die(mysql_error());
I keep getting the following 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 'WHERE username = 'admin' at line 1.
I've had a good look at the INSERT query and I can't seem to find anything wrong with it.
Am I missing something?
Oohhhhhhhhhhhhhhh....silly me!! Thank you ever so much!!
Ok...another question...
I'm trying to enter details into the database...or I guess...update the database with a new password...it nearly works.
But everytime I try to enter a new password, the field corresponding to that user's password shows up blank. It doesn't enter the new password, and it appears that the html form isn't capturing the values entered.
<!-- FORM START -->
<form method="post" action="update.php">
<!-- some form fields ... -->
<td><font face="Arial" style="font-size:12pt" color="#0B3A62">Current Password:</td>
<td><input type="password" name="userPassword" maxlength="30" value=""</td>
<!-- some more form fields ... -->
</form>
<!-- FORM END -->
I can't seem to enter a new password into the database. Bear in mind that I want to test out entering any old password into the Current Password text box which will then enter it into the database...I am just testing it out and getting the basics to work before I move any further with this part of the login function. But it seems that something as simple as this won't work.
I got it to work on my registration form, but unfortunately, it's not working with this, despite the forms being very similar. Hmmmm...
I would be so grateful if anyone could come up with something to help me. Thanks.
After submitting form data dump your $_POST array to see if everything is as it should be.
Also dump $_SESSION, since you use $_SESSION['username'] in your queries.