我试图通过使用php文件从mysql数据库中删除条目,并且由于某种原因它不起作用。连接(在" connect.php")工作,因为我使用相同的文件为我的SELECT语句和那些工作。我只是在删除它们时遇到了麻烦。我有什么想法,我做错了什么? 提前谢谢!
<?php
include "include/connect.php";
if($link === false){
die("ERROR: Could not connect. " . mysql_connect_error());
}
$word = (isset($_GET['email']) ? $_GET['email'] : null);
$sql = "DELETE * from tbl_sbs WHERE eml='" . word . "'";
$result = mysql_query($sql);
?>
答案 0 :(得分:3)
public class MActivity extends Activity {
private ImageAdapter adapter;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.grid_layout);
GridView gridView = (GridView) findViewById(R.id.grid_view);
this.adapter = new ImageAdapter(this);
gridView.setAdapter(this.adapter);
}
public ImageAdapter getImageAdapter(){
return this.adapter;
}
}
语句不使用*
或列名,除非在DELETE
子句中用于过滤目的与WHERE
语句相同。它应该只是
SELECT
$sql = "DELETE from tbl_sbs";
一般语法是
DELETE
所以,在你的情况下它应该只是
DELETE FROM TABLE_NAME WHERE COLUMN_NAME <comparison_operator> SOME_FILTER_CONDITION
错误报告会抛出一个未定义的常量字通知; IF ,这不是$sql = "DELETE FROM tbl_sbs WHERE eml='" . $word . "'";
中的拼写错误。
'" . word . "'
并且检查过错误,会引发以下情况:
您的SQL语法有错误;检查与MySQL服务器版本对应的手册,以便在'*
附近使用正确的语法
参考文献:
答案 1 :(得分:1)
你必须在变量名(word)之前使用$
$sql = "DELETE from tbl_sbs WHERE eml='" . $word . "'";