PHP array issue: cannot use string offset as an Array

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ReBooker
Forum Newbie
Posts: 2
Joined: Tue Dec 08, 2009 5:23 pm

PHP array issue: cannot use string offset as an Array

Post by ReBooker »

I get this error only some of the time with a call from an FQL query.
Fatal error: Cannot use string offset as an array

Code: Select all

 
$results = $facebook->api_client->fql_query('Select first_name, pic_big  From user Where uid='.$user.'');
$fname = $results[0]['first_name'];
 
The result array looks like:

Code: Select all

Array
(
    [0] => Array
        (
            [first_name] => Kevin
            [pic_big] => http://profile.ak.fbcdn.net/v226/16/68/ ... 5_6373.jpg
        )
)
 
Any ideas about what the issue would be here?
Thanks,
Kevin
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: PHP array issue: cannot use string offset as an Array

Post by AbraCadaver »

It probably means that you have no results, so $results is not an array.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
ReBooker
Forum Newbie
Posts: 2
Joined: Tue Dec 08, 2009 5:23 pm

Re: PHP array issue: cannot use string offset as an Array

Post by ReBooker »

That would make sense except that I can test the query in Facebook's developer tools and it returns the same results every time. Man, Facebook app development is frustrating.. :x
Post Reply