Is there any way to write this PHP code in a secure way using Pepare statements?
$query = "TRUNCATE TABLE comments";
$result = mysqli_query($conn,$query)
or die('Error deleting table.');
}
else {
echo "Sorry cannot delete";
}
I am trying to improve my Code but the 'TRUNCATE' function of the database is giving me problems.
With this code lines it doesn’t work:
$table_commets = 'comments';
$PDOStatement_comments = $PDO->prepare("TRUNCATE TABLE $table_commets;");
$PDOStatement_comments->execute();
Is there any way to improve it using MySQLi prepare statements?
Or it is better not to use Prepare statements in the TRUNCATE function?