PHP not running from command line, works fine on webserver?
<p>Appreciate your help, my question is: I have a simple PHP which works fine when it runs on my webhosting company's server but when I try to run it on my machine from command line it does not work. On local machine it just does something for a while and then comes out without even printing content of echo. Using MySQl GUI client I can connect from local machine and query.</p>

<p>Here is the script:</p>

<pre><code>&lt;?php
$dbhost = '118.52.14.13';
$dbuser = 'hfm';
$dbpass = 'sdb';
$dbname = 'mdb';
$timeout = '50000';

$con = mysql_connect($dbhost,$dbuser,$dbpass);

//select a database to work with
$selected = mysql_select_db($dbname, $con);// or echo "Couldn't open database $dbname";

$sql = "select name,thumbnail_url,swf_url from mochi_games limit 10,50";
$result=mysql_query($sql,$con);

while($row = mysql_fetch_array($result))    
{

    echo "Loading Start .... " . $row['swf_url'] ;
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $row['swf_url']);
    $swf_filename = substr($row['swf_url'], strrpos( $row['swf_url'],'/') + 1);
    curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
    curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT,$timeout);
    //curl_setopt( $ch, CURLOPT_TIMEOUT,0); 
    curl_setopt( $ch, CURLOPT_FILETIME,0);
    $output = curl_exec($ch);

    // Allows overwriting of existing files on the remote FTP server
    $stream_options = array('ftp' =&gt; array('overwrite' =&gt; true));
    $stream_context = stream_context_create($stream_options);

    // Opens the file for writing and truncates it to zero length 
    $fp = fopen("ftp://exer:now12@ftp.logitia.com/cgi-bin/wf_files/" .  $swf_filename, 'w',0, $stream_context);
    fwrite($fp, $output);
    fclose($fp);
    curl_close($ch);    
  echo "Loading End";
}
mysql_close($con);
?&gt;
</code></pre>
