Resource id #3

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
afbase
Forum Contributor
Posts: 113
Joined: Tue Aug 15, 2006 1:29 pm
Location: SoCAL!!!!

Resource id #3

Post by afbase »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


I have an issue with my code.  my  code returns an evil 'resource id#3'.  I want my code to just return the webpage in my fopen ().  I really am a noob @ php but eventually i want to build a php based stock screener.  I am having issues pulling/getting stock data and financial statements for free from databases so i figured that i would try Moneycentral website as my source for stock/company information.

if anyone knows where i can pull financial statements from a database or something for free, it would be very helpful!!!!!!

Code: Select all

class stockform{
//Set functions
function set_retrieve($ticker){
$setstock = fopen ("http://moneycentral.msn.com/detail/stock_quote?Symbol=".$ticker."", 'r');
return $setstock;
}
}
$stock = new stockform();
print_r ($stock->set_retrieve($_GET['ticker']));

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
User avatar
neophyte
DevNet Resident
Posts: 1537
Joined: Tue Jan 20, 2004 4:58 pm
Location: Minnesota

Post by neophyte »

Why not just use:

Code: Select all

$file = file_get_contents("http://yoururl/goes/here");
afbase
Forum Contributor
Posts: 113
Joined: Tue Aug 15, 2006 1:29 pm
Location: SoCAL!!!!

Post by afbase »

thanks for the tip. I didn't know that was a built in function. I am a PHP noob
nickvd
DevNet Resident
Posts: 1027
Joined: Thu Mar 10, 2005 5:27 pm
Location: Southern Ontario
Contact:

Post by nickvd »

You may also want to read the manual's entry for fopen, just so you are aware of its use in the future...
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Description
resource fopen ( string filename, string mode [, bool use_include_path [, resource zcontext]] )

Specifically the part about 'resource'. That is what is returned by the function.
Post Reply