Home > Backend Development > PHP Tutorial > 读写数据库的有关问题

读写数据库的有关问题

WBOY
Release: 2016-06-13 10:10:09
Original
622 people have browsed it

读写数据库的问题

PHP code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--><?require_once ("session.php");$web_root_part = "../";require_once($web_root_part."lib/db.php");require_once($web_root_part."lib/function.php");header('Content-type:text/html;charset=utf-8');   $AdminID = trim($_POST['AdminID']);$PassWord = trim($_POST['PassWord']);$Addtime = date("Y-m-d H:i:s");$querySel = "select * from Admin where AdminID='".$AdminID."'";if( !($result = $db->sql_query($querySel)) ){    message_die(DB_MESSAGE, 'Could not query Admin');        }else{        $row = $db->sql_fetchrow($result);        //$db->sql_freeresult($result);            if (empty($row['ID'])){                $sql="insert into Admin (AdminID,PassWord,Editer,Addtime) values('".$AdminID."','".md5($PassWord)."','".$_SESSION['AdminID']."','".$Addtime."')";        if( !($result = $db->sql_query($sql)) )        {            //echo $sql;            message_die(DB_MESSAGE, 'Could not query Admin');                        }else{                              echo "<script>location.replace('admin.php');</script>";            }                }else{                echo "<script language="Javascript">";        echo "alert('提示:管理员ID已存在,请重新输入!');";        echo "history.go(-1);";        echo "</script>";     }}        ?>
Copy after login


这个代码那里有问题呢? 怎么不管理员ID 有没有重复 都提示 管理员ID已存在,请重新输入 呢

------解决方案--------------------
代码看不出哪儿有问题,你的测试是否准确?
至于你说的$row['ID']没被清除,应该说不可能
------解决方案--------------------
把以下代码换成print_r($row);做调试,如果还有问题,把调试出来的结果发上来

echo "";
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template