How to pass a String variable from PHP to Javascript
<p>I'm trying to pass a string variable from PHP to Javascript and it is giving me troubles.</p>

<p>I actually pas a number variable as per the code below and it works, but once I introduce (or uncomment) the line <code>var cityname = &lt;?=$city;?&gt;;</code> in my javascript code then it doesn't work. I believe it has something to do with the type of data because if I introduce a number like <code>Scity = 3</code> in my PHP then it works.</p>

<p>Thank you</p>

<p>I have the following PHP:</p>

<pre><code>&lt;?php
    $get_total_rows = 0;
    $city = "London";

    $db = pg_connect("$db_host $db_name $db_username $db_password");
    $query = "SELECT * FROM table";
    $results = pg_query($query);

    $get_total_rows = pg_numrows($results); 
?&gt;
</code></pre>

<p>and I have the following javascript:</p>

<pre><code>&lt;script type="text/javascript"&gt;
$(document).ready(function() {
var track_load = 0; //total loaded record group(s)
//var cityname = &lt;?=$city;?&gt;;
var total_rows = &lt;?=$get_total_rows;?&gt;;

$('#results').load("autoload_process.php", {'rows':total_rows}, function() {track_load++;}); //load first group
</code></pre>