Current location: Hot Scripts Forums » Programming Languages » PHP » Need help with an object


Need help with an object

Reply
  #1 (permalink)  
Old 07-16-09, 04:28 PM
npsken npsken is offline
Newbie Coder
 
Join Date: Feb 2004
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Need help with an object

The following code works:
Code:
$file = "http://gdata.youtube.com/feeds/api/videos/fiAb1HuiHyA";
$xml = simplexml_load_file($file);
echo "Title:". $xml->title;
The following code returns an error:
Code:
$data = array();
$file = "http://gdata.youtube.com/feeds/api/videos/fiAb1HuiHyA";
$obj_video = simplexml_load_file($file);
$data[0] = (string) $obj_video->title;
The error being:
Code:
Fatal error: Cannot use object of type stdClass as array in C:\wamp\www\video\video.php on line 58
The overall goal is to get the title of the youtube video into an array.

Can anybody help?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 07-17-09, 02:18 AM
pyr0t3chnician pyr0t3chnician is offline
Newbie Coder
 
Join Date: Jul 2009
Posts: 30
Thanks: 0
Thanked 1 Time in 1 Post
Code:
$file = "http://gdata.youtube.com/feeds/api/videos/fiAb1HuiHyA";
$xml = simplexml_load_file($file);
$data[0]=$xml->title;
echo $data[0];
That works just fine. I think the (string) might be throwing it off.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Object reference not set to an instance of an object. m.timoney Windows .NET Programming 6 04-20-09 04:06 AM
Cannot use object of type stdClass as array tophat PHP 0 11-05-08 10:56 PM
Creating a browser RPG in javascript SolidSamurai JavaScript 26 10-20-08 04:27 PM
Error in OleDBConnection : Object reference not set to an instance of an object pvsunil Windows .NET Programming 1 04-22-05 02:45 PM


All times are GMT -5. The time now is 08:31 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.