Jump to content

Recommended Posts

In the site I'm currently working on I'm having a reoccuring problem where for some reason a particular variable just likes to change itself to '0'. Here's one instance of the code..

[code]if($_POST['submit'] == "Update")
{
    $realname = sanitize($_POST['realname']);
    if($realname)
    {
        if(strlen($realname) > 64)
        {
            doMessage('Your real name must be less than 64 characters.');
        }
    }
    if(strlen($_SESSION['message']) == 0)
    {
        doQuery("UPDATE `members` SET `realname`='$realname' AND `gender`='$gender' AND `location`='$location' AND `birthday`='$birthday' AND `email`='$email' AND `about`='$about' AND `forumavatar`='$forumavatar' WHERE `username`='". $userInfo['username'] ."'");
    }
}[/code]

The doQuery function is nothing but
[code]function doQuery($query)
{
    $query = mysql_query($query .';') or die($dieMessage . "\n<br />". mysql_errno() .': '. mysql_error() .'</p>');
    return $query;
}[/code]

And the doMessage is just
[code]function doMessage($messageStr, $class="error")
{
    if($_SESSION['message']) {$_SESSION['message'] .= "\n<br />";}
    $_SESSION['message'] .= '<span class="$class">'. $messageStr .'</span>';
}[/code]

Everything else will insert itself in the database fine, but for some reason 'realname' will change itself to 0. I cannot figure out why.
I left out big chunks of code from the first part, but nothing I would think worth posting..
If anybody can figure out what I'm doing wrong I would greatly appreciate it. I've exhausted myself for over a month now trying to figure out what the deal is.

Thanks alot!
Daniel
Link to comment
https://forums.phpfreaks.com/topic/11852-string-changing/
Share on other sites

[!--quoteo(post=383184:date=Jun 13 2006, 10:12 AM:name=coldkill)--][div class=\'quotetop\']QUOTE(coldkill @ Jun 13 2006, 10:12 AM) [snapback]383184[/snapback][/div][div class=\'quotemain\'][!--quotec--]
What does the sanitize function do? If it is adding slashes or the sort you might want to use mysql_real_escape_string() which will also help stop injection attacks.
[/quote]


sanitize? what that mean get rid of it lol.

Wash a string according to google.

Echo out the query then post the result ok.
Link to comment
https://forums.phpfreaks.com/topic/11852-string-changing/#findComment-44945
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.