Note that there are some explanatory texts on larger screens.

plurals
  1. POCannot send a database timestamp through JavaScript but can send other values
    primarykey
    data
    text
    <p>I'm using PHP5, MySQL, JavaScript and Fusion Charts.</p> <p>I have the following time value returned from a database: <code>2011-12-19 12:00:00</code></p> <p>After taking it from the database, I try to pass it through a JavaScript strURL to get it to another page where I can make further database calls using this value. The problem I have is that the JavaScript fails whenever I send it through a date/time. I can send through any other value type and it works so the problem seems to be with the time stamp. I've tried converting it to string before it is passed (just to be sure it's not one already) and that doesn't work. I'm guessing it's to do with the characters within the value. Any idea how to get around this?</p> <p>The database call in PHP and then sending fields into the JavaScript:</p> <pre><code>$strQuery = "SELECT unit, watts, time, device, siteid FROM inverter WHERE time = '2011-12-19 12:00:00' AND siteid = '842'"; $result2 = mysql_query($strQuery) or die(mysql_error()); if ($result2) { while($ors2 = mysql_fetch_array($result2)) { $thetime = (string)$ors2['time']; $strXML .= "&lt;set color='58ACFA' label='" . $ors2['device'] . "/" . $ors2['unit'] . "' value='" . $ors2['watts'] . "' link='javaScript:updateChart(" . $ors2['unit'] . " , " . $ors2['device'] . " , " . $ors2['siteid'] . " , " . $thetime . ")'/&gt;"; } } </code></pre> <p>And then the JavaScript function:</p> <pre><code>function updateChart(first, second, third){ //DataURL for the chart var strURL = "FactoryData.php?factoryId=" + first + "&amp;device=" + second + "&amp;siteid=" + third; FusionCharts("FactoryDetailed").setXMLUrl(strURL); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload