I cannot save in my db using prepared statements. I don't know what the problem is with this code:
$stmt3 = $this->db->prapare("INSERT INTO criminal(investigation, isFujitive, suspect_id) VALUES (?, ?, ?)");
$stmt3->bind_param('sii', $lastSeen[$i], $isFujitive[$i], $id);
if ($stmt3->execute()){
echo "Working";
}
I checked already if the db is empty using this code:
$db = $this->db;
if(empty($db)){
$this->connect();
$db = $this->db;
}
But then again there is no output and cannot save in db.
You should try this:
$stmt3 = $this->db->prepare("INSERT INTO criminal(investigation, isFujitive, suspect_id) VALUES (?, ?, ?)");
if ($stmt3->execute(array($lastSeen[$i], $isFujitive[$i], $id)){
echo "Working";
}
Either one will work
$stmt3 = $this->db->prepare("INSERT INTO criminal(investigation, isFujitive, suspect_id) VALUES (?, ?, ?)");
$stmt3->bindParam(1, $lastSeen[$i]);
$stmt3->bindParam(2, $isFujitive[$i]);
$stmt3->bindParam(3, $id);
$stmt3->execute();
Or
$stmt3 = $this->db->prepare("INSERT INTO criminal(investigation, isFujitive, suspect_id) VALUES (:inv, :fuj, :sus)");
$stmt3->bindParam('inv', $lastSeen[$i]);
$stmt3->bindParam('fuj', $isFujitive[$i]);
$stmt3->bindParam('sus', $id);
$stmt3->execute();
Or
$stmt3 = $this->db->prepare("INSERT INTO criminal(investigation, isFujitive, suspect_id) VALUES (?, ?, ?)");
$stmt3->execute(array($lastSeen[$i], $isFujitive[$i], $id));
Luca