I have searched every single one of these forms, however I still cant figure this out. I've been stuck on it for hours.
Here is my code
<?php
//$success = 0;
//process login form if submitted
error_reporting(E_ALL);
ini_set('display_errors', 1);
if(isset($_POST['profileSubmit']))
{
if (empty(($_POST['first_name']) || ($_POST['last_name']) ||
($_POST['age']) || ($_POST['mobile']) || ($_POST['location']) ||
($_POST['email']) || ($_POST['password']) ||($_POST['verify_password'])))
{
$error[] = "Please fill out all fields";
}
if (($_POST['password']) != ($_POST['verify_password']))
{
$error[] = "Please make sure your password matches";
}
else
{
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$age = $_POST['age'];
$mobile = $_POST['mobile'];
$location = $_POST['location'];
$email= $_POST['email'];
$password = ($_POST['password']);
$username= 'username1';
$sql='SELECT username FROM Accounts WHERE username=?';
$stmt=$conn->prepare($sql);
$stmt->bind_param('s',$username);
$stmt->execute();
$stmt->bind_result( $found );
$stmt->fetch();
if($found)
{
$hashed_password = password_hash($_POST['password'], PASSWORD_DEFAULT);
$hash = substr( $hashed_password, 0, 60 );
$sqli= 'UPDATE Accounts SET first_name= ?';
$stmt=$conn->prepare( $sqli );
echo $conn->error;
$stmt->bind_param('s',$first_name);
$success = "Your Profile has been Updated Successfully";
$stmt->execute();
$stmt->close();
}
}
}
When I run this I get Fatal error: Call to a member function bind_param() on boolean. I dont understand why my prepare is failing.. It is failing on $stmt->bind_param('s',$first_name);
Also this is the config code.
enter $db_name="stockTest";
$server_name = "localhost";
$username = "root";
$password = "";
// Create connection
$conn = new mysqli($server_name,$username, $password,$db_name);
///Check connection
if ($conn->connect_error)
{
echo $conn->error;
die("Connection failed: " . $conn->connect_error);
}
Thank you