1

this my php code for the insert when i insert a data in the formulaire ----> Fatal error: Uncaught Error: Call to a member function bind_param() on bool in... what should i do to insert a différent data in différent table with joining this table in a view " colisvue"

<?php

error_reporting(E_ALL);
ini_set("display_errors", 1);


$nom_produit = $_POST['nom_produit'];
$quantite_p = $_POST['quantite_p'];
$prix_t = $_POST['prix_t'];
$id_colis = $_POST['id_colis'];
$note_colis = $_POST['note_colis'];
$numtele = $_POST['numtele'];
$adresse_livraison = $_POST['adresse_livraison'];
$wilaya = $_POST['wilaya'];
$commune = $_POST['commune'];
$date_livraison = $_POST['date_livraison'];



$conn= new mysqli('localhost','root','','ls');
if($conn->connect_error){
    die('Connection Failed : '.$conn->connect_error) ; 
}else{
    
    $stmt = $conn->prepare("insert into colisvue(nom_produit,quantite_p) values(?, ?) "|| "insert into colisvue(c.id_colis,c.note_colis,c.prix_t) values(?, ?, ?)"||"insert into colisvue(umtele,wilaya,commune) values(?, ?, ?)"||"insert into colisvue(adresse_livraison,date_livraison) values(?, ?)");
    
  
    $stmt->bind_param("sissiisssi",$nom_produit, $quantite_p, $id_colis,$note_colis,$prix_t, $numtele,$wilaya,$commune,$adresse_livraison,$date_livraison);
  
    $stmt->execute();
    
    echo"registration succesfull"; 
    $stmt->close();
    $conn->close();
 
}
?>

this is how a had create the view :

CREATE VIEW colisvue (nom_produit,quantite_p,prix_t,id_colis,note_colis,numtele,adresse_livraison,wilaya,commune,date_livraison) as SELECT p.nom_produit,p.quantite_p,c.prix_t,c.id_colis,c.note_colis,f.numtele,l.adresse_livraison,f.wilaya,f.commune,l.date_livraison FROM produit p,colis c,fournisseur f,livraison l,livreur lv WHERE c.id_fournisseur=f.id_fournisseur and p.id_colis=c.id_colis and l.id_colis=c.id_colis and c.loginname=lv.loginname

please help me cause i realy search in all websites :/

  • If you want to insert the data into 4 tables then you require 4 separate prepared statements. You can't use logical OR on strings. – Dharman Aug 25 '21 at 10:22

1 Answers1

0

This error Fatal error: Uncaught Error: Call to a member function bind_param() on bool in... is quite cryptic, but pretty much means that your SQL query failed to execute.

You should check this page as the top answer covers how to get more specific errors which can help you to find the problem:

mysqli_fetch_assoc() expects parameter / Call to a member function bind_param() errors. How to get the actual mysql error and fix it?

Secondly, just make sure your query fits the following structure: (Replace columnname with the name of your column and tablename with the name of your table)

CREATE VIEW [columnname tablename] AS
SELECT (what to select whether it is * or a specific 
column/s)
FROM tablename
WHERE columnname = '(whatever you are trying to retrieve)';

Also make sure all your table names and column names are typed correctly.

Matthias
  • 170
  • 15