简体   繁体   English

php函数在localhost中有效,但在服务器上不起作用

[英]php function works in localhost but doesn't on the server

When I try to put my website in production, i get an error, but everything works well in my wamp localhost. 当我尝试将网站投入生产时,出现错误,但是在我的wamp localhost中一切正常。

The error => 错误=>

  • Type: ErrorException 类型:ErrorException
  • Code: 8 代码:8
  • Message: Undefined offset: 0 消息:未定义的偏移量:0
  • File: *******/httpdocs/alliance/slimrest/datamanager/dm_utilisateur.php 文件:******* / httpdocs / alliance / slimrest / datamanager / dm_utilisateur.php
  • Line: 20 行:20

Le line 20 is the last of this code portion => 第20行是此代码部分的最后一个=>

    $user = $o_utilisateur->getUserByLogPass($log, $pass);

    if(isset($user['0'])){
        //GET group BY user
        $tmp = $o_droit->getGroupById($user['0']['TB_groupe_id_groupe']);
        $user['0']['libele'] = $tmp['0']['libele'];

I might be the PHP version ? 我可能是PHP版本吗?

  • Localhost : PHP_VERSION = 5.5.12 本地主机:PHP_VERSION = 5.5.12
  • Server : PHP_VERSION = 5.5.9-1ubuntu4.4 服务器:PHP_VERSION = 5.5.9-1ubuntu4.4

You checked isset($user['0']) , but not isset($tmp['0']) . 您检查了isset($user['0']) ,但没有检查isset($tmp['0']) The problem must be with the $tmp variable, it has no 0 key. 问题必须出在$tmp变量上,它没有0键。

if(isset($user['0']) && isset($tmp['0']))

I don't know what $tmp is supposed to contain, but for some reason it doesn't contain it on your production server. 我不知道$tmp应该包含什么,但是由于某种原因,它在您的生产服务器上不包含它。 You need to check whatever code creates the $tmp array, perhaps it's a database problem, did you upload the DB to production? 您需要检查创建$tmp数组的任何代码,也许这是数据库问题,您是否已将数据库上传到生产环境?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我的php代码在localhost上有效,但在实际服务器上不起作用 - My php code works on localhost, but doesn't work on the actual server AJAX 适用于本地主机,但不适用于实时服务器 - AJAX works on localhost, but doesn't on live server PHP脚本适用于localhost,但不适用于托管 - PHP script works on localhost, but doesn't works on hosting PHP-提交登录表单后重定向到主页在服务器上不起作用,但在localhost上可以正常工作 - PHP- Redirect to home page after submit login form doesn't work on server but works fine on localhost PHP INSERT 查询不适用于 web 服务器,但适用于 localhost。 没有返回错误 - PHP INSERT query doesn't work on web server but works on localhost. No errors returned 函数在localhost上起作用,但在服务器上不起作用 - Function works on localhost but not on server php function 验证令牌在 localhost 中有效,但在 GoDaddy 服务器上无效 - php function verify token works in localhost but not on GoDaddy server php脚本无法在服务器上运行,而可以在localhost [xampp]上运行 - php script isn't working on server while works on localhost [xampp] PHP:Readfile在本地主机上有效,但在服务器上不可用 - PHP: Readfile works at localhost but not at server 这个 php 代码在本地主机上工作,但不在服务器上? - this php code works in localhost but not on server?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM