Menu
For some reason this code to bring a PHP variable to Javascript isn’t working…Can someone show me why??
First, we select the value from SQL and store it in a PHP variable…this part works correct as I tested it just to echo the result.
[code=php]$chrname = “select Charname from $table where 1”;
$chrnme = mysql_query($chrname);
$Charname = mysql_result($chrnme, $Id);
Then, later on in the code, we try to convert it to Javascript, but it doesn’t work.
[code=html]<script type=”text/javascript”>
var charname = “<?$Charname?>”;
alert(charname);
</script>
This gives me a blank alert box…why isn’t this working???