简体   繁体   English

SQL语句不返回任何内容

[英]SQL Statement Not Returning Anything

I have a form whereby users are required to anwser their own security question before proceeding further. 我有一张表格,要求用户在继续之前先回答自己的安全问题。 my form is as follows: 我的表格如下:

    <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>&nbsp;</td>
    <td><br /><input name="" type="submit" value="Continue" /></td>
  </tr>
</table>
</form>

my php code looks like this: 我的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");
}

?>

I have a table called public and a field called 'secret_anwser' but i keep on getting a blank page even with the right value being entered. 我有一个名为public的表,一个名为“ secret_anwser”的字段,但是即使输入正确的值,我仍会保持空白页。 can anyone help me? 谁能帮我?

thanks 谢谢

I guess all the secret_anwser in your PHP are typo's. 我猜您的PHP中所有secret_anwser都是错字。

At least the fields name is secret_answer but you try to get $_POST['secret_anwser']; 至少字段名称是secret_answer,但是您尝试获取$_POST['secret_anwser']; , you'll never find anything inside the DB. ,您将永远不会在数据库中找到任何东西。

The names of the DB and the table also may be wrong. 数据库和表的名称也可能是错误的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM