Website Membership (?) MySQL Error
4 posts by 2 authors in: Forums > CMS Builder: Plugins & Add-ons
Last Post: August 31, 2010 (RSS)
By yusuke - August 29, 2010
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 ErrorF
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ƒtl”‚ð“ü—Í‚µ‚ĉº‚³‚¢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[î•ñ‚ÍXV‚³‚ê‚Ü‚µ‚½B";
}
}
?>
Will you please help me on this problem?
Re: [yusuke] Website Membership (?) MySQL Error
By Chris - August 30, 2010
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!
Chris
Re: [chris] Website Membership (?) MySQL Error
By yusuke - August 30, 2010
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. (?)
Re: [yusuke] Website Membership (?) MySQL Error
By Chris - August 31, 2010
Glad you got this fixed!
Unnecessary spacing is not an issue. If you're referring to the fact that I removed a couple spaces above, that's just a habit I have to keep things lined up. You can add or remove as many spaces as you want. :)
Chris