$query="select * from users1 where name='$login'";
正如上面几位指出的错误地方,我已进行如下修改: —————————————— —————————————————— <? if ($login=="" or $password==""){ header("location:http://localhost/test/index.htm"); exit(); } $connect=mysql_connect("localhost","root","1"); if ($connect==false){ print"数据库未启动!"; exit(); } $res=mysql_select_db("bookseller",$connect); if ($res==false){ print"不能够打开bookseller数据库!"; mysql_close($connect); exit(); } //此处始终打不开users1数据表 $query="select * from users1 where name='$login'"; $res=mysql_query($query,$connect); if ($res==false){ print"sorry! 你不是受权用户!"; exit(); } else{ print"welcome you !"; mysql_close($connect); exit(); } ?> —————————— ———————————————————— 虽然程序运行没问题,但$res=mysql_query($query,$connect); 的返回值好像恒为false ! mysql_query用于select命令好像返回值不太一样???!!!
不对!$result=mysql_query("select * from $BBSDB",$db); $maxrow=mysql_num_rows($result);明白否?
更改程序后报错:Warning: Supplied argument is not a valid MySQL result resource in C:\WINDOWS\Desktop\ceshi\login.php on line 20—————————————— —————————————————————— <? if ($login=="" or $password==""){ header("location:http://localhost/test/index.htm"); exit(); } $connect=mysql_connect("localhost","root","1"); if ($connect==false){ print"数据库未启动!"; exit(); } $res=mysql_select_db("bookseller",$connect); if ($res==false){ print"不能够打开bookseller数据库!"; mysql_close($connect); exit(); } $query="select * from users1 where name='$login'"; $result=mysql_query($query,$connect); //就在此处! $maxrows=mysql_num_rows($result); if ($maxrows==0){ print"sorry! 你不是受权用户!"; exit(); } else{ print"welcome you !"; mysql_close($connect); exit(); } ?>
——————————————
——————————————————
<?
if ($login=="" or $password==""){
header("location:http://localhost/test/index.htm");
exit();
}
$connect=mysql_connect("localhost","root","1");
if ($connect==false){
print"数据库未启动!";
exit();
}
$res=mysql_select_db("bookseller",$connect);
if ($res==false){
print"不能够打开bookseller数据库!";
mysql_close($connect);
exit();
}
//此处始终打不开users1数据表
$query="select * from users1 where name='$login'";
$res=mysql_query($query,$connect);
if ($res==false){
print"sorry! 你不是受权用户!";
exit();
}
else{
print"welcome you !";
mysql_close($connect);
exit();
}
?>
——————————
————————————————————
虽然程序运行没问题,但$res=mysql_query($query,$connect);
的返回值好像恒为false !
mysql_query用于select命令好像返回值不太一样???!!!
$maxrow=mysql_num_rows($result);明白否?
——————————————————————
<?
if ($login=="" or $password==""){
header("location:http://localhost/test/index.htm");
exit();
}
$connect=mysql_connect("localhost","root","1");
if ($connect==false){
print"数据库未启动!";
exit();
}
$res=mysql_select_db("bookseller",$connect);
if ($res==false){
print"不能够打开bookseller数据库!";
mysql_close($connect);
exit();
}
$query="select * from users1 where name='$login'";
$result=mysql_query($query,$connect);
//就在此处!
$maxrows=mysql_num_rows($result);
if ($maxrows==0){
print"sorry! 你不是受权用户!";
exit();
}
else{
print"welcome you !";
mysql_close($connect);
exit();
}
?>