首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >MySQL 'bind_param‘语句似乎不起作用-- UserCake剪切化

MySQL 'bind_param‘语句似乎不起作用-- UserCake剪切化
EN

Stack Overflow用户
提问于 2014-09-30 19:50:25
回答 1查看 100关注 0票数 0

因此,我正在使用UserCake进行一个项目。我已经将字段添加到“用户”表中。到目前为止,一切都很顺利。我遇到的问题是,当您注册时,它返回成功,但SQL语句没有将任何表单数据放入数据库。

到目前为止,我已经成功地添加了必要的字段,并且能够从这些字段中提取数据,但是,我无法将数据推送到数据库中。我有一种感觉,这与bind_param声明有关,但我不确定。我现在要面对的是:

编辑9/30下午5点>>>的唯一问题是,数据没有被放入表中。

代码语言:javascript
复制
$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;

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-09-30 20:23:47

您的表上的字段Company不允许NULL值,但是您的“正在发送null”,正如我在“问题”( print_r($this)部分)中看到的那样。

所以你有两种方法来解决这个问题

  1. 如果您确实需要公司,请根据需要设置company字段,并在验证期间(发送查询后)检查它,这将使您远离此类问题。
  2. 否则,请更改数据库中的company字段,并允许对其使用NULL。
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26128928

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档