Reputation: 1260
Because of a single quote I am receiving a expecting ) after argument list error:
window.top.stopAudioUpload(1, '43', 'Thorne, Grandma's Goodbye excerpt.m4a');
audioupload.php (line 11, col 54)
My question is how can I get the line of code to accept single quote?
Code:
<script language="javascript" type="text/javascript">
window.top.stopAudioUpload(<?php echo $result; ?>, '<?php echo $id; ?>', '<?php echo $_FILES['fileAudio']['name'] ?>');
</script>
Upvotes: 0
Views: 143
Reputation: 2373
Your issue lies here:
window.top.stopAudioUpload(<?php echo $result; ?>, '<?php echo $id; ?>', '<?php echo $_FILES['fileAudio']['name'] ?>');
Changing the single quotes around'<?php echo
will fix it. So:
window.top.stopAudioUpload("<?php echo $result; ?>", "<?php echo $id; ?>", "<?php echo $_FILES['fileAudio']['name'] ?>");
You can also use json_encode($_FILES['fileAudio']['name'])
. This adds quotes automatically.
Upvotes: 0
Reputation: 799
You could try to manually escape your single-quote with a backslash Thorn, Grandma\'s Goodbye excerpt.m4a
or you could use the escape function - see the docs here:
http://www.php.net/manual/en/function.htmlspecialchars.php
Upvotes: 0
Reputation: 324790
Try this:
<script type="text/javascript">
top.stopAudioUpload(
<?php echo json_encode($result); ?>,
<?php echo json_encode($id); ?>,
<?php echo json_encode($_FILES['fileAudio']['name']); ?>
);
</script>
Note the lack of quotes - this is important, because json_encode
will add these automatically if needed.
Upvotes: 5
Reputation: 1666
Try \ escape character 'Thorne, Grandma\'s Goodbye excerpt.m4a'
Upvotes: 2