U kunt uw SQL wijzigen in...
//THIS IS BETTER BUT DONT USE THIS
$qry = "ALTER IGNORE TABLE {$table} ADD {$column} VARCHAR(20);"
Gebruik in plaats daarvan PHP PDO of MySQLi met voorbereide statements.In plaats van die legacy horror met aaneengeschakelde unescaped strings.
MySQLi-oplossing:
$mysqli = new mysqli($cfg->host, $cfg->user, $cfg->password, $cfg->db);
if ($mysqli->connect_errno) {
echo 'Connect failed: ', $mysqli->connect_error, '" }';
exit();
}
if ($stmt = $mysqli->prepare("ALTER IGNORE TABLE ? ADD ? VARCHAR(20);")) {
$stmt->bind_param("ss", $table, $column);
$stmt->execute();
$stmt->close();
}
$mysqli->close();