Jump to content

Update script, saying successful, but isn't.


thereaper87

Recommended Posts

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?

Link to comment
Share on other sites

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  :shrug:

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.