关于pdo的一个疑问
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->if (isset($_POST['loginName']) && isset($_POST['pwd']) && $_POST['action'] == 'submit') { $loginName = $_POST['loginName']; $pwd = $_POST['pwd']; echo $loginName.' '.$pwd; $sql = "SELECT COUNT(*) FROM tb_esq WHERE login_name = :loginName AND pwd = :pwd"; require_once ('conn.php'); $sth = $db->prepare($sql); $sth->bindParam(':loginName', $loginName, PDO::PARAM_STR, 25); $sth->bindParam(':pwd', $pwd, PDO::PARAM_STR, 25); $sth->execute(); $rowCount = $sth->fetchColumn(); var_dump($rowCount);//一直是0 $db = NULL; if ($rowCount == 1) { echo "<script>window.location=\"index.html\";</script>"; } else { alert('用户名或密码错误!'); echo "<script>window.location=\"login.php\";</script>"; }}
$sql = "SELECT COUNT(*) FROM tb_esq WHERE login_name = '$loginName' AND pwd = '$pwd'";$result = $db->query($sql);$row = $result->fetch(PDO::FETCH_ASSOC);print_r($row);<div class="clear"> </div>