Php in external javascript II

My developer tool says there’s a parse error in this line, but I don’t see it. Do you?

echo 'var div = document.getElementById('subcat');';

Here’s the function in which that line belongs

<?php 
session_start();
	$url = $_SESSION['url'];
	//$url = "http://localhost";
session_write_close();

header('Content-type: text/javascript');
echo 'var url = "' . $url . '";';
//echo 'alert(url);';
echo 'function subcat5() {;';
        //echo 'alert(url + "/index.php");';
	echo 'var div = document.getElementById('subcat');'; //get the container on the page
	//echo 'div.innerHTML = '';'; //clear out the subcat
	//echo 'var new_subcat = document.createElement('form');';//create form
	//echo 'new_subcat.action = url + "/index.php";';
	//echo 'new_subcat.id = "models";';
	//echo 'div.appendChild(new_subcat);';
echo '};';
?>

got it: echo ‘var div = document.getElementById(\‘subcat\’);’;

It’s preferred though to stick with single quotes for javascript, and double quotes for html content.
So, I would go with this modification instead, where double quotes are used to denote the string, so that the single quotes can be left unmolested inside of it. That way the escaped quotes don’t end up causing more confusion:


echo "var div = document.getElementById('subcat');";