Search code examples
phpquit

PHP script stops on str_getcsv with no error


Newbie here with a frustrating, but probably simple question. I am trying to write a script that will get the last line of a .csv with 2 columns. I only need the value in the second column to do a calculation. I have been trying to use str_getcsv to access the second column and then calculate the math. The script works fine on my local server but when I upload to the webserver the script stops and the rest of the page does not load. There are no error messages. Here is the code that I have been working with. It gets to the hello1 echo and stops.

$file = "test.csv"; 
//echo "hello";
$data = file($file);
$line = $data[count($data)-1];
echo "hello1";
$dump = str_getcsv($line);
echo "hello2";
$mynum = $dump[1]*1440;
echo $mynum;

Solution

  • http://php.net/manual/en/function.str-getcsv.php

    (PHP 5 >= 5.3.0)

    What PHP version is installed on your host?

    There are no error messages.

    Then enable error reporting.