使用PHP将Yahoo Finance中的csv导入MySQL

Using Johnboy's tutorial on importing .csv files to MySQL, I tried to make a script that would take exchange rate data from Yahoo finance, and write it to the MySQL database.

<?php  

//connect to the database 
$host = "****"
$user = "****"
$password = "****"
$database = "****"
$connect = mysql_connect($host,$user,$password); 
mysql_select_db($database,$connect);

//select the table  
if ($_FILES[csv][size] > 0) { 

    //get the csv file 
    $symbol = "ZARINR"
    $tag = "l1"
    $file = "http://finance.yahoo.com/d/quotes.csv?e=.csv&f=$tag&s='$symbol'=x"; 
    $handle = fopen($file,"r"); 

    //loop through the csv file and insert into database 
    do { 
        if ($data[0]) { 
            mysql_query("INSERT INTO ZAR_to_INR(exchange_rate) VALUES 
                ( 
                    '".addslashes($data[0])."', 
                ) 
            "); 
            echo "done";
        } 
    } while ($data = fgetcsv($handle,1000,",","'")); 

    //redirect 
    header('Location: import.php?success=1'); die; 

} 

else{
    echo "nope";
}

?> 

I added the echos in the hope that they'd tell me whether or not the script worked. It doesn't work at all. There are no error messages or anything. When I run the script by opening it in my webhost, it simply does not run.

I'd appreciate any advice on how to make this script work (or even an alternate way of solving the problem).

try using mysql debugs :

mysql_select_db($database) or die('Cant connect to database'); 
$result = mysql_query($query) or die('query fail : ' . mysql_error());
$connect = mysql_connect($host,$user,$password) 
    or die('Cant connect to server: ' . mysql_error());

to find this outputs you need to check your php error_log : where-does-php-store-the-error-log