通过查询删除表列通过查询
问题描述:
我想删除具有特定标题的表列。这个查询有什么问题?如果我添加删除-URL(?与请求的称号; ...名称=)在我的网页浏览器,我得到最后的回声(错误消息)通过查询删除表列通过查询
<?php
//Getting Id
$name = $_GET['name'];
//Importing database
require_once('dbConnect.php');
//Creating sql query
$sql = "ALTER TALBE tische DROP `$name`";
//Deleting record in database
if(mysqli_query($con,$sql)){
echo 'Element erfolgreich aus Abrechnung entfernt';
}else{
echo 'Konnte Element nicht aus Abrechnung entfernen';
}
//closing connection
mysqli_close($con);
答
的语法是:ALTER TABLE table_name DROP COLUMN column_name
[Little Bobby](http://bobby-tables.com/)说*** [你的脚本存在SQL注入攻击风险。](http://stackoverflow.com/questions/60174/how-can- ***)了解[MySQLi](http://php.net/manual)[准备](http://en.wikipedia.org/wiki/Prepared_statement)声明/en/mysqli.quickstart.prepared-statements.php)。即使[转义字符串](http://stackoverflow.com/questions/5741187/sql-injection-that-gets-around-mysql-real-escape-string)是不安全的! [不相信它?](http://stackoverflow.com/q/38297105/1011527) –
你引用的值,而不是后面打勾。 ''$ name'' –
'ALTER TALBE'是错误的。 –