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