Salve a tutti,
ho un problema che non riesco a capire con php e mysql:
Apro una pagina php da un form con POST settato. La variabile POST contiene un array di ID di tabella che devo cancellare, quindi procedo così:
Lo script esce dandomi errore: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE id = 43' at line 1;Codice PHP:
if(isset($_POST['rows']) and is_array($_POST['rows'])) {
foreach($_POST['rows'] as $value) {
$row = (int)($value);
$query = mysql_query("DELETE FROM tabella WHERE id = " . $row);
}
}
come si può spiegare? Se faccio da linea di comando: DELETE FROM tabella WHERE id = 43; il comando funziona. Qualcuno saprebbe aiutarmi?
Vi ringrazio anticipatamente.