Uncaught SyntaxError: Unexpected identifier in empty line?

Uncaught SyntaxError: Unexpected identifier in empty line?

我在第 40 行收到语法错误...我不知道为什么,此脚本也只能与所有其他文件一起使用(太多,无法上传)。它不是最好的或最漂亮的,但请尝试一下。

错误:

Uncaught SyntaxError: Unexpected identifier

<?php
session_start();
?>

<!DOCTYPE html>

<html>
<head>
    <title>SCRABBLEGOD</title>
    <script src='https://cdn.rawgit.com/naptha/tesseract.js/1.0.10/dist/tesseract.js'></script>
    <link rel="shortcut icon" type="image/png" href="favicon.png"/> 
</head>
<body>

<script type="text/javascript">
var row0 = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
var row1 = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
var row2 = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
var row3 = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
var row4 = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
var row5 = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
var row6 = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
var row7 = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
var row8 = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
var row9 = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
var row10 = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
var row11 = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
var row12 = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
var row13 = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
var row14 = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
</script>

<img id="row0sm0" src=<?php echo "uploads/sm/" . $_SESSION["row0sm0"]; ?>>
<img id="row0sm1" src=<?php echo "uploads/sm/" . $_SESSION["row0sm1"]; ?>>
<img id="row0sm3" src=<?php echo "uploads/sm/" . $_SESSION["row0sm3"]; ?>>
<img id="row1sm0" src=<?php echo "uploads/sm/" . $_SESSION["row1sm0"]; ?>>
<img id="row2sm0" src=<?php echo "uploads/sm/" . $_SESSION["row2sm0"]; ?>>
<img id="row3sm6" src=<?php echo "uploads/sm/" . $_SESSION["row3sm6"]; ?>>

<script type="text/javascript">
var i;
var x;
for (i = 0; i < 15 i++) {
    for (x = 0; x < 15 i++) {
        Tesseract.recognize("row" + i + "sm" + x)
        .then(function(result){
            console.log(result.text);
            document.write(result.text);
        })
    }
}
</script>

</body>
</html>

此代码适用于拼字游戏机器人,我的输入(来自上传文件的 OCR)有效,但不幸的是,由于似乎在空行中的语法错误,我被卡住了。我询问这可能是由于我正在使用的脚本类型,我尝试使用 type="module" 但这也不起作用。

你的两个 for 循环都缺少一个分号。

代码不正确:

for (i = 0; i < 15 i++) {
    for (x = 0; x < 15 i++) {
        Tesseract.recognize("row" + i + "sm" + x)
        .then(function(result){
            console.log(result.text);
            document.write(result.text);
        })
    }
}

更正代码:

for (i = 0; i < 15; i++) {
    for (x = 0; x < 15; i++) {
        Tesseract.recognize("row" + i + "sm" + x)
        .then(function(result){
            console.log(result.text);
            document.write(result.text);
        })
    }
}