Update Table Error

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
thisbl00d
Forum Newbie
Posts: 13
Joined: Sat Feb 14, 2009 1:17 pm

Update Table Error

Post by thisbl00d »

Code: Select all

$sql = "UPDATE " . USERS_TABLE . "
                SET " . $username_sql . $passwd_sql . "user_email = '" . str_replace("\'", "''", $email) ."', user_interests = '" . str_replace("\'", "''", $interests) . "',user_viewemail = $viewemail,  '" . "' user_allowhtml = $allowhtml, user_allow_viewonline = $allowviewonline, user_notify = $notifyreply, user_notify_pm = $notifypm, user_popup_pm = $popup_pm, user_dateformat = '" . str_replace("\'", "''", $user_dateformat) . "', user_active = $user_active, user_actkey = '" . str_replace("\'", "''", $user_actkey) . "'" . "
                WHERE user_id = $user_id";
 
        if ( !($result = $db->sql_query($sql)) )
            {
                message_die(GENERAL_ERROR, 'Could not update users table', '', __LINE__, __FILE__, $sql);
            }
Do u guys see any error in the update query?

The error show is
Could not update users table

DEBUG MODE

SQL Error : 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''' user_allowhtml = 1, user_allow_viewonline = 1, user_notify = 0, user_notify_p' at line 2

UPDATE phpbb_users SET user_email = 'thisbl00d@devnetowrk.com', user_interests = 'pop',user_viewemail = 1, '' user_allowhtml = 1, user_allow_viewonline = 1, user_notify = 0, user_notify_pm = 1, user_popup_pm = 1, user_dateformat = 'd M Y h:i a', user_active = 1, user_actkey = '' WHERE user_id = 2
:banghead: ive been trying to figure this out for a very long time . pls help. i wud be thankful if any one writes down the correct form of the above query :dubious:
User avatar
susrisha
Forum Contributor
Posts: 439
Joined: Thu Aug 07, 2008 11:43 pm
Location: Hyderabad India

Re: Update Table Error

Post by susrisha »

try this please

Code: Select all

 
$sql = "UPDATE phpbb_users 
                SET " . $username_sql . $passwd_sql . "user_email = '" . str_replace("'", "''", $email) ."', user_interests = '" . str_replace("'", "''", $interests) . "',user_viewemail = $viewemail,  user_allowhtml = $allowhtml, user_allow_viewonline = $allowviewonline, user_notify = $notifyreply, user_notify_pm = $notifypm, user_popup_pm = $popup_pm, user_dateformat = '" . str_replace("'", "''", $user_dateformat) . "', user_active = $user_active, user_actkey = \'" . str_replace("'", "''", $user_actkey) . "\'" . "
                WHERE user_id = $user_id";
 
thisbl00d
Forum Newbie
Posts: 13
Joined: Sat Feb 14, 2009 1:17 pm

Re: Update Table Error

Post by thisbl00d »

workSSSSS !!!! i see THE error!! :x


thnx!!
Post Reply