Ciao,
questo codice sembra ok, la connessione è corretta e anche la stringa sql, ma sulla delete mi dà:
"Error deleting record: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 1". Ho provato altre sintassi ma da sempre questo errore.( Line 1non è chiaro...).
Qualche dritta?
Grazie mille
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "dbname";
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// sql to delete a record
$sql = "DELETE FROM table_name WHERE user_id = $user_id";
if ($conn->query($sql) === TRUE) {
echo "Record deleted successfully";
} else {
echo "Error deleting record: " . $conn->error;
}
$conn->close();
?>