title: Warning: chmod() [function.chmod]: No such file or directory in
body: <p>I'm trying to give a php file a permission to write to JSON file, but it does not seem to work. here is my code</p>
  
  <pre><code>&lt;?php
  $light = $_GET['light'];
  if($light == "on") {
    $file = fopen("light.json", "w") or die("can't open file");
    fwrite($file, '{"light": "on"}');
    fclose($file);
  } 
  else if ($light == "off") {
    $file = fopen("light.json", "w") or die("can't open file");
    fwrite($file, '{"light": "off"}');
    fclose($file);
  }
  
  chmod(" /home/daffo/public_html/ard/light.json", 0755);
  
  ?&gt;
  </code></pre>