thereaper87 Posted August 8, 2011 Share Posted August 8, 2011 Hello there, I'm having a bit of trouble getting the UPDATE function to work and I was looking for some guidance. Here is the form: echo '<tr><td width="300">Current Avatar: <br /><img src="avatars/'.$data[avatar].'" width="100" height="100"></td><td width="300"><input type="file" value="Change" name="file"></td></tr>'; echo '<tr><td width="300">News Pick 1</td><td width="300"><select name="pick1"><option value="'.$data[field1].'">'.$data[field1].'</option><option value="Science">Science</option><option value="Politics">Politics</option><option value="Arts">Arts</option><option value="Sports">Sports</option><option value="Religious">Religious</option><option value="General">General</option><option value="Electronics">Electronics</option></select></td></tr>'; echo '<tr><td width="300">News Pick 2</td><td width="300"><select name="pick2"><option value="'.$data[field2].'">'.$data[field2].'</option><option value="Science">Science</option><option value="Politics">Politics</option><option value="Arts">Arts</option><option value="Sports">Sports</option><option value="Religious">Religious</option><option value="General">General</option><option value="Electronics">Electronics</option></select></td></tr>'; echo '<tr><td width="300">News Pick 3</td><td width="300"><select name="pick3"><option value="'.$data[field3].'">'.$data[field3].'</option><option value="Science">Science</option><option value="Politics">Politics</option><option value="Arts">Arts</option><option value="Sports">Sports</option><option value="Religious">Religious</option><option value="General">General</option><option value="Electronics">Electronics</option></select></td></tr>'; echo '<tr><td width="300">Edit Bio</td><td width="300"><textarea name="bio" cols="50" rows="8">'.$data[bio].'</textarea></td></tr>'; echo '<tr><td width="300"><input type="submit" value="Submit Changes"></form></td><td></td></tr>'; Pretty much 3 drop-downs and a textbox. Here is the processing: if (function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc()) { $_POST['pick1'] = stripslashes($_POST['pick1']); $_POST['pick2'] = stripslashes($_POST['pick2']); $_POST['pick3'] = stripslashes($_POST['pick3']); $_POST['bio'] = stripslashes($_POST['bio']); $userid = stripslashes($userid); } $pick1 = mysql_real_escape_string($_POST['pick1']); $pick2 = mysql_real_escape_string($_POST['pick2']); $pick3 = mysql_real_escape_string($_POST['pick3']); $bio = mysql_real_escape_string($_POST['bio']); $userid = mysql_real_escape_string($userid); $update_profile=mysql_query("UPDATE `user` SET `field1`='$pick1',`field2`='$pick2',`field3`='$pick3',`bio`='$bio' WHERE `username`='$userid'") or die(mysql_error($update_profile)); echo '<br />Your profile has been updated.'; echo '<br /><a href="index.php?page=cpanel">Go to profile</a>'; // $userid = $_SESSION['user'] , that is where it is called But when I fill out the form, it says it has been updated, but no change in the row in the database. Any ideas? What am I missing? Quote Link to comment https://forums.phpfreaks.com/topic/244191-update-script-saying-successful-but-isnt/ Share on other sites More sharing options...
thereaper87 Posted August 8, 2011 Author Share Posted August 8, 2011 Trying to debug my sql statement. This is what it echo'd out when I ran the query: UPDATE `user` SET `field1`='Science',`field2`='General',`field3`='Electronics',`bio`='asdfasdfsdf' WHERE `username`='thisismyusername' Everything seems to be in their columns...i'm lost Quote Link to comment https://forums.phpfreaks.com/topic/244191-update-script-saying-successful-but-isnt/#findComment-1254102 Share on other sites More sharing options...
phpSensei Posted August 8, 2011 Share Posted August 8, 2011 What is the error ouput? Quote Link to comment https://forums.phpfreaks.com/topic/244191-update-script-saying-successful-but-isnt/#findComment-1254104 Share on other sites More sharing options...
thereaper87 Posted August 8, 2011 Author Share Posted August 8, 2011 What is the error ouput? There is no error output. I have die(mysql_error($update_profile)); echo '<br />Your profile has been updated.'; But it does not display an error. Quote Link to comment https://forums.phpfreaks.com/topic/244191-update-script-saying-successful-but-isnt/#findComment-1254105 Share on other sites More sharing options...
phpSensei Posted August 8, 2011 Share Posted August 8, 2011 Do a var_dump($_post) Quote Link to comment https://forums.phpfreaks.com/topic/244191-update-script-saying-successful-but-isnt/#findComment-1254106 Share on other sites More sharing options...
thereaper87 Posted August 8, 2011 Author Share Posted August 8, 2011 Not too sure what it means, but here is the result: array(4) { ["pick1"]=> string(7) "Science" ["pick2"]=> string(7) "General" ["pick3"]=> string(11) "Electronics" ["bio"]=> string(11) "asdfasdfsdf" } Quote Link to comment https://forums.phpfreaks.com/topic/244191-update-script-saying-successful-but-isnt/#findComment-1254107 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.