Devo9 Devo9 - 1 year ago 47
PHP Question

mysqli Delete query return boolean false

i'm waching a tutorial i'm trying to delete a specific section By Id , i'm gettin Error Processing Request which is my error exception in my model and if i var_damp my query it returns boolean false idk why this not working.


public function deletesec($id)
// Delete a specific section.
$query = "DELETE * FROM $this->tablename WHERE id = '$id'";

if (!$sqli = mysqli_query($this->cxn->connect(),$query)) {

throw new Exception("Error Processing Request");

echo "Done";


//Display all data.
require_once '../model/cone.php';
require_once '../model/display.php';
$display = new Display("sections");
$data = $display->getSections();

//Delete a specific section By Id.
$id = $_GET['deleteid'];
require_once '../model/dsections.php';
$delete = new Dsections("sections");

//my view.
require_once '../view/vsections.php';

Answer Source

Change the query by removing the *

$query = "DELETE  FROM $this->tablename WHERE id = '$id'";

Also check if you require those quotes around $id