在linux上装好了phpstudy,代码放上去能显示网页,但是php链接数据库不行,代码在windows下没问题

zhengbowen 发布于 2016/12/06 13:45
阅读 607
收藏 0
var storage = window.localStorage; var key = null; $('#login').click(function(){ var uname = $("#name").val(); var upwd = $("#pwd").val(); var md5=hex_md5(upwd); $.post("PHP/dengluphp/guanliyuandenglu.php",{uname:uname,upwd:md5},function(data){ if(data.msg=='exit') { if(data[0].ustate=="正常"){ console.log(data); //             location.href="guanliyuan.html";  key = 'username'; var value = uname; storage.setItem(key,value); key = null;//释放资源 //             console.log(data[0].ujob);  var level=data[0].ujob; if(level=="管理员"){ //                   location.href="guanliyuan.html?level="+level;  }else if(level=="一级代理"){ location.href="yijidaili.html?level="+level;
                  }else if(level=="二级代理"){ location.href="erjidaili.html?level="+level;
                  }else if(level=="三级代理"){ location.href="sanjidaili.html?level="+level;
                  }
               }else{ alert('您的账号已被停封,请联系管理员');
               }

            }else{ alert('您输入的账号或密码错误');
            }
         })
      })
<?php
  header("Content-Type:appliction/json;charset=UTF-8");
  $uname = $_REQUEST['uname'];
  $upwd = $_REQUEST['upwd'];
  if(empty($uname)){
    echo '[]';
    return;
  };
  $conn = mysqli_connect("服务器的ip",'root','mysql的密码',"group666",3306);
  $sql = "SET NAMES UTF8";
  mysqli_query($conn,$sql);
  $sql = "SELECT * FROM firdaili WHERE uname='$uname' AND upwd='$upwd'";
  $result = mysqli_query($conn,$sql);
  $output = [];
  while(($row=mysqli_fetch_assoc($result))!==NULL){
           $output[] = $row;
           $output['msg'] = 'exit';
         };
  echo json_encode($output);
?>
在linux上装了phpstudy,把文件都放到www文件中

然后浏览器输入ip能访问到页面,进行异步请求时就出现错误

jquery-3.1.1.min.js:4 POST http://139.224.70.248/mysqlhoutai/PHP/dengluphp/guanliyuandenglu.php 500 (Internal Server Error)

    1. Request URL:
      http://139.224.70.248/mysqlhoutai/PHP/dengluphp/guanliyuandenglu.php
    2. Request Method:
      POST
    3. Status Code:
      500 Internal Server Error
    4. Remote Address:
      139.224.70.248:80
  1. Response Headersview source
    1. Connection:
      close
    2. Content-Length:
      0
    3. Content-Type:
      text/html
    4. Date:
      Tue, 06 Dec 2016 04:28:19 GMT
    5. Server:
      Apache/2.4.7 (Unix) PHP/5.3.27
    6. X-Powered-By:
      PHP/5.3.27
  2. Request Headersview source
    1. Accept:
      */*
    2. Accept-Encoding:
      gzip, deflate
    3. Accept-Language:
      zh-CN,zh;q=0.8
    4. Connection:
      keep-alive
    5. Content-Length:
      47
    6. Content-Type:
      application/x-www-form-urlencoded; charset=UTF-8
    7. Host:
      139.224.70.248
    8. Origin:
      http://139.224.70.248
    9. Referer:
      http://139.224.70.248/mysqlhoutai/
    10. User-Agent:
      Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.99 Safari/537.36
    11. X-Requested-With:
      XMLHttpRequest
  3. Form Dataview sourceview URL encoded
好像说是代码的问题,但是我在windows下没问题啊,求大神指点
加载中
0
inuxor
inuxor

PHP/5.3.27

这个版本的php支持$output = []这样声明数组?5.4以上才行吧

返回顶部
顶部