Warning: mysql_fetch_array() expects parameter 1
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /home/kxmusic/test.php on line 8
本人使用XAMPP for linux 版
在本地机 WAMP 可以使用
但上次到服务器 就出现这个错误
请指教一下
<!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
--><?php
02 include("config.php");
03
04 if($_POST[submit]){
05 $username= str_replace(" ","",$_POST[username]);
06 $_SESSION[login_name]= str_replace(" ","",$_POST[username]);
07 $sql="select * from user_list where `username` = '$username' and user_static != '0'";
08 $query=mysql_query($sql);
09 $us=is_array($row=mysql_fetch_array($query));
10 $ps= $us ? md5($_POST[password].ALL_PS)== $row[password] : FALSE;
11 if($ps){
12 $_SESSION[uid]=$row[uid];
13 $_SESSION[user_shell]=md5($row[username].$row[password].ALL_PS);
14 $_SESSION[times]=mktime();
15 echo "登陆成功";
16 echo "<a href=\"jianli.php\">add list</a><br/>";
17 echo "<a href=\"logout.php\">logout</a>";
18 }else{
19 echo "密码或者用户名错误";
20 session_destroy();
21 }
22
23 }
24
25
26
27 ?>
28 <LINK href="common.css" type=text/css rel=stylesheet>
29
30 <title>::开心肠粉网::开心音乐室</title><form action="" method="post">
31
32 username:<input type="text" name="username" style="height:23px" /><br>
33 password:<input type="password" name="password" style="height:23px" /><br>
34 code:<input type="code" name="code" size="10" style="height:23px" />
35 @@##@@
36 <br><br>
37 <input type="submit" name="submit" value="登陆"/>
38 </form>
<!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
-->
<?php
02 session_start();
03 //数据库连接
04 $conn=mysql_connect('localhost','root','');
05 mysql_select_db('test',$conn);
06 mysql_query("set names 'gbk'");
07 //定义常量
08 define(ALL_PS,"topbase");
09
10 function user_shell($uid,$shell,$m_id){
11 $sql="select * from user_list where `uid` = '$uid'";
12 $query=mysql_query($sql);
13 $us=is_array($row=mysql_fetch_array($query));
14 $shell=$us ? $shell==md5($row[username].$row[password].ALL_PS):FALSE;
15 if($shell){
16 if($row[m_id]<=$m_id){
17 return $row;
18 }else{
19 echo "你的权限不足";
20 exit();
21 }
22 }else{
23 echo "你无权限访问该页";
24 exit();
25 }
26 }
27
28 function user_mktime($onlinetime){
29 $new_time = mktime();
30 echo $new_time-$onlinetime;
31 if($new_time-$onlinetime > '1000'){
32 echo "登录超时";
33 exit();
34 session_destroy();
35 }else{
36 $_SESSION[times]=mktime();
37 }
38 }
39 ?>
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号