有人可以帮助我在用户退出时从sql表中删除用户数据吗?
我的退出文件是:
<?php
//Start session
session_start();
include('config.php');
require_once('delete.php');
//Unset the variables stored in session
unset($_SESSION['SESS_MEMBER_ID']);
unset($_SESSION['SESS_FIRST_NAME']);
unset($_SESSION['SESS_LAST_NAME']);?>
开头所需的删除文件应该用空值替换用户值,因为我无法删除它们,也... ...
删除文件是:
<?php
//Start session
session_start();
include('config.php');
$login= $_POST['username'];
$password= $_POST['password'];
mysql_query("UPDATE registo SET username='' AND password='' WHERE username='$login' AND password='$password'");
{
echo "Deleted Successfully";
}?>
请帮忙!
答案 0 :(得分:0)
UPDATE
子句的语法是:
UPDATE [LOW_PRIORITY] [IGNORE] table_reference
SET col_name1={expr1|DEFAULT} [, col_name2={expr2|DEFAULT}] ...
[WHERE where_condition]
[ORDER BY ...]
[LIMIT row_count]
也就是说,您提供逗号分隔的列列表。
你有这个:
UPDATE registo
SET username='' AND password=''
没有逗号,所以你告诉MySQL只更新一列:username
。新值为'' AND password=''
。那是零:
mysql> SELECT '' AND password='' FROM registo;
+--------------------+
| '' AND password='' |
+--------------------+
| 0 |
+--------------------+
1 row in set (0.00 sec)
因此,您的代码等于:
UPDATE registo
SET username=0
你可能是这个意思:
UPDATE registo
SET username=NULL, password=NULL