我有一个语法错误,上面写着“Uncaught SyntaxError: Unexpected token ILLEGAL”,我认为它在<?php ?>
JavaScript 代码中的代码中,但无法弄清楚为什么......如果我删除标签中的<?php ?>
代码,我不会收到错误. 我之前删除了错误,但随后错误突然再次“出现”。
所以这里是 JavaScript 函数。我正在调用 PHP 代码,因为如果出现问题,我需要显示错误,并且正在从 PHP 文件调用该 javascript 函数。我要求此 PHP 文件中的 PHP 文件。
function visErrorFraaLastOppSjekk() {
document.getElementById("errorLastOpp").innerHTML = "Filnamnet " + "<strong>" + "<?php echo substr($_FILES['file']['name'],0,50) ?>" + "</strong>" + "eksisterer allereide.<br>" + "Gje bilete eit anna namn, eller<br>" + "velg eit anna bilete og prøv igjen.";
}
// Denne funksjonen er for last_opp_sjekk.php som tar med denne sida, index_geolocation, og setter inn tekst i error boks for last opp vindauget
function visErrorFraaLastOppOK() {
document.getElementById("errorLastOpp").innerHTML = "Bilete er blitt opplasta.";
document.getElementById("filNamnTabellR").value = "Opplasta_bilete/" + "<?php echo $_FILES['file']['name'] ?>"; // EDIT: FIXED
document.getElementById("namnLastOpp").value = "<?php echo $_FILES['file']['name'] ?>";
document.getElementById("storrelse_kb").value = "<?php echo round($_FILES['file']['size']/1024000, 3) ?>" + " megabyte " + "(<?php echo round($_FILES['file']['size']/1024, 3) ?>" + " kilobyte)";
}
这是错误代码的图片:
更新:
以下是 Google Developer Tools 中的更多代码:
<script>
// Denne funksjonen er for last_opp_sjekk.php som tar med denne sida, index_geolocation, og setter inn tekst i error boks for last opp vindauget
function visErrorFraaLastOppSjekk() {
document.getElementById("errorLastOpp").innerHTML = "Filnamnet " + "<strong>" + "<br />
// 错误代码在上面一行 Uncaught SyntaxError: Unexpected token ILLEGAL
( ! ) 注意:未定义索引:C:\wamp\www\geolocation_for_voss_gymnas\index_geolocation_admin.php 中的文件在第103行
调用堆栈#TimeMemoryFunctionLocation 10.0029204912{main}( )..\index_geolocation_admin.php : 0 " + "
" + "eksisterer allereide。” + “Gje bilete eit anna namn, eller
” + “velg eit anna bilete og prøv igjen。”; }
// Denne funksjonen er for last_opp_sjekk.php som tar med denne sida, index_geolocation, og setter inn tekst i error boks for last opp vindauget
function visErrorFraaLastOppOK() {
document.getElementById("errorLastOpp").innerHTML = "Bilete er blitt opplasta.";
document.getElementById("filNamnTabellR").value = "Opplasta_bilete/" + "<br />
<font size='1'><table class='xdebug-error xe-notice' dir='ltr' border='1' cellspacing='0' cellpadding='1'>
<tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> Notice: Undefined index: file in C:\wamp\www\geolocation_for_voss_gymnas\index_geolocation_admin.php on line <i>109</i></th></tr>
<tr><th align='left' bgcolor='#e9b96e' colspan='5'>Call Stack</th></tr>
<tr><th align='center' bgcolor='#eeeeec'>#</th><th align='left' bgcolor='#eeeeec'>Time</th><th align='left' bgcolor='#eeeeec'>Memory</th><th align='left' bgcolor='#eeeeec'>Function</th><th align='left' bgcolor='#eeeeec'>Location</th></tr>
<tr><td bgcolor='#eeeeec' align='center'>1</td><td bgcolor='#eeeeec' align='center'>0.0029</td><td bgcolor='#eeeeec' align='right'>204912</td><td bgcolor='#eeeeec'>{main}( )</td><td title='C:\wamp\www\geolocation_for_voss_gymnas\index_geolocation_admin.php' bgcolor='#eeeeec'>..\index_geolocation_admin.php<b>:</b>0</td></tr>
</table></font>
";
document.getElementById("namnLastOpp").value = "<br />
<font size='1'><table class='xdebug-error xe-notice' dir='ltr' border='1' cellspacing='0' cellpadding='1'>
<tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> Notice: Undefined index: file in C:\wamp\www\geolocation_for_voss_gymnas\index_geolocation_admin.php on line <i>110</i></th></tr>
<tr><th align='left' bgcolor='#e9b96e' colspan='5'>Call Stack</th></tr>
<tr><th align='center' bgcolor='#eeeeec'>#</th><th align='left' bgcolor='#eeeeec'>Time</th><th align='left' bgcolor='#eeeeec'>Memory</th><th align='left' bgcolor='#eeeeec'>Function</th><th align='left' bgcolor='#eeeeec'>Location</th></tr>
<tr><td bgcolor='#eeeeec' align='center'>1</td><td bgcolor='#eeeeec' align='center'>0.0029</td><td bgcolor='#eeeeec' align='right'>204912</td><td bgcolor='#eeeeec'>{main}( )</td><td title='C:\wamp\www\geolocation_for_voss_gymnas\index_geolocation_admin.php' bgcolor='#eeeeec'>..\index_geolocation_admin.php<b>:</b>0</td></tr>
</table></font>
";
document.getElementById("storrelse_kb").value = "<br />
<font size='1'><table class='xdebug-error xe-notice' dir='ltr' border='1' cellspacing='0' cellpadding='1'>
<tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> Notice: Undefined index: file in C:\wamp\www\geolocation_for_voss_gymnas\index_geolocation_admin.php on line <i>111</i></th></tr>
<tr><th align='left' bgcolor='#e9b96e' colspan='5'>Call Stack</th></tr>
<tr><th align='center' bgcolor='#eeeeec'>#</th><th align='left' bgcolor='#eeeeec'>Time</th><th align='left' bgcolor='#eeeeec'>Memory</th><th align='left' bgcolor='#eeeeec'>Function</th><th align='left' bgcolor='#eeeeec'>Location</th></tr>
<tr><td bgcolor='#eeeeec' align='center'>1</td><td bgcolor='#eeeeec' align='center'>0.0029</td><td bgcolor='#eeeeec' align='right'>204912</td><td bgcolor='#eeeeec'>{main}( )</td><td title='C:\wamp\www\geolocation_for_voss_gymnas\index_geolocation_admin.php' bgcolor='#eeeeec'>..\index_geolocation_admin.php<b>:</b>0</td></tr>
</table></font>
0" + " megabyte " + "(<br />
<font size='1'><table class='xdebug-error xe-notice' dir='ltr' border='1' cellspacing='0' cellpadding='1'>
<tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> Notice: Undefined index: file in C:\wamp\www\geolocation_for_voss_gymnas\index_geolocation_admin.php on line <i>111</i></th></tr>
<tr><th align='left' bgcolor='#e9b96e' colspan='5'>Call Stack</th></tr>
<tr><th align='center' bgcolor='#eeeeec'>#</th><th align='left' bgcolor='#eeeeec'>Time</th><th align='left' bgcolor='#eeeeec'>Memory</th><th align='left' bgcolor='#eeeeec'>Function</th><th align='left' bgcolor='#eeeeec'>Location</th></tr>
<tr><td bgcolor='#eeeeec' align='center'>1</td><td bgcolor='#eeeeec' align='center'>0.0029</td><td bgcolor='#eeeeec' align='right'>204912</td><td bgcolor='#eeeeec'>{main}( )</td><td title='C:\wamp\www\geolocation_for_voss_gymnas\index_geolocation_admin.php' bgcolor='#eeeeec'>..\index_geolocation_admin.php<b>:</b>0</td></tr>
</table></font>
0" + " kilobyte)";
}
// Denne funksjonen er for last_opp_sjekk.php som tar med denne sida, index_geolocation, og setter inn tekst i error boks for last opp vindauget
function visErrorLastOppSjekkIV() {
document.getElementById("errorLastOpp").innerHTML = "Fila er ikkje valid. Prøv igjen;<br>" + "sjekk filtypa og filstørrelsen.";
}
</script>