警告:mysql_num_rows()希望参数1是resource,布尔值在第17行的/var/customers/webs/ni272979_1/Loader/login.php中给出
您的查询中有一个错误。应该是这样的警告:mysql_num_rows()希望参数1是resource,布尔值在第17行的/var/customers/webs/ni272979_1/Loader/login.php中给出,php,Php,您的查询中有一个错误。应该是这样的 <?php $filename = 'install.php'; if (file_exists($filename)) { echo ("<center><font color='red'><b>/install.php still exists<br> After installing please delete install.php</center></font></b
<?php
$filename = 'install.php';
if (file_exists($filename)) {
echo ("<center><font color='red'><b>/install.php still exists<br>
After installing please delete install.php</center></font></b>");
} else {
if (isset($_POST['Login'])){
include('config.php');
if (!mysql_connect($host, $username, $password)) die("Can't connect to database");
if (!mysql_select_db($db_name)) die("Can't select database");
$myusername=$_POST['myusername'];
$mypassword=$_POST['mypassword'];
$sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword' or die(mysql_error());";
$result=mysql_query($sql);
$count=mysql_num_rows($result);
if($count >= 1){
session_register("myusername");
session_register("mypassword");
header("location: index.php");
} else {
}
}
$sql = "SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword';";
然后你可以这样做
<?php
$filename = 'install.php';
if (file_exists($filename)) {
echo ("<center><font color='red'><b>/install.php still exists<br>
After installing please delete install.php</center></font></b>");
} else {
if (isset($_POST['Login'])){
include('config.php');
if (!mysql_connect($host, $username, $password)) die("Can't connect to database");
if (!mysql_select_db($db_name)) die("Can't select database");
$myusername=$_POST['myusername'];
$mypassword=$_POST['mypassword'];
$sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword' or die(mysql_error());";
$result=mysql_query($sql);
$count=mysql_num_rows($result);
if($count >= 1){
session_register("myusername");
session_register("mypassword");
header("location: index.php");
} else {
}
}
$sql = "SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword';";
还可以尝试使用或函数进行CRUD操作。请阅读。不应使用不推荐使用的
mysql_*()
函数编写新代码。相反,现在是开始学习如何使用MySQLi或PDO安全地使用prepare()/execute()
。请学习如何不存储密码(1的纯文本):如果您正在学习某个特定教程,最好找到一个更新的教程。也