title: can't pass json array
body: <p>I have an 'onload' handler for my web page, and it calls a javascript function  'handleLoad()' that has now stopped working (not being called) after I try to pass the output of json_encode in my PHP.</p>
  
  <pre><code> &lt;body onload="handleLoad('&lt;?php echo $myJsonArr ?&gt;')"&gt;
  </code></pre>
  
  <p>I have also tried:</p>
  
  <pre><code> &lt;body onload="handleLoad(&lt;?php echo $myJsonArr ?&gt;)"&gt;
  </code></pre>
  
  <p>and:</p>
  
  <pre><code> &lt;body onload='handleLoad("&lt;?php echo $myJsonArr ?&gt;")'&gt;
  </code></pre>
  
  <p>playing around with the quotes, and nothing.  <strong>handleLoad()</strong> is not being called anymore.</p>
  
  <p>This passing of <strong>myJsonArr</strong> now prevents the handleLoad() function from executing -- I know this because the 1st line of code in handleLoad(), which is javascript by the way, looks like this:</p>
  
  <pre><code> function handleLoad(jsonArr)
   {
        alert("just entered handleLoad()");
  
        .....other code not shown, and 100% commented out during fixing this bug
   }
  </code></pre>
  
  <p>That 'alert' box above will appear fine -- until I added the 'jsonArr' JSON nested array, after which the 'alert' box is not showing up at all.   I removed all code from handleLoad() except the alert() box to eliminate any other cause -- and handleLoad() is not being invoked, despite the only thing now in handleLoad() is a simple call to alert().</p>
  
  <p>The jsonArr is created like this, from a database read:</p>
  
  <pre><code> $result = mysql_query($query);
   $numrows = mysql_num_rows($result);
   $theOuterArray = array();
  
   for($i = 0; $i &lt; $numrows;  $i++)
   { 
      $theRow = mysql_fetch_row($result);
      $cityName = $theRow[1];
      $lat = $theRow[2];
      $lng = $theRow[3];
       // AND SO ON FOR address, titleOnly, recordNum, cityName, etc. used next....
  
      $nestedArray =  array($cityName, $lat, $lng, $i, $address, $titleOnly, 
                               $recordNum, $cityName, $stateName, $price);
      $theOuterArray[] = $nestedArray;
   }
   $myJsonArr = json_encode($theOuterArray);
   var_dump($myJsonArr);
  </code></pre>
  
  <p>Here's what the var_dump show me -- to keep things easy I only put one record in the database:</p>
  
  <pre><code> string(136) "[["Auburn","32.6121","-85.4819",0,"Main Street","Test to debug why handleLoad() not being invoked","53378577","Auburn","Alabama","995"]]" 
  </code></pre>
  
  <p>Is there something I'm missing here?   I successfully read the database, but creating then passing that json array to my "onload" handler is breaking the code.</p>
  
  <p>EDIT:  suggested was to provide the source on my page in Firefox of the generated onload in the body tag, here it is:</p>
  
  <pre><code>  &lt;body onload="handleLoad('[["Auburn","32.6121","-85.4819",0,"Main Street","Test to debug why handleLoad() not being invoked","53378577","Auburn","Alabama","995"]]')"&gt;
  </code></pre>