因此,我正在使用UserCake进行一个项目。我已经将字段添加到“用户”表中。到目前为止,一切都很顺利。我遇到的问题是,当您注册时,它返回成功,但SQL语句没有将任何表单数据放入数据库。
到目前为止,我已经成功地添加了必要的字段,并且能够从这些字段中提取数据,但是,我无法将数据推送到数据库中。我有一种感觉,这与bind_param声明有关,但我不确定。我现在要面对的是:
编辑9/30下午5点>>>的唯一问题是,数据没有被放入表中。
$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 =新用户($password、$email、$token、$activationRequest、$passwordRequest、$active、$title、$signUp、$signIn、$company、$address_1、$address_2、$city、$state、$zip、$paid、$state、$zip、$paid、$state、$state);
编辑>>>表uc_users ( id int(11) NOT NULL,password varchar(225) NULL),
email varchar(150)不为空,
activation_token varchar(225)不为空,
last_activation_request int(11) NULL
lost_password_request tinyint(1) NULL
active tinyint(1) NULL
title varchar(150)不为空,
sign_up_stamp int(11) NULL
last_sign_in_stamp int(11) NULL
company varchar(50)默认为空,
address_1 varchar(50)不为空,
address_2 varchar(50)不为空,
city varchar(50)不为空,
state varchar(20)不为空,
zip int(5) NULL
paid tinyint(1) NULL
first_name varchar(50)不为空,
last_name varchar(50)不为空
) ENGINE=InnoDB默认CHARSET=utf8 AUTO_INCREMENT=3;
发布于 2014-09-30 20:23:47
您的表上的字段Company不允许NULL值,但是您的“正在发送null”,正如我在“问题”( print_r($this)部分)中看到的那样。
所以你有两种方法来解决这个问题
company字段,并允许对其使用NULL。https://stackoverflow.com/questions/26128928
复制相似问题