我的PHP存在问题

时间:2013-12-15 02:20:33

标签: php mysql

这是我尝试使用登录表单时获得的内容。我的PHP,HTML和错误列在下面

PHP:

<?php
$con=mysqli_connect("h","h","h","g");
$sql = "SELECT username, password FROM users WHERE username=? AND  pwd=? LIMIT 1";
$stmt = $con->prepare($sql);
$stmt->bind_param('ss', $_POST["username"], $_POST["pwd"]);
$dbh->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
$stmt->execute();
$stmt->bind_result($username, $password);
$stmt->store_result();
if($stmt->num_rows == 1)
{
    echo "you are logged in";
}

HTML:

<form action="login.php" method="post">
  <input type="text" name="username"required>
  <p>
    <input type="password" name="pwd"required>
  <p>
    <input type="submit" name="Sign Up" value="Log In">
</form>

错误:

Fatal error: Call to a member function bind_param() on a non-object in /home/u378761662/public_html/login/login.php on line 5

1 个答案:

答案 0 :(得分:0)

看起来{@ 1}}在第5行

处抛出异常。

login.php之前添加echo $con->error;,看看是否会引发错误。

希望这有帮助。