[英]MySQL 'bind_param' statement doesn't seem to work - UserCake cutomization
So I am working on a project using UserCake. 所以我正在使用UserCake进行项目。 I have added fields to the 'users' table.
我已将字段添加到“用户”表。 So far, everything works great.
到目前为止,一切正常。 The issue I am having is when you register, it returns successful but the SQL statement did not put any of the form data into the database.
我遇到的问题是注册时返回成功,但是SQL语句未将任何表单数据放入数据库中。
So far, I have been successful at adding the necessary fields and I am able to pull data from those fields however, I am not able to push data to the database. 到目前为止,我已经成功添加了必填字段,并且能够从这些字段中提取数据,但是,我无法将数据推送到数据库中。 I have a feeling it has to do with the bind_param statement, but I am not sure.
我觉得这与bind_param语句有关,但是我不确定。 Here's what I am dealing with:
这是我要处理的内容:
EDIT 9/30 5pm >>> Only issue at this point is that the data is not being put into the table. 编辑9/30 5pm >>>这时唯一的问题是没有将数据放入表中。
$stmt = $mysqli->prepare("INSERT INTO ".$db_table_prefix."users (
password,
email,
activation_token,
last_activation_request,
lost_password_request,
active,
title,
sign_up_stamp,
last_sign_in_stamp,
company,
address_1,
address_2,
city,
state,
zip,
paid,
first_name,
last_name
)
VALUES (
?,
?,
?,
'".time()."',
'0',
?,
'New Member',
'".time()."',
'0',
?,
?,
?,
?,
?,
?,
'0',
?,
?
)");
$stmt->bind_param("sssisssssiiss", $secure_pass, $this->clean_email, $this->activation_token, $this->user_active, $this->company, $this->address_1, $this->address_2, $this->city, $this->state, $this->zip, $this->first_name, $this->last_name);
$stmt->execute();
print_r($stmt);
$inserted_id = $mysqli->insert_id;
$stmt->close();
EDIT >>> Solved empty array issue 编辑>>>解决了空数组问题
I am calling the new user like this: $user = new User($password, $email, $token, $activationRequest, $passwordRequest, $active, $title, $signUp, $signIn, $company, $address_1, $address_2, $city, $state, $zip, $paid, $first_name, $last_name); 我这样称呼新用户:$ user = new User($ password,$ email,$ token,$ activationRequest,$ passwordRequest,$ active,$ title,$ signUp,$ signIn,$ company,$ address_1,$ address_2 ,$ city,$ state,$ zip,$ paid,$ first_name,$ last_name);
EDIT >>> TABLE uc_users
( id
int(11) NOT NULL, password
varchar(225) NOT NULL, 编辑>>>表
uc_users
( id
int(11)NOT NULL, password
varchar(225)NOT NULL,
email
varchar(150) NOT NULL, email
varchar(150)NOT NULL,
activation_token
varchar(225) NOT NULL, activation_token
varchar(225)NOT NULL,
last_activation_request
int(11) NOT NULL, last_activation_request
int(11)非空,
lost_password_request
tinyint(1) NOT NULL, lost_password_request
tinyint(1)非空,
active
tinyint(1) NOT NULL, active
tinyint(1)NOT NULL,
title
varchar(150) NOT NULL, title
varchar(150)NOT NULL,
sign_up_stamp
int(11) NOT NULL, sign_up_stamp
int(11)非空,
last_sign_in_stamp
int(11) NOT NULL, last_sign_in_stamp
int(11)非空,
company
varchar(50) DEFAULT NULL, company
varchar(50)默认为NULL,
address_1
varchar(50) NOT NULL, address_1
varchar(50)NOT NULL,
address_2
varchar(50) NOT NULL, address_2
varchar(50)NOT NULL,
city
varchar(50) NOT NULL, city
varchar(50)NOT NULL,
state
varchar(20) NOT NULL, state
varchar(20)NOT NULL,
zip
int(5) NOT NULL, zip
int(5)NOT NULL,
paid
tinyint(1) NOT NULL, paid
tinyint(1)NOT NULL,
first_name
varchar(50) NOT NULL, first_name
varchar(50)NOT NULL,
last_name
varchar(50) NOT NULL last_name
varchar(50)非空
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ; )ENGINE = InnoDB DEFAULT CHARSET = utf8 AUTO_INCREMENT = 3;
The field Company
on your table not allowing NULL
values, but Your'e sending it null
as I see in Your question ( print_r($this) section ). 您表上的字段
Company
不允许NULL
值,但是您将其发送为null
正如我在您的问题(print_r($ this)部分)中看到的那样。
So You have 2 ways to solve this problem, 因此,您有2种方法可以解决此问题,
company
field in database, and allow NULLs for it. company
字段,并允许使用NULL。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.