Please help. I am trying to change data in my MySql database. I am able to input new data, but when i try to change anything, it doesn't work. Here is my code:
$id = $_REQUEST['id'];
$newname = $_REQUEST['newname'];
$newemail = $_REQUEST['newemail'];
$newpassword = $_REQUEST['newpassword'];
mysql_connect("localhost", "root", "") or die("problem with connection");
mysql_query("UPDATE users SET name='$newname', email='$newemail', password='$newpassword' WHERE users id='$id'");
echo "Your values have been updated! Now kiss my ###";
I am doing this on a localhost, so the login is correct (and with no password!). As far as i can tell, the problem lies within the mysql_query. But what am i doing wrong? Please keep in mind that I am a total beginner to PHP and MySql databases.
I have updated the line to change the database as follows:
mysql_query("UPDATE users SET name='$newname', email='$newemail', password='$newpassword' WHERE id='$id'");
I recieve no error while doing so, but the change still doesn't occur. I am only querying that single table. Also, i am able to add new data to the table, so i don't think there is anything wrong with the connection. But for some reason, it doesn't understand what it is, i am trying to do. And thanks for your help btw! :)
IT WORKS! :) Thank you so much for your help! And thx for helping me kickstarting my brain ;) I found the problem by echoing out the paramiters (id, name, email and password) and discovered that it wasn't recieving the 'id' paramater! Found a typo in the file it was recieving from and BOOM! Now it works! Your help is very much appreciated. Thanks again.