My php script is not working when uploaded on the server

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
nenni80
Forum Newbie
Posts: 1
Joined: Wed Jun 10, 2009 8:56 pm

My php script is not working when uploaded on the server

Post 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);
Last edited by Benjamin on Fri Jun 12, 2009 5:39 pm, edited 1 time in total.
Reason: Added [code=php] tags.
User avatar
akuji36
Forum Contributor
Posts: 190
Joined: Tue Oct 14, 2008 9:53 am
Location: Hartford, Connecticut

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

Post 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.
Post Reply