Page 1 of 1

My php script is not working when uploaded on the server

Posted: Wed Jun 10, 2009 9:02 pm
by nenni80
Hi I have a simple php script that prints the content of a csv file. I read this file from yahoo website, it has the stock closing price and other info.

My problem is when I try the script from my local machine, it works fine, but when I upload the script to the web server. It doesn't work. I think my php.ini may have different settings than the server php setting, but I dont know which variable should be corrected.

Thanks in advance.

here is the script
-----------------

Code: Select all

 
$url = "http://ichart.finance.yahoo.com/table.csv?s=$tickersymbol&a=$StartMonth&b=$StartDay&c=$StartYear&d=$EndMonth&e=$EndDay&f=$EndYear&g=d&ignore=.csv";
 
echo $url . "<br />n";
 
////////////////////////////////////////////////////////////////////////
/// Get the closing price of a stock and print the a array  
////////////////////////////////////////////////////////////////////////
$row = -1;
// row = 0 will have the title Date/open/low, etc...
$handle = fopen($url, "r");
echo $url . "<br />n";
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
$row++;
$num = count($data);
echo $data[1] . "<br />n";
echo $data[2] . "<br />n";
echo $data[3] . "<br />n";
echo $data[4] . "<br />n";
echo $data[0] . "<br />n";
 
}
echo "Total number of rows is $row ,Total number of colums is $num" . "<br />n";
fclose($handle);

Re: My php script is not working when uploaded on the server

Posted: Fri Jun 12, 2009 1:16 pm
by akuji36
Shouldn't you have a connection script in your php before this one?

Therefore you connect to your server and db (using an include)

before executing code.