new here, looking for a hand

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!

Moderator: General Moderators

Post Reply
meres
Forum Newbie
Posts: 2
Joined: Sun Apr 13, 2008 9:34 pm

new here, looking for a hand

Post by meres »

Hi,

Im new to the forum, and looking for a bit of help.

Im developing a site complete with user accounts, mail from user to user, etc.
Ive gotten the accounts to function, login and register. But i am having trouble allowing a user to change their account information.

This is the code to update the mysql database with a php form..

Code: Select all

 
if(!$error) {
$userName = $_SESSION['userName'];
mysql_query("INSERT INTO users (name, location, funds, time, email) VALUES ('$_POST[name]', '$_POST[location]', '$_POST[funds]', '$_POST[time]', '_POST['email']') WHERE username = test");
}
 
Is there an error in this code? Im getting no errors when i use the form, but the database entries are not getting updated.

Thanks for helping :D
spligak
Forum Newbie
Posts: 1
Joined: Sun Apr 13, 2008 3:11 pm
Location: Plano, TX, USA

Re: new here, looking for a hand

Post by spligak »

Code: Select all

mysql_query("UPDATE `users` set `name` = '".$_POST['name']."', `location` = '".$_POST['location']."', `funds` = '".$_POST['funds']."', `time` = '".$_POST['time']."', `email` = '".$_POST['email']."' WHERE `username` = '".$userName."'");
I changed your insert query to an update, as you mentioned this would be used for updating. Should work fine.
meres
Forum Newbie
Posts: 2
Joined: Sun Apr 13, 2008 9:34 pm

Re: new here, looking for a hand

Post by meres »

thanks!

that was the problem, been a while since ive done work with databases :banghead:
Post Reply