Problem using foreach to loop pdo results

Here is the scenario. On my local vm this works great. but on the production server does not work.

My VM where the code works:
uname -a
Linux dev 3.13.0-65-generic #106-Ubuntu SMP Fri Oct 2 22:08:27 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
root@dev:/var/www# php -v
PHP 5.5.9-1ubuntu4.14 (cli) (built: Oct 28 2015 01:34:46)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
    with Zend OPcache v7.0.3, Copyright (c) 1999-2014, by Zend Technologies
root@dev:/var/www# mysql --version
mysql  Ver 14.14 Distrib 5.5.46, for debian-linux-gnu (x86_64) using readline 6.3

Open in new window


The Production server:
 
uname -a
Linux  2.6.32-573.8.1.el6.x86_64 #1 SMP Tue Nov 10 18:01:38 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
[root@server1 ~]# php -v
PHP 5.4.45 (cli) (built: Mar  2 2016 16:08:51)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies
[root@server1 ~]# mysql --version
mysql  Ver 14.14 Distrib 5.5.48, for Linux (x86_64) using readline 5.1

Open in new window


Here is the code:
Screenshot_5.png
so above i have this code. on my vm i get the result['filename'] printed as it should be. but on my production server I got printed the word "Array"

So what is going on here. pls help me.
LVL 1
rafaelrglAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ray PaseurCommented:
At first glance, your code looks correct to me, but it's a data-dependent problem, so we would need to see the data.

When you try to print a PHP array (or otherwise convert it to a string) PHP returns "array."  Not very helpful!

Here is the man page for fetchAll():
http://php.net/manual/en/function.var-dump.php

Try looking directly at the raw data.  You can use var_dump($results) to see what the data structure looks like.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.