-2
I’m having problems in mysql when recognizing delete function
$code = '1234';
$conn = new PDO('mysql:host=localhost;dbname=data', 'root');
$stmt = $conn->prepare('SELECT * FROM codes WHERE code='.$code.'');
$stmt->execute();
$result = $stmt->fetchAll();
foreach($result as $row) {
extract($id);
$del = "DELETE FROM codes WHERE id = '".$id."'";
//$id é o id da coluna do BD
}
}
Could you be more specific about your difficulties? What flaws are you talking about?
– gato
@cat , mysql does not return anything in the DELETE function I made a var dump in the variables and they return me, but it seems that the function does not work
– David Jesus
That one
extract($id)
shouldn’t beextract($row)
? And how are you executing the commandDELETE
? In question you just defined it as string, but did not execute it.– Woss
the pq of these two closing braces } ?
– user60252
Only needed to execute $Conn->exec($del);
– user60252