0
我有一個表單,用戶在進一步繼續之前需要解決他們自己的安全問題。我的形式如下:SQL語句不返回任何內容
<form action="securitychecked.php" method="post">
<table width="70%" border="0">
<tr>
<td><?php $result = mysql_query("SELECT secret_question FROM public WHERE active = 'activated' AND ni = '". $_SESSION['ni']."'")
or die(mysql_error());
if (mysql_num_rows($result) == 0) {
echo '<hr><h4>This Person Has Not Setup A Security Question</h4><hr> ';
} else {
while($info = mysql_fetch_array($result))
{
echo $info['secret_question'];
}
}?></td>
<td><span id="sprytextfield1">
<input type="text" name="secret_answer" id="secret_answer" />
<span class="textfieldRequiredMsg">*</span></span></td>
</tr>
<tr>
<td> </td>
<td><br /><input name="" type="submit" value="Continue" /></td>
</tr>
</table>
</form>
我的PHP代碼如下所示:
<?php
$secret_anwser=$_POST['secret_anwser'];
$secret_anwser = stripslashes($secret_anwser);
$secret_anwser = mysql_real_escape_string($secret_anwser);
$sql="SELECT secret_anwser FROM public WHERE secret_anwser ='$secret_anwser' AND active = 'activated' AND ni = '". $_SESSION['ni']."'";
$result=mysql_query($sql);
// Mysql_num_row is counting table row
$count=mysql_num_rows($result);
if($count==1){
header("location:votenow.php");
}
?>
我呼籲公衆表和字段名爲「secret_anwser」,但我一直得到一個空白頁,即使輸入正確的值。誰能幫我?
感謝
[PHP程序員的調試技巧](http://www.ibm.com/developerworks/library/os-debug/) – webbiedave 2012-02-24 23:38:12
您是否在執行sql stmt時選擇了正確的目錄(db名稱)? – 2012-02-24 23:39:16
是的,我沒有選擇正確的數據庫名稱 – 2012-02-24 23:39:49