我正在做我的最后一年项目,我按照在youtube上用php创建登录页面的教程,我按照教程并继续出现这种类型的错误>>试图获得非对象的属性,但在视频中他运行顺利
<form class="modal-content animate" action="login1.php" method="POST">
<div class="imgcontainer">
<span onclick="document.getElementById('id01').style.display='none'"
class="close" title="Close Modal">×</span>
<img src="download.png" alt="Avatar" class="avatar">
</div>
<div class="container">
<label><b>Username</b></label>
<input type="text" placeholder="Enter Username" name="uname" required>
<label><b>Password</b></label>
<input type="password" placeholder="Enter Password" name="psw" required>
<button type="submit">Login</button>
<input type="checkbox" checked="checked" name ="submit"> Remember me
</div>
<div class="container" style="background-color:#f1f1f1">
<button type="button"
onclick="document.getElementById('id01').style.display='none'"
class="cancelbtn">Cancel</button>
<span class="psw">Forgot <a href="#">password?</a></span>
</div>
</form>
</div>
<?php
$connect = new mysqli ('localhost','root','','tenantsdb');
if ($connect->connect_error)
{
die("Connection failed : " );
}else
echo 'connect worked';
$uname = $_POST['uname'];
$psw = $_POST['psw'];
$sql = "SELECT FROM tenantsignup WHERE uname ='uname' AND psw='$psw'";
$result = $connect->query($sql);
if($result -> num_row> 0)
{
while ($row=$result->fetch_assoc()){
echo "<br>Admin name is:";
}
}else
echo"username and password are wrong";
?>
它提到错误来自&gt;&gt;&gt; if($ result - &gt; num_row&gt; 0)
任何人都可以帮助我吗?
答案 0 :(得分:-2)
原因就在这里。
您的mysql查询错误。使用以下
MyComboBox.Column(1) = 3
原因是你的uname没有'$'
请注意使用''并不重要,而是使用花括号来表明它们是PHP变量