I am trying to load a file which is being uploaded using PHP script.
I have assigned a variable for the location of the uploaded file $tra = basename( $_FILES['userfile']['name']); and trying to give it as a input for the java script
<script type="text/javascript">
var a = <?php echo $tra; ?>;
</script>
<script type="text/javascript" src="C:/xampp/htdocs/new/jmol/Jmol.js"></script>
But its showing an error
Parse error: syntax error, unexpected ‘<‘ in C:\xampp\htdocs\example.php on line 30 and line number 30 is
<script type="text/javascript">
try this:
You need to enclose with ” to asign a string to a javascript variable. If you are trying to assign a number it should work without the quotes, unless there’s an error in your PHP.