Error in php connection file for database mysql

1

Errors:

  

Warning: mysqli_stmt_bind_param () expects parameter 1 to be   mysqli_stmt, boolean given in /home/a9630388/public_html/register.php    on line 7

     

Free Web Hosting

     

PHP Error Message

     

Warning: mysqli_stmt_execute () expects parameter 1 to be mysqli_stmt,   boolean given in /home/a9630388/public_html/register.php on line 8

     

Free Web Hosting {"success": true}

Code:

<?php
$con = mysqli_connect("CONFIDENCIAL");

$email = $_POST["email"];
$senha = $_POST["senha"];
$statement = mysqli_prepare($con, "INSERT INTO user (email, senha) VALUES(?, ?)");
mysqli_stmt_bind_param($statement, "siss", $email, $senha);
mysqli_stmt_execute($statement);

$response = array();
$response["success"] = true;  

echo json_encode($response);
?>

It says that the error is on line 7 and 8. Why does this appear? What is the problem?

    
asked by anonymous 22.08.2016 / 16:41

1 answer

0

A visible error is the second parameter of mysqli_stmt_bind_param >, which in your case should be "ss", representing string and string for login and password respectively.

So you should replace: mysqli_stmt_bind_param($statement, "siss", $email, $senha);

By: mysqli_stmt_bind_param($statement, "ss", $email, $senha);

In addition, if running var_dump($_POST); is returning array(0) { } , it indicates that the data is not being posted and for this reason your code continues to display error.

    
22.08.2016 / 17:18