oliverj777 Posted August 26, 2010 Share Posted August 26, 2010 Okay, I have a useredit page in where a user can manage their account info. All the text field and SQL connections work fine, and they all update perfectly. But when I go ahead and add my own text field (first name) and hit submit, it says success - but in my SQL it hasn't actually updated ... What the Ef? Here are my snippets of my codes: --useredit.php-- <form action="process.php" method="POST"> <input type"text" name"firstname" value="<? if($form->value("firstname") == ""){ echo $session->userinfo['firstname']; }else{ echo $form->value("firstname"); } ?>"> <input type="hidden" name="subedit" value="1"> <input type="submit" value="Edit Account"> --process.php-- function procEditAccount(){ global $session, $form; /* Account edit attempt */ $retval = $session->editAccount($_POST['curpass'], $_POST['newpass'], $_POST['email'], $_POST['firstname']); /* Account edit successful */ if($retval){ $_SESSION['useredit'] = true; header("Location: ".$session->referrer); } --session.php-- function editAccount($subcurpass, $subnewpass, $subemail, $subfirstname){ global $database, $form; if($subfirstname){ $database->updateUserField($this->username,"firstname",$subfirstname); } --database.php-- function updateUserField($username, $field, $value){ $q = "UPDATE ".TBL_USERS." SET ".$field." = '$value' WHERE username = '$username'"; return mysql_query($q, $this->connection); } If you need to see more code, let me know. Would appreciate the help, thanks! Ollie! Quote Link to comment https://forums.phpfreaks.com/topic/211789-updating-field-in-sql-via-php-help/ Share on other sites More sharing options...
PFMaBiSmAd Posted August 26, 2010 Share Posted August 26, 2010 So, when you were debugging this to find out what execution path your code is taking and what the data was at the different points along that path, at what point did you find you had the expected data and at what point did you find you did not? I can guarantee that the problem lies between those two points. Quote Link to comment https://forums.phpfreaks.com/topic/211789-updating-field-in-sql-via-php-help/#findComment-1103961 Share on other sites More sharing options...
oliverj777 Posted August 26, 2010 Author Share Posted August 26, 2010 Oh My Jesus Christ -- It's taken me, what 6 hours to figure this out ... And I've just found the problem .. You're not going to believe it. I missed the '=' off the: input type"text" name"firstname"... Correction is: input type="text" name="firstname"... It had nothing to do with my PHP coding!! HOW ANNOYING!! Quote Link to comment https://forums.phpfreaks.com/topic/211789-updating-field-in-sql-via-php-help/#findComment-1104046 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.