up vote 0 down vote favorite
share [fb]

I am just facing a problem,the codes are behaving in different ways.When I coded in my local machine it works well,even in my demo server it works great but its not working in clients server.

$input = "";
if($tagsources!=""){    
  foreach ($tagsources as $show_tagsources) {
    $search_sources = TestSource::search($this->access_key, $show_tagsources);
    foreach ($search_sources as $source) {
      if(in_array($source,$tagsources) ){
        $input[] = $source->id;                         
      }
    }               
  }     
}   

return $input;

working well in my server,problem in client's server. My servers php version is:5.2.4 Clients server's php version is :5.1.6-23.2 I am not sure where the problem is,it will be very helpful if you can guys can figure it out. Thanks in advance.

link|improve this question

54% accept rate
I don't see a problem with the code you posted. And if it's working like you said then there is a good chance it's something other than what is being shown here. I think you are going to have to add some echo statements on the broken server and see where it breaks down. – madmik3 Jan 27 at 5:10
feedback

2 Answers

up vote 1 down vote accepted

I'd start by treating arrays as arrays:

$input = array();

There might have been some change in behavior between versions when using [] = on a string. Make it an array since you're using it as an array and there should be no problem.

Also:

if ($tagsources != "")

This should be if ($tagsources) or if (is_array($tagsources)) or if (!empty($tagsources)). Don't compare an array to an empty string. It may work, but it's not what you mean and it's error prone.

If that doesn't fix it you need to do more step-by-step debugging.

link|improve this answer
yes,I assumed so,but not sure that it is the problem. – caveman Jan 27 at 5:26
feedback

if you are fetching data from database, it might be possible that the values you are looking for don't exist on the particular machine you are testing on.

link|improve this answer
the data is coming from API call from data providers actually. – caveman Jan 27 at 7:59
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.