Home  >  Article  >  Backend Development  >  这么删除不了数据。确提示删除成功,汗

这么删除不了数据。确提示删除成功,汗

WBOY
WBOYOriginal
2016-06-13 13:16:22801browse

这样删除不了数据。确提示删除成功,汗

PHP code
<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--><?php session_start();
if($_SESSION[name]==""){
    exit();
}
include "img/ddddd.php";
$ming=$_SESSION[name];
$shan=$_GET["num"];
echo $shan;
$sql=mysql_query("delete from `readuser` where `falsename`='$shan' and `username`='$ming'");
if($sql){
echo "<script>alert('删除成功');window.history.go(-1);";
}
?>



------解决方案--------------------
$shan 和 $ming 都取到值了? 

数据库中确定有这条数据?
------解决方案--------------------
数据库 的编码确认正确?
探讨

算了,改删id算了。这个我解决了。还有个问题啊。我所有编码都统一的 utf8_general_ci 网页到数据库,及数据库连接 都是utf-8 可是写入MYSQL的汉子还是乱码 不知道怎么回事

------解决方案--------------------
1、$sql=mysql_query("delete from `readuser` where `falsename`='$shan' and `username`='$ming'");
if($sql){ //这里只表示SQL指令没有错误,并不表示删除成功了

2、算了,改删id算了。这个我解决了。
并没有解决!你只是回避了按内容查询时的问题

3、我所有编码都统一的 utf8_general_ci 网页到数据库,及数据库连接 都是utf-8 可是写入MYSQL的汉子还是乱码
修改字符集之前的数据依然是“乱码”的,不知你注意了没有
mysql_query("set names utf8"); 只是告知mysql其后的数据是utf-8编码的,但实际是用的什么字符集,那只有天知道了
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn