Error in php connection file for mysql database

Asked

Viewed 49 times

1

Mistakes:

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 the error is on line 7 and 8. Why does it appear? What’s the problem?

  • how I perform this test?

  • I made the changes and returned this error: NULL NULL PHP Error Message Warning: mysqli_stmt_bind_param() expects Parameter 1 to be mysqli_stmt, Boolean Given in /home/a9630388/public_html/Register.php on line 10 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 11 Free Web Hosting {"Success":true}

  • yes, I wrote them

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.

Soon, you must replace: mysqli_stmt_bind_param($statement, "siss", $email, $senha);

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

Also, if when executing var_dump($_POST); is returning array(0) { }, indicates that the data is not being posted and for this reason your code continues to show error.

  • fixed and still the problem persists!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.