Я пытаюсь вставить новую строку в мою БД через php7.
Mysqli выдает ошибку
Column 'newsletter' cannot be null
Столбец новостной рассылки в базе данных - tinyint (1)
![The database structure](https://i.stack.imgur.com/flAtt.png)
Вот код:
public function Add_User(array $data) {
if( !isset($data['name']) || !isset($data['email']) || !isset($data['newsletter']) )
$optin = ( $data['newsletter'] === 'on' ) ? 1 : 0;
$country_code = $this->Get_Country_Code();
if( !$q = $this->_db->prepare("INSERT INTO `users` (`name`,`email`,`country_code`,`newsletter`) VALUES (?,?,?,?)") ) { printf('error on prepare'); }
if( !$q->bind_param('sssi', $data['name'], $data['email'], $country_code, $optin)) { printf('error on bind'); }
if( !$q->execute() ) { printf('error on execute'); }
printf('Insert error %s', $this->_db->error);
if( $this->_db->affected_rows == 0 ) {
// There was a problem with the insert
printf('Insert error %s', $this->_db->error);
}
$q->close();
}
Я также попытался добавить логическое значение в виде строки, но оно все равно не сработало.
Заранее спасибо.