Warning: file_put_contents() expects at least 2 parameters - But i am giving 2 params
<p>Hi I have the function below which grabs and saves screenshots.
It works 50% of the time but it sometimes fails with the following message:
<strong>Warning: file_put_contents() expects at least 2 parameters, 1 given</strong></p>

<p>I have dumped out the 2 parameters and can see that they both exist but the error message suggests otherwise</p>

<p>its driving me mad and any help would be appreciated..</p>

<pre><code>&lt;?php

grab_screenshot('http://www.usa4ink.com', 480, 240,"myscreen.jpg")

function grab_screenshot($url, $w, $h,$filename)
{
    global $imgPath;
    $filename = make_filename($filename,"jpg");
    $url = urlencode($url);
    $url = "http://s.wordpress.com/mshots/v1/$url/?w=$w&amp;h=$h";
    $url = str_replace("//","/",$url);
    $url = str_replace("http:/","http://",$url);
    $image = file_get_contents($url);

    if($image!='')
    {
        file_put_contents(str_replace("//","/",$imgPath."/".get_subDir($filename)."/".$filename, $image));
    }
    return get_subDir($filename)."/".$filename;
}
?&gt;
</code></pre>
