删除查询正在执行,但记录已删除且 table 为空
Delete Query is executing however record is deleted and table is empty
每次 "Removed!!!" 都是结果.... $na 在 au.php 中声明...也许 DELETE 查询可能有问题..
<?php
date_default_timezone_set('Asia/KolKata');
$xyz = date(DATE_RFC2822);
include "../au.php";
$conn = mysql_connect('localhost', 'local', 'local');
mysql_select_db('sol_index', $conn);
$sid = $_GET['sid'];
$qqq = "SELECT * FROM $sid WHERE (one = '$na' AND three = 'liked')";
if (mysql_query($qqq)){
mysql_query("DELETE FROM $sid WHERE (one='$na' AND three='liked')");
echo "Removed!!!";
} else {
mysql_query("INSERT INTO $sid (one, three) VALUES ('$na', 'liked')");
echo "Liked!!!";
}
?>
感谢您的配合和帮助!!
Each time "Removed!!!" is the result
没错。
$qqq = "SELECT * FROM $sid WHERE (one = '$na' AND three = 'liked')";
if (mysql_query($qqq)){
mysql_query("DELETE FROM $sid WHERE (one='$na' AND three='liked')");
echo "Removed!!!";
}
那个if
是不正确的,只要查询有效,它总是return真,即使没有数据。您需要 运行 检查记录数量或记录本身,而不仅仅是执行。例如,您必须从该结果中获取数据并 运行 您对此进行检查。
How can I prevent SQL injection in PHP?
每次 "Removed!!!" 都是结果.... $na 在 au.php 中声明...也许 DELETE 查询可能有问题..
<?php
date_default_timezone_set('Asia/KolKata');
$xyz = date(DATE_RFC2822);
include "../au.php";
$conn = mysql_connect('localhost', 'local', 'local');
mysql_select_db('sol_index', $conn);
$sid = $_GET['sid'];
$qqq = "SELECT * FROM $sid WHERE (one = '$na' AND three = 'liked')";
if (mysql_query($qqq)){
mysql_query("DELETE FROM $sid WHERE (one='$na' AND three='liked')");
echo "Removed!!!";
} else {
mysql_query("INSERT INTO $sid (one, three) VALUES ('$na', 'liked')");
echo "Liked!!!";
}
?>
感谢您的配合和帮助!!
Each time "Removed!!!" is the result
没错。
$qqq = "SELECT * FROM $sid WHERE (one = '$na' AND three = 'liked')";
if (mysql_query($qqq)){
mysql_query("DELETE FROM $sid WHERE (one='$na' AND three='liked')");
echo "Removed!!!";
}
那个if
是不正确的,只要查询有效,它总是return真,即使没有数据。您需要 运行 检查记录数量或记录本身,而不仅仅是执行。例如,您必须从该结果中获取数据并 运行 您对此进行检查。
How can I prevent SQL injection in PHP?