<?php $dfdf = mysql_result($result2,0,name); ?> <script language='javascript'> var lol = <?= "'$dfdf'" ?> alert(lol); </script>