我生成了一个 10 位数字,购买后将其添加到数据库中。
现在我想做一个php页面给用户一个输入框,让他们输入10位数字,然后点击提交。单击提交后,如果使用或未使用 pin,它应该返回。(如果它不可用,则使用 - 如果它在表中,则不使用)
我得到以下代码:
<?php
require_once 'db.php';
function validated_pin($pin)
{
$pin = mysql_real_escape_string($pin); // SECURITY!
$result = mysql_query("SELECT pins FROM pins WHERE pin='$pin' LIMIT 1");
if (mysql_fetch_row($result)) {
return 'This pin has already been used';
} else {
return 'This pin is available for use';
}
}
echo '<html><center>
<form action="' . $_SERVER['SCRIPT_NAME'] . '" method="post">
<table style="border:0px solid black;">
<tr>
<td>PIN*:</td><td><input type="text" name="pin" value="" class="bginput"/></td>
</tr>
<tr>
<td></td><td><input type="submit" id ="submit" name="submit1" value="Check Pin>>" class="button"></td>
</tr>
</table>';
echo validated_pin($pin);
echo '</center></html>';
?>
PHPmyAdmin 看起来像这样: http: //gyazo.com/67c3df7171c83c677cb221c04d644ed7.png
它位于 _donation 和表名引脚中
我不知道发生了什么尝试到处寻找
当前代码将返回此错误
Warning: mysql_fetch_row() expects parameter 1 to be resource, boolean given in /home/website/public_html/directory/example.php on line 8