插入不工作的成员

时间:2018-01-28 12:22:26

标签: php sql

我有一个正在运行和运行的脚本,但是插入成员部分不能正常工作:

function register_member($username,$name,$email,$password) {
$time = time();
$ip = get_ip();
db()->query("INSERT INTO members (full_name,username,email,password,ip_address,last_active,date_created,banned,active)VALUES(?,?,?,?,?,?,?,?,?)",
    $name,$username,$email,$password, $ip, $time, $time,0,1);
//login user

login_user($username, $pass, false);

if (config('auto-follow', '')) {
    $users = explode(',', config('auto-follow'));
    foreach($users as $user){
        $user = get_user($user);
        if ($user) {
            follow($user['id']);
        }
    }
}
return true;

}

对我而言,它似乎无法读取db() - >查询(" INSERT INTO部分。当我删除该查询时,注册脚本可以完成读取功能,但如果我保留它,它返回500内部错误。任何想法?

2 个答案:

答案 0 :(得分:0)

最后让php.ini改变了,并且在js脚本中发生了错误。在这一行:var json = jQuery.parseJSON(result);

$(document).on("submit", "#signup-form", function() {
    $(".loader-container").fadeIn();
    $(this).ajaxSubmit({
        url : baseUrl + 'signup',
        success : function(result) {
            var json = jQuery.parseJSON(result);
            if (json.status == 1) {
                //we can redirect to the next destination
                window.location.href = json.url;
                notify(json.message, 'success');
            } else {
                notify(json.message, 'error');
                $(".loader-container").fadeOut();
            }
        }
    })
    return false;
});    

答案 1 :(得分:0)

获得更多调试工具后,我发现了这个:

    <head/><br/>
<b>Fatal error</b>:  Uncaught PDOException: SQLSTATE[HY000]: General error: 1364 Field 'bio' doesn't have a default value in /opt/bitnami/apache2/htdocs/includes/application.php:630
Stack trace:
#0 /opt/bitnami/apache2/htdocs/includes/application.php(630): PDOStatement-&gt;execute(Array)
#1 /opt/bitnami/apache2/htdocs/includes/models/user.php(62): Database-&gt;query('INSERT INTO mem...', 'a', 'a', 'arnfinn79@gmail...', '$2y$10$SXogMoKt...', '92.221.162.43', 1517160199, 1517160199, 0, 1)
#2 /opt/bitnami/apache2/htdocs/includes/controllers/HomeController.php(86): register_member('a', 'a', 'arnfinn79@gmail...', 'aizy7910')
#3 /opt/bitnami/apache2/htdocs/includes/application.php(878): HomeController-&gt;signup()
#4 /opt/bitnami/apache2/htdocs/includes/application.php(809): Router::load(Object(Route))
#5 /opt/bitnami/apache2/htdocs/includes/application.php(37): Router::run()
#6 /opt/bitnami/apache2/htdocs/index.php(19): Application-&gt;run()
#7 {main}
  thrown in <b>/opt/bitnami/apache2/htdocs/includes/application.php</b> on line <b>630</b><br/>

然而,在那一行我只得到了这个:$ response-&gt; execute($ args);