Uncaught SyntaxError: Unexpected identifier in empty line?

Liam Weitzel

I am getting a syntax error in line 40... I have no clue why, this script only works with all of the other files aswell (too many, cant upload). It is not the best or prettiest but please give it a try.

ERROR:

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>

This code is meant for a scrabble bot, I have got the input (OCR from uploaded file) working but unfortunatly I am stuck due to a syntax error which seems to be in an empty line. I inquired that it might be due to the script type that I am using, I tried using type="module" but this did not work either.

Guillaume Georges

Both your for loops are missing a semicolon.

Incorrect code :

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);
        })
    }
}

Corrected code :

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);
        })
    }
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Uncaught SyntaxError: Invalid or unexpected token for new line

"Uncaught SyntaxError: Unexpected identifier"

Uncaught SyntaxError: Unexpected token ) on line 5

JS carousel - Uncaught SyntaxError: Unexpected identifier

Firebase: Uncaught SyntaxError: Unexpected identifier

Script error : "Uncaught SyntaxError: Unexpected identifier"

Uncaught SyntaxError: Unexpected identifier (imported class in javascript)

Uncaught SyntaxError: Unexpected identifier - Webshare api

Uncaught SyntaxError: Unexpected identifier with import statement

Uncaught SyntaxError: Unexpected identifier at compute

How to fix "Uncaught SyntaxError: Unexpected identifier" on yield

Using eval() - Uncaught SyntaxError: Unexpected identifier at pageLoad

Uncaught SyntaxError: Unexpected identifier (Javascript Objects)

Uncaught SyntaxError: Unexpected end of input on line one

Uncaught SyntaxError, Unexpected Identifier in for loop in jade

Uncaught SyntaxError: Unexpected identifier IN Chrome

Uncaught SyntaxError: Unexpected identifier on ajax jquery

Embeddin PHP into Javascript ,Uncaught SyntaxError: Unexpected identifier

Uncaught SyntaxError: Unexpected identifier

What's causing `Uncaught SyntaxError: Unexpected identifier`?

Javascript Uncaught SyntaxError: Unexpected identifier

Uncaught SyntaxError: Unexpected identifier in html

jQuery ajax var line - Uncaught SyntaxError: Unexpected identifier

JavaScript error Uncaught SyntaxError: Unexpected identifier

Getting error as Uncaught SyntaxError: Unexpected identifier

Comments send AJAX Uncaught SyntaxError: Unexpected identifier

SyntaxError: Unexpected identifier (line 11, file "DeleteFiles")

Uncaught SyntaxError: Unexpected identifier within bookmarklet

Node js Uncaught SyntaxError: Unexpected identifier