Click here to Skip to main content
15,888,113 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
i keep on getting this error
Fatal error: Uncaught Error: Call to a member function bind_param() on bool in /Users/Tobo/Sites/prototype/connect.php:193 Stack trace: #0 {main} thrown in /Users/Tobo/Sites/prototype/connect.php on line 193

This is my code

<?php












if(isset($_POST['Documentno'])){
    $Documentno = $_POST['Documentno'];
}
if(isset($Documentno)){ 
    echo $Documentno;
}



if(isset($_POST['DocumentCategory'])){
    $DocumentCategory = $_POST['DocumentCategory'];
}
if(isset($DocumentCategory)){ 
    echo $DocumentCategory;
}


if(isset($_POST['CertificateNo'])){
    $CertificateNo = $_POST['CertificateNo'];
}
if(isset($CertificateNo)){ 
    echo $CertificateNo;
}


if(isset($_POST['Revision'])){
    $Revision = $_POST['Revision'];
}
if(isset($Revision)){ 
    echo $Revision;
}



if(isset($_POST['Duedate'])){
    $Duedate = $_POST['Duedate'];
}
if(isset($Duedate)){ 
    echo $Duedate;
}





if(isset($_POST['IMCAD018ref'])){
    $IMCAD018ref = $_POST['IMCAD018ref'];
}
if(isset($IMCAD018ref)){ 
    echo $IMCAD018ref;
}


if(isset($_POST['DESIGNAuditref'])){
    $DESIGNAuditref = $_POST['DESIGNAuditref'];
}
if(isset($DESIGNAuditref)){ 
    echo $DESIGNAuditref;
}


if(isset($_POST['Description'])){
    $Description = $_POST['Description'];
}
if(isset($Description)){ 
    echo $Description;
}


if(isset($_POST['Make'])){
    $Make = $_POST['Make'];
}
if(isset($Make)){ 
    echo $Make;
}


if(isset($_POST['AssetNumber'])){
    $AssetNumber = $_POST['AssetNumber'];
}
if(isset($AssetNumber)){ 
    echo $AssetNumber;
}


if(isset($_POST['COMMENTS'])){
    $COMMENTS = $_POST['COMMENTS'];
}
if(isset($COMMENTS)){ 
    echo $COMMENTS;
}


if(isset($_POST['TestProcedureRef'])){
    $TestProcedureRef = $_POST['TestProcedureRef'];
}
if(isset($TestProcedureRef)){ 
    echo $TestProcedureRef;
}




if(isset($_POST['PlaceofInspection'])){
    $PlaceofInspection = $_POST['PlaceofInspection'];
}
if(isset($PlaceofInspection)){ 
    echo $PlaceofInspection;
}





if(isset($_POST['DateofInspection'])){
    $DateofInspection = $_POST['DateofInspection'];
}
if(isset($DateofInspection)){ 
    echo $DateofInspection;
}



if(isset($_POST['DateofNextInspection'])){
    $DateofInspection = $_POST['DateofNextInspection'];
}
if(isset($DateofNextInspection)){ 
    echo $DateofNextInspection;
}




if(isset($_POST['TestResults'])){
    $TestResults = $_POST['TestResults'];
}
if(isset($TestResults)){ 
    echo $TestResults;
}



if(isset($_POST['Doneby'])){
    $Doneby = $_POST['Doneby'];
}
if(isset($Doneby)){ 
    echo $Doneby;
}




if(isset($_POST['Approval'])){
    $Approval = $_POST['Approval'];
}
if(isset($Approval)){ 
    echo $Approval;
}


if(isset($_POST['Date'])){
    $Date = $_POST['Date'];
}
if(isset($Date)){ 
    echo $Date;
}



	
	//. database connection code
 $conn = new mysqli('127.0.0.1', 'root', 'toboroot', 'sys');

if($conn->connect_error){
die('Connection Failed : '.$conn->connect_error);
}else{
$stmt = $conn->prepare("insert into database(Documentno, DocumentCategory, DepartmentOwner, CertificateNo, Revision, Duedate, IMCAD018ref, DESIGNAuditref, Description, Make, AssetNumber, COMMENTS, TestProcedureRef, PlaceofInspection, DateofInspection, DateofNextInspection, TestResults, Doneby, Approval, Date ) values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");


$stmt->bind_param("ssssssssssssssssssss", ['Documentno'], ['DocumentCategory'], ['DepartmentOwner'], ['CertificateNo'], ['Revision'], ['Duedate'], ['IMCAD018ref'], 
  ['DESIGNAuditref'], ['Description'], ['Make'], ['AssetNumber'], ['COMMENTS'], ['TestProcedureRef'], ['PlaceofInspection'], ['DateofInspection'], ['DateofNextInspection'], ['TestResults'], ['Doneby'], ['Approval'], ['Date']);

$stmt->execute();
	echo "Record stored";
		$stmt->close();
		$conn->close();
}
?>


What I have tried:

trying changing the quotes of the field names from 'to ` as someone suggested.didnt work
Posted
Updated 23-May-20 14:57pm

What it means is there was a problem when you ran prepare()[^]
1. Check the value of $stmt before you bind; it should be a boolean
2a. If this value is false; check the query to make sure table and columns are correct.
2b. Otherwise, you should be able to do the binding and execution.

Reference:
PHP: mysqli_stmt::prepare - Manual[^]
 
Share this answer
 
Yes it was definitely a probably when i ran prepare.

Changed insert into from lower case to upper case and database into boat, which is the name of the table and it started working .

Thanks for your help. I appreciate it
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900