2016-04-15 83 views
0

我花了几个小时的故障排除试图找到错误,但我,对我而言,无法找到它。不能写数据到数据库

我想插入数据到我的MySQL数据库,它不会工作。 我没有得到任何错误,也不知道如何修改我的代码来获得一个。

这是我PHP代码

// write new users data into database 
$query_new_user_insert = $this->db_connection->prepare('INSERT INTO users (user_name, user_first, user_last, user_icon, user_password_hash, user_email, user_activation_hash, user_registration_ip, user_registration_datetime) VALUES(:user_name, :user_first, :user_last, :user_icon, :user_password_hash, :user_email, :user_activation_hash, :user_registration_ip, now())'); 
$query_new_user_insert->bindValue(':user_name', $user_name, PDO::PARAM_STR); 
$query_new_user_insert->bindValue(':user_first', $user_first, PDO::PARAM_STR); 
$query_new_user_insert->bindValue(':user_last', $user_last, PDO::PARAM_STR); 
$query_new_user_insert->bindValue(':user_icon', $user_icon, PDO::PARAM_STR); 
$query_new_user_insert->bindValue(':user_password_hash', $user_password_hash, PDO::PARAM_STR); 
$query_new_user_insert->bindValue(':user_email', $user_email, PDO::PARAM_STR); 
$query_new_user_insert->bindValue(':user_activation_hash', $user_activation_hash, PDO::PARAM_STR); 
$query_new_user_insert->bindValue(':user_registration_ip', $_SERVER['REMOTE_ADDR'], PDO::PARAM_STR); 
$query_new_user_insert->execute(); 

当我执行上面的代码,收到此错误:

array (size=3) 
    0 => string '00000' (length=5) 
    1 => null 
    2 => null 

什么是错误的意思是,我该如何解决?

我不知道你还需要什么代码,所以如果有另一个你想要的部分,让我知道。

+1

你得到了什么类型的错误? –

+0

最新错误?我们不知道告诉我们。只需打开错误报告 – Ghost

+0

我将如何打开错误报告?我收到了其他的错误,但没有收到任何错误。 @Ghost – TheWebDev

回答

0

我已经找到了问题。我的sql数据库没有没有提交的行的默认值。

0

添加下面的代码行

define("HASH_COST_FACTOR", "10"); 

为了支持代码

$hash_cost_factor = (defined('HASH_COST_FACTOR') ? HASH_COST_FACTOR : null);