如何从Mysql表中删除选定的表数据

时间:2022-11-16 04:25:51

I am trying to remove selected info from a mysql table but cant see to get it correct, here is my code:

我试图从mysql表中删除选定的信息,但无法看到它是正确的,这是我的代码:

<?php
include('config.php');

$username = addslashes($_GET['username']);
$password = addslashes($_GET['password']);

mysql_query("DELETE FROM users (username, password) VALUES ('$username', '$password')");
?>

The database connection is setup in the "config.php" I know that works.

数据库连接是在“config.php”中设置的,我知道它可行。

I know it is in no way secure I just need it to work.

我知道这绝不是安全我只是需要它才能工作。

Any help is much appreciated.

任何帮助深表感谢。

Edit - I should probably say that I am trying to delete through the url.

编辑 - 我应该说我试图通过网址删除。

3 个解决方案

#1


2  

The query to delete rows should be

删除行的查询应该是

DELETE FROM users WHERE username='$username' AND password = '$password'

#2


0  

Your SQL is invalid, instead consider:

您的SQL无效,而是考虑:

DELETE FROM users WHERE username = '$username' AND password = '$password'

#3


0  

try this

<?php
include('config.php');

$username = addslashes($_GET['username']);
$password = addslashes($_GET['password']);

mysql_query("DELETE FROM users where username='$username' and password='$password'");
?>

#1


2  

The query to delete rows should be

删除行的查询应该是

DELETE FROM users WHERE username='$username' AND password = '$password'

#2


0  

Your SQL is invalid, instead consider:

您的SQL无效,而是考虑:

DELETE FROM users WHERE username = '$username' AND password = '$password'

#3


0  

try this

<?php
include('config.php');

$username = addslashes($_GET['username']);
$password = addslashes($_GET['password']);

mysql_query("DELETE FROM users where username='$username' and password='$password'");
?>