title: Possible echo javascript function syntax error?
body: <p>This has been stressing me out. I'm calling a php function that saves an image from a user input url, then echos a javascript function to set it as the background image. 
  Everythings working fine except setting the image as the background. Its saved on the server and everything. Im not getting any js or php syntax errors, the browser just says 404 not found even though the file with the correct name is there in the directory. It works completely fine when i dont include the session variable as part of the image name. </p>
  
  <p>Thanks in advance, this is probably just me being stupid as its been a while since ive used php.</p>
  
  <pre><code>&lt;?php
  session_start();
  
  $src = $_GET['image'];
  $contents= file_get_contents($src);
  $file = fopen( pic.$_SESSION['id'].'.jpg','w+');
  fwrite($file, $contents);
  fclose($file);
  
  echo '&lt;script&gt;';
  echo 'var body = document.getElementsByTagName("body")[0];';
  echo 'var source = "pic'.$_SESSION['id'].'.jpg";';
  echo '$(body).css("background-image", "url(source)");';
  echo 'alert(source);'; //just to test to make sure it returns the correct name
  echo '&lt;/script&gt;';
  
  
  ?&gt;
  </code></pre>