所以我正在使用UserCake开发一个项目。我在'users'表中添加了字段。到目前为止,一切都很好。我遇到的问题是当你注册时,它返回成功,但SQL语句没有将任何表单数据放入数据库。
到目前为止,我已成功添加必要的字段,并且我能够从这些字段中提取数据,但是,我无法将数据推送到数据库。我有一种感觉它与bind_param语句有关,但我不确定。这是我正在处理的事情:
编辑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();
编辑>>>解决了空阵列问题
我正在调用这样的新用户: $ user = new用户($ password,$ email,$ token,$ activationRequest,$ passwordRequest,$ active,$ title,$ signUp,$ signIn,$ company,$ address_1,$ address_2,$ city,$ state,$ zip ,$ paid,$ first_name,$ last_name);
编辑>>>
表格1}} (
uc_users
int(11)NOT NULL,
id
varchar(225)NOT NULL,
password
varchar(150)NOT NULL,
email
varchar(225)NOT NULL,
activation_token
int(11)NOT NULL,
last_activation_request
tinyint(1)NOT NULL,
lost_password_request
tinyint(1)NOT NULL,
active
varchar(150)NOT NULL,
title
int(11)NOT NULL,
sign_up_stamp
int(11)NOT NULL,
last_sign_in_stamp
varchar(50)DEFAULT NULL,
company
varchar(50)NOT NULL,
address_1
varchar(50)NOT NULL,
address_2
varchar(50)NOT NULL,
city
varchar(20)NOT NULL,
state
int(5)NOT NULL,
zip
tinyint(1)NOT NULL,
paid
varchar(50)NOT NULL,
first_name
varchar(50)NOT NULL
)ENGINE = InnoDB DEFAULT CHARSET = utf8 AUTO_INCREMENT = 3;
答案 0 :(得分:0)
您桌面上的字段Company
不允许NULL
值,但您正在我的问题(print_r($ this)部分)中发送null
。
所以你有2种方法可以解决这个问题,
company
字段,并为其允许NULL。