0
當我執行下面的代碼,我得到這個錯誤:「mysql_num_rows預計參數1是資源」的錯誤查詢
Warning: mysql_num_rows() expects parameter 1 to be resource, object given in C:\wamp\www\my\myWork.php on line 53
請告訴我錯這個代碼?
<?php
if(isset($_POST['login']))
{
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "Begin";
$uName = $_POST["txtUsername"];
$uPwd = $_POST["txtPwd"];
echo "Your Username is: ".$uName."<br>";
echo "Your password is: ".$uPwd."<br>";
$conn = mysqli_connect($servername, $username, $password, $dbname);
if(!$conn)
die("Connection faild: " . mysqli_connect_error());
$sql = "SELECT firstname from myguests WHERE firstname = '$uName'";
$result = $conn->query($sql);
if(mysql_num_rows($result) > 0)
{
echo "You have a login";
$_SESSION['uname'] = $uName;
}
else
echo "You don't have a login";
}
?>