title: fopen with cron job
body: <p>Can someone please tell me what I'm doing wrong? I have a php script which is supposed to be executed with a cron job, extract data from a database and put it in a csv file.
  When I run it from the browser, it works just fine so I'm sure my query is correct. But, when I use cron job, it returns "<strong>No input file specified.</strong>" and doesn't write to the file.</p>
  
  <p>Here's my code:</p>
  
  <p>CRON: </p>
  
  <blockquote>
    <p>/home/ACCOUNT_NAME/public_html/directory/report.sh</p>
  </blockquote>
  
  <p><em>report.sh</em></p>
  
  <pre><code>php -q /home/ACCOUNT_NAME/public_html/directory/report.php
  php -q /home/ACCOUNT_NAME/public_html/directory/report_mail.php
  </code></pre>
  
  <p><em>report.php</em></p>
  
  <pre><code>&lt;?php
  
      $con = mysql_connect("localhost", "my_un", "my_pw") ;
  
      if(!$con){
          die('Could not connect: ' . mysql_error()) ;
          }
      mysql_select_db("my_db", $con) ;
  
  if (!function_exists('fputcsv')){
          function fputcsv($objFile,$arrData,$strDelimiter=',',$strEnclose='"') {
              $strNewLine="\n";
              $strToWrite = '';
              foreach ($arrData as $strCell){
                  //Test if numeric
                  if (!is_numeric($strCell)){
                      //Escape the enclose
                      $strCell = str_replace($strEnclose,$strEnclose.$strEnclose,$strCell);
                      //Not numeric enclose
                      $strCell = $strEnclose . $strCell . $strEnclose;
                  }
                  if ($strToWrite==''){
                      $strToWrite = $strCell;
                  } else {
                      $strToWrite.=  $strDelimiter . $strCell;
                  }
              }
              $strToWrite.=$strNewLine;
              fwrite($objFile,$strToWrite);
          }
  }
  
  // CUT - MY QUERY HERE
  
  
  $fp = fopen("/reports/report.csv" , "w+");
  
  foreach ($list as $line) {
      fputcsv($fp, split(',', $line));
  }
  ?&gt;
  </code></pre>
  
  <p>The csv file should be stored under </p>
  
  <blockquote>
    <p>/home/ACCOUNT_NAME/public_html/directory/reports/report.csv</p>
  </blockquote>
  
  <p>What am I missing here? TIA</p>