Website Membership (?) MySQL Error

By yusuke - August 29, 2010

Hi,

I set up multiple member profile pages so members can update their profiles by categories such as login info, store info...

I get an error message.

(It's in Japanese)
MySQL ƒGƒ‰[F
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 'set = 'ƒeƒXƒg', message = 'ƒeƒXƒg', ' at line 10


TRANSLATION:
MySQL ErrorF
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 'set = 'TEST', message = 'TEST', ' at line 10


<?php require_once"/home/keepstock-s/www/hairsalon/lib/viewer_functions.php"; ?>

<?php if (!@$GLOBALS['WEBSITE_MEMBERSHIP_PLUGIN']) { die("ƒƒ“ƒo[ƒy[ƒW‚ª‹N“®‚µ‚Ä‚¢‚Ü‚¹‚ñB"); } ?>
<?php if (!$CURRENT_USER) { websiteLogin_redirectToLogin(); } ?>
<?php

// prepopulate form with current user values
foreach ($CURRENT_USER as $name => $value) {
if (array_key_exists($name, $_REQUEST)) { continue; }
$_REQUEST[$name] = $value;
}

// process form
if (@$_REQUEST['save']) {

// error checking
$errorsAndAlerts = "";
if (!@$_REQUEST['shopname']) { $errorsAndAlerts .= "ƒVƒ‡ƒbƒv–¼‚ð“ü—Í‚µ‚ĉº‚³‚¢B<br/>\n"; }
if (!@$_REQUEST['address']) { $errorsAndAlerts .= "ZŠ‚ð“ü—Í‚µ‚ĉº‚³‚¢B<br/>\n"; }
if (!@$_REQUEST['phone']) { $errorsAndAlerts .= "“d˜b”ԍ†‚ð“ü—Í‚µ‚ĉº‚³‚¢B<br/>\n"; }
if (!@$_REQUEST['time']) { $errorsAndAlerts .= "‰c‹ÆŽžŠÔ‚ð“ü—Í‚µ‚ĉº‚³‚¢B<br/>\n"; }
if (!@$_REQUEST['station']) { $errorsAndAlerts .= "ÅŠñ‚è‰w‚ð“ü—Í‚µ‚ĉº‚³‚¢B<br/>\n"; }
if (!@$_REQUEST['dayoff']) { $errorsAndAlerts .= "‹x“ú‚ð“ü—Í‚µ‚ĉº‚³‚¢B<br/>\n"; }
if (!@$_REQUEST['card']) { $errorsAndAlerts .= "ƒJ[ƒh–¼‚ð“ü—Í‚µ‚ĉº‚³‚¢B<br/>\n"; }
if (!@$_REQUEST['staff']) { $errorsAndAlerts .= "ƒXƒ^ƒbƒtl”‚ð“ü—Í‚µ‚ĉº‚³‚¢B<br/>\n"; }
if (!@$_REQUEST['set']) { $errorsAndAlerts .= "ƒZƒbƒg–Ê‚ð“ü—Í‚µ‚ĉº‚³‚¢B<br/>\n"; }
if (!@$_REQUEST['message']) { $errorsAndAlerts .= "ƒƒbƒZ[ƒW‚ð“ü—Í‚µ‚ĉº‚³‚¢B<br/>\n"; }


// update user
if (!$errorsAndAlerts) {
mysqlStrictMode(false); // disable Mysql strict errors for when a field isn't defined below (can be caused when fields are added later)
if (@$_REQUEST['newPassword2']) { $CURRENT_USER['password'] = $_REQUEST['newPassword2']; } // update password
$query = "UPDATE `{$TABLE_PREFIX}accounts` SET
shopname = '".mysql_escape( $_REQUEST['shopname'] )."',
address = '".mysql_escape( $_REQUEST['address'] )."',
phone = '".mysql_escape( $_REQUEST['phone'] )."',
time = '".mysql_escape( $_REQUEST['time'] )."',
station = '".mysql_escape( $_REQUEST['station'] )."',
dayoff = '".mysql_escape( $_REQUEST['dayoff'] )."',
card = '".mysql_escape( $CURRENT_USER['card'] )."',
staff = '".mysql_escape( $_REQUEST['staff'] )."',
set = '".mysql_escape( $_REQUEST['set'] )."',
message = '".mysql_escape( $_REQUEST['message'] )."',

updatedByUserNum = '".mysql_escape( $CURRENT_USER['num'] )."',
updatedDate = NOW()
WHERE num = '".mysql_escape( $CURRENT_USER['num'] )."'";
mysql_query($query) or die("MySQL ƒGƒ‰[F<br/>\n". htmlspecialchars(mysql_error()) . "\n");
$userNum = mysql_insert_id();

// on success
unset($_REQUEST['oldPassword'], $_REQUEST['newPassword1'], $_REQUEST['newPassword2']); // clear password fields
$errorsAndAlerts = "ƒƒ“ƒo[î•ñ‚͍XV‚³‚ê‚Ü‚µ‚½B";
}

}

?>


Will you please help me on this problem?

Re: [yusuke] Website Membership (?) MySQL Error

By Chris - August 30, 2010

Hi yusuke,

It could be that your field name "set" is a [url http://dev.mysql.com/doc/refman/4.1/en/reserved-words.html]MySQL Reserved Word[/url]. Try adding some backtick quotes around it whenever you use it in SQL to see if that helps.

For example, try changing this line:

set = '".mysql_escape( $_REQUEST['set'] )."',

...to this:

`set` = '".mysql_escape( $_REQUEST['set'] )."',

Does that help? If not, please let me know and I'll figure out what to try next!
All the best,
Chris

Re: [chris] Website Membership (?) MySQL Error

By yusuke - August 30, 2010

Hi Chris,

Everything is fine now!

Thank you!!!!!

It was caused by MySQL Reserved Word. Also it seems that there was other reasons causing the error such as unnecessary spacing. (?)