ERROR : "You have an error in your SQL syntax; check the manual that > corresponds to your MySQL server "
ERROR : "You have an error in your SQL syntax; check the manual that > corresponds to your MySQL server "
我在使用下面的函数时遇到错误,我正在为 WordPress 编写插件:
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 '0,'1','', )' at line 2
输入值为:
'user1', 'pass1', 'fredy','lincoln','Batman',0,'0987','31231',1980
查询结果为:
query("INSERT INTO tblusers(UserUserName,UserPassword,UserFirstName,UserLastName,UserNickName,UserSex,UserMobile,UserNationalCode,UserBirthDate)
VALUES ( 'user1', 'pass1', 'fredy','lincoln',,0,'1','', ) ") //error is here//
.
function complete_registration() {
global $wpdb,$reg_errors, $username, $password, $email, $mobile, $first_name, $last_name, $nickname,$gender, $birthdate ;
if ( 1 > count( $reg_errors->get_error_messages() ) ) {
$wpdb->show_errors();
$wpdb = new wpdb('username','*****','mydb','x.x.x.x');
$wpdb->tblusers = 'tblusers';
$sql = $wpdb->prepare( "INSERT INTO $wpdb->tblusers(UserUserName,UserPassword,UserFirstName,UserLastName,UserNickName,UserSex,UserMobile,UserNationalCode,UserBirthDate)
VALUES ( %s, %s, %s,%s,$s,%d,%s,%s,$s )
" ,
array(
$username,
$password,
$first_name,
$last_name,
$nickname,
$gender,
$mobile,
$email,
$birthdate
) );
$wpdb->query($sql);
}
尝试类似的东西
query("INSERT INTO tblusers(UserUserName,UserPassword,UserFirstName,UserLastName,UserNickName,UserSex,UserMobile,UserNationalCode,UserBirthDate)
VALUES ( 'user1', 'pass1', 'fredy','lincoln','nickname','male','+254716370730','254','1993-02-18' ) ")
干杯
您似乎有几个错别字,$s
而不是 %s
,导致蝙蝠侠和 1980 消失:
VALUES ( %s, %s, %s,%s,$s,%d,%s,%s,$s )
只需将其更改为:
VALUES (%s, %s, %s, %s, %s, %d, %s, %s, %s)
我在使用下面的函数时遇到错误,我正在为 WordPress 编写插件:
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 '0,'1','', )' at line 2
输入值为: 'user1', 'pass1', 'fredy','lincoln','Batman',0,'0987','31231',1980
查询结果为:
query("INSERT INTO tblusers(UserUserName,UserPassword,UserFirstName,UserLastName,UserNickName,UserSex,UserMobile,UserNationalCode,UserBirthDate)
VALUES ( 'user1', 'pass1', 'fredy','lincoln',,0,'1','', ) ") //error is here//
.
function complete_registration() {
global $wpdb,$reg_errors, $username, $password, $email, $mobile, $first_name, $last_name, $nickname,$gender, $birthdate ;
if ( 1 > count( $reg_errors->get_error_messages() ) ) {
$wpdb->show_errors();
$wpdb = new wpdb('username','*****','mydb','x.x.x.x');
$wpdb->tblusers = 'tblusers';
$sql = $wpdb->prepare( "INSERT INTO $wpdb->tblusers(UserUserName,UserPassword,UserFirstName,UserLastName,UserNickName,UserSex,UserMobile,UserNationalCode,UserBirthDate)
VALUES ( %s, %s, %s,%s,$s,%d,%s,%s,$s )
" ,
array(
$username,
$password,
$first_name,
$last_name,
$nickname,
$gender,
$mobile,
$email,
$birthdate
) );
$wpdb->query($sql);
}
尝试类似的东西
query("INSERT INTO tblusers(UserUserName,UserPassword,UserFirstName,UserLastName,UserNickName,UserSex,UserMobile,UserNationalCode,UserBirthDate)
VALUES ( 'user1', 'pass1', 'fredy','lincoln','nickname','male','+254716370730','254','1993-02-18' ) ")
干杯
您似乎有几个错别字,$s
而不是 %s
,导致蝙蝠侠和 1980 消失:
VALUES ( %s, %s, %s,%s,$s,%d,%s,%s,$s )
只需将其更改为:
VALUES (%s, %s, %s, %s, %s, %d, %s, %s, %s)