Trouble replacing file() with curl commands


#1

OK, I’m having a tough time figuring out replacements for fopen() and file() commands in some of my PHP files. In particular, this bit of code is giving me trouble:

$cdlistfilename = “http://mark.stubbornlights.org/cdlist/cdlist.csv”;
$cddata = file($cdlistfilename);

replaced with:

$curl_handle = curl_init();
$cdlistfilename = ‘http://mark.stubbornlights.org/cdlist/cdlist.csv’;
curl_setopt ($curl_handle, CURLOPT_URL, $cdlistfilename);
curl_setopt($curl_handle, curlOPT_HEADER,0);
curl_setopt($curl_handle, curlOPT_RETURNTRANSFER, 1);
$cddata = curl_exec($curl_handle);
curl_close($curl_handle);

What ends up happening is that it prints out the contents of the cdlist.csv file, which is not what I want. All I want to do is read the contents of the file into $cddata so that I can parse it and print it out to my liking (if you’re curious, the page is a customized display of my cd list – the csv file contains all of the information for each disk that I store in my excel spreadsheet, whereas the php file parses the file to only display important details like artist, title and record label).

Anyway, the php page is located here:

http://mark.stubbornlights.org/cdlist/index.php

If anyone could suggest a way that I could read the file without having it automatically printed out like it’s doing now, I’d appreciate it. Thanks.

mark.


#2

[quote]I’m having a tough time figuring out replacements for fopen()
and file() commands in some of my PHP files.

[/quote]

Anyone know if alternatively it is possible to install ones own PHP escaping DH’s OHO config limitations?


#3

See the many php5 threads, and the PHP5 entry in the Wiki.

-Jason

I40.com - Home Page
MP3Mystic - Personal Streaming Music server.
(Links to my sites are always appreciated)