Hi there, can anyone make sense of what I'm supposed to put in here? Here's my original code: $fd = fopen (("http://quote.yahoo.com/d/quotes.csv?s=".$symbol."&f=sl1d1t1c1ohgv&e=.csv"), "r"); $contents = fread ($fd, 200); fclose ($fd); $contents = str_replace ("\"", "", $contents); $contents = explode (",", $contents); echo '<style type="text/css">table { font-size: 12; } </style>'; Here's what dreamhost says to use: wiki.dreamhost.com (http://wiki.dreamhost.com/Special:Search?search=fopen&go=Go) Anyone know? Thanks a bunch! I appreciate your time.
Your both right...my post doesn't make any sense...sorry. I'll try again: First, I'm with Dreamhost and they don't allow the commands: fopen or fclose Here's the code in my php file: $fd = fopen (("http://quote.yahoo.com/d/quotes.csv?s=".$symbol."&f=sl1d1t1c1ohgv&e=.csv"), "r"); $contents = fread ($fd, 200); fclose ($fd); $contents = str_replace ("\"", "", $contents); $contents = explode (",", $contents); echo '<style type="text/css">table { font-size: 12; } </style>'; As I understand it, it's supposed to open up the url, grab the info for the stock symbol I entered on the search and display it. As Dreamhost doesn't allow the fopen and fclose commands, here is their suggestion on what to replace the original code with: Description cURL is a command line tool for transferring files with URL syntax, supporting FTP, FTPS, HTTP, HTTPS, SCP, SFTP, TFTP, TELNET, DICT, FILE and LDAP. cURL supports HTTPS certificates, HTTP POST, HTTP PUT, FTP uploading, HTTP form based upload, proxies, cookies, user+password authentication (Basic, Digest, NTLM, Negotiate, kerberos...), file transfer resume, proxy tunneling and other useful tricks. [edit] Examples [edit] Fetching a web page <?php $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "http://example.com/"); curl_setopt($ch, CURLOPT_HEADER, 0); curl_exec($ch); curl_close($ch); ?> [edit] Alternative for file_get_contents() Instead of: <?php $file_contents = file_get_contents('http://example.com/'); // display file echo $file_contents; ?> Use this: <?php $ch = curl_init(); $timeout = 5; // set to zero for no timeout curl_setopt ($ch, CURLOPT_URL, 'http://example.com'); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout); $file_contents = curl_exec($ch); curl_close($ch); // display file echo $file_contents; ?> Otherwise if you are getting some errors with the code above, use this: <?php $site_url = 'http://example.com'; $ch = curl_init(); $timeout = 5; // set to zero for no timeout curl_setopt ($ch, CURLOPT_URL, $site_url); curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout); ob_start(); curl_exec($ch); curl_close($ch); $file_contents = ob_get_contents(); ob_end_clean(); echo $file_contents; ?> ******************************************* I cannot for the life of me figure this one out. What code should I put in place of my original code to make it display the info I want it to? ******************************************* (A recent example of how I fixed a more simpler code that involved the fopen/etc.. commands: Instead of: $request ='http://answers.yahooapis.com/AnswersService/V1/questionSearch?appid='.$api.'&query='.$keyword.'&output=php'.$parameter; $response = file_get_contents($request); I used this: $request ='http://answers.yahooapis.com/AnswersService/V1/questionSearch?appid='.$api.'&query='.$keyword.'&output=php'.$parameter; $ch = curl_init(); $timeout = 5; // set to zero for no timeout curl_setopt ($ch, CURLOPT_URL, $request); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout); $response = curl_exec($ch); curl_close($ch); ) Any ideas? Your help would be appreciated. Thank you. (Hopefully I made sense this time)
Here's the combination of your code/curl code you should use: $url = "http://quote.yahoo.com/d/quotes.csv?s=".$symbol."&f=sl1d1t1c1ohgv&e=.csv"; $ch = curl_init(); curl_setopt ($ch, CURLOPT_URL, $url); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HEADER, 0); $contents = curl_exec($ch); curl_close($ch); $contents = str_replace ("\"", "", $contents); $contents = explode (",", $contents); PHP: Nico -- beat you to it
Mwahaha. I wasn't going to reply now anyway. It's 5:26 am here and I didn't sleep yet. And there was way too much code for my tired eyes.