Possible Duplicate:
Javascript echo’d by PHP doesn’t run
In the following code I am parsing values from a php table into a javascript function, however I am getting an Uncaught ReferenceError: "the php text" is not defined (anonymous function)
<html>
<script type="text/javascript">
function draw(name ) {
alert(name);
}
</script>
<body>
<canvas id="mycanvas" width=800 height=400></canvas>
</body>
</html>
<?php
$query = 'SELECT * FROM graph_table';
$result = mysql_query($query);
while($val = mysql_fetch_array($result)) {
$name = $val['test_name'];
echo '<script type="text/javascript"> draw('.$name .'); </script>';
}
?>
draw(sometext), where you actually want to havedraw("sometext").