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<br>"; 17 echo "<a href="%5C%22logout.php%5C%22">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>
<!-- 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 ?>