Main
Index
Search
Posts
Who's
Online
Log
In

Home: Products: CMS Builder: Plugins & Add-ons:
Website Membership (?) MySQL Error

 

 


yusuke
User

Aug 29, 2010, 7:18 PM

Post #1 of 4 (2511 views)
Shortcut
Website Membership (?) MySQL Error Can't Post

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)

Code
MySQL エラー: 
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 = 'テスト', message = 'テスト', ' at line 10


TRANSLATION:

Code
MySQL Error: 
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



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

<?php if (!@$GLOBALS['WEBSITE_MEMBERSHIP_PLUGIN']) { die("メンバーページが起動していません。"); } ?>
<?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 .= "ショップ名を入力して下さい。<br/>\n"; }
if (!@$_REQUEST['address']) { $errorsAndAlerts .= "住所を入力して下さい。<br/>\n"; }
if (!@$_REQUEST['phone']) { $errorsAndAlerts .= "電話番号を入力して下さい。<br/>\n"; }
if (!@$_REQUEST['time']) { $errorsAndAlerts .= "営業時間を入力して下さい。<br/>\n"; }
if (!@$_REQUEST['station']) { $errorsAndAlerts .= "最寄り駅を入力して下さい。<br/>\n"; }
if (!@$_REQUEST['dayoff']) { $errorsAndAlerts .= "休日を入力して下さい。<br/>\n"; }
if (!@$_REQUEST['card']) { $errorsAndAlerts .= "カード名を入力して下さい。<br/>\n"; }
if (!@$_REQUEST['staff']) { $errorsAndAlerts .= "スタッフ人数を入力して下さい。<br/>\n"; }
if (!@$_REQUEST['set']) { $errorsAndAlerts .= "セット面を入力して下さい。<br/>\n"; }
if (!@$_REQUEST['message']) { $errorsAndAlerts .= "メッセージを入力して下さい。<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 エラー:<br/>\n". htmlspecialchars(mysql_error()) . "\n");
$userNum = mysql_insert_id();

// on success
unset($_REQUEST['oldPassword'], $_REQUEST['newPassword1'], $_REQUEST['newPassword2']); // clear password fields
$errorsAndAlerts = "メンバー情報は更新されました。";
}

}

?>


Will you please help me on this problem?


Chris
Staff / Moderator


Aug 30, 2010, 3:23 PM

Post #2 of 4 (2453 views)
Shortcut
Re: [yusuke] Website Membership (?) MySQL Error [In reply to] Can't Post

Hi yusuke,

It could be that your field name "set" is a MySQL Reserved Word. Try adding some backtick quotes around it whenever you use it in SQL to see if that helps.

For example, try changing this line:


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


...to this:


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


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


yusuke
User

Aug 30, 2010, 5:58 PM

Post #3 of 4 (2448 views)
Shortcut
Re: [chris] Website Membership (?) MySQL Error [In reply to] Can't Post

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. (?)


Chris
Staff / Moderator


Aug 31, 2010, 12:05 PM

Post #4 of 4 (2436 views)
Shortcut
Re: [yusuke] Website Membership (?) MySQL Error [In reply to] Can't Post

Hi yusuke,

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