0

Any idea what happened here?

$stmt = $con->prepare("INSERT INTO `users` (`FirstName`, `LastName`, `Email`, `Password`, `DateOf_Birth`, `DateOf_Create`, `Gender`, `City`, `Country`, `Status`, `Validation`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) LIMIT 1");
    $stmt->bind_param('ssssiisssis', $Firstname, $Lastname, $Email, $Password, $Birth_day, $DateNOW, $Gender, $City, $Country, $Status, $Validation);

Every column and table name is correct, I checked it several times now. Whats wrong then?

I get this error code : PHP Fatal error: Call to a member function bind_param() on boolean

1 Answers1

0

LIMIT doesn't go on an insert query because insert will just execute once. If you want to execute it more than once you need a loop (while, for, foreach). So you have to delete "LIMIT 1".

Check this line (sign error `` and LIMIT included):

$stmt = $con->prepare("INSERT INTO `users` (`FirstName`, `LastName`, `Email`, `Password`, `DateOf_Birth`, `DateOf_Create`, `Gender`, `City`, `Country`, `Status`, `Validation`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) LIMIT 1");

It must be this way (sign fixed '' without LIMIT):

$stmt = $con->prepare("INSERT INTO 'users' ('FirstName', 'LastName', 'Email', 'Password', 'DateOf_Birth', 'DateOf_Create', 'Gender', 'City', 'Country', 'Status', 'Validation') VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");

Check this line (12 parameters but just 11 to bind in your sql):

$stmt->bind_param('ssssiisssis', $Firstname, $Lastname, $Email, $Password, $Birth_day, $DateNOW, $Gender, $City, $Country, $Status, $Validation);

it must be this way (fixed 11 parameters= 11 values on $sql):

$stmt->bind_param($Firstname, $Lastname, $Email, $Password, $Birth_day, $DateNOW, $Gender, $City, $Country, $Status, $Validation);

You must check this too:

A) Your string connection $con to ensure you have the right values. Check if you are truly connecting to mysqli

B) Table name and column names are right, see if they don't have any typo (because the error has to do with boolean value)

Art_Code
  • 513
  • 4
  • 12