Reputation: 137
I am having a problem when inserting data into MySQL. This is the error, and i can't find the solution. Wheres the phpmyadmin camps and certains names in :
PHPMYADMIN - NAME:
Register.php: (<form action="registo.php" method="get">
)
<button type="submit" name="submit">Enviar</button>
</form>
<?php
if(isset($_GET['submit'])){
$date = mysql_real_escape_string($_GET['data']);
$date = date('Y-m-d', strtotime(str_replace('-', '/', $date)));
$inst=mysqli_prepare($connect,"INSERT INTO cliente(email, password, nome, pais, contribuinte, endereco, codpostal, localidade, data_de_nascimento) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)");
$pw_hash=password_hash($_GET['pass1'], PASSWORD_DEFAULT);
$inst->bind_param("ssssissss", $_GET['email'], $pw_hash, $GET_['nome'], $_GET['pais'], $GET_['n_contribuinte'], $GET_['morada'], $GET_['codpostal'], $GET_['localidade'], $date);
if($inst->execute()==TRUE){
echo '<p>Registo efetuado com sucesso</p>';
}
else print_r($inst);
}
?>
EDIT: (print_r($inst);
)
mysqli_stmt Object
(
[affected_rows] => -1
[insert_id] => 0
[num_rows] => 0
[param_count] => 9
[field_count] => 0
[errno] => 1048
[error] => Column 'nome' cannot be null
[error_list] => Array(
[0] => Array(
[errno] => 1048
[sqlstate] => 23000
[error] => Column 'nome' cannot be null
)
)
[sqlstate] => 23000
[id] => 1
)
But name is with string on input.
Upvotes: 1
Views: 1675
Reputation: 961
From what I can see is you have a typo in the bind_param
section of your code.
What you have:
$inst->bind_param("ssssissss", $_GET['email'], $pw_hash, $GET_['nome'], $_GET['pais'], $GET_['n_contribuinte'], $GET_['morada'], $GET_['codpostal'], $GET_['localidade'], $date);
You are calling $GET_['nome']
instead of $_GET['nome']
. Notice the underscore in the wrong place. Which is why the value isn't being pulled in.
Same with $GET_['n_contribuinte']
, $GET_['morada']
, $GET_['codpostal']
and $GET_['localidade']
.
Upvotes: 1