Questions tagged [syntax-error]

A syntax error occurs when a program does not follow the syntactical rules of the programming language.

Syntax errors are often caused by a spelling mistake, missing characters (such as a closing parenthesis), or badly indented code.

The compiler/interpreter of the program often displays the position of the syntax error. However, in complex projects, this indication is not guaranteed to be correct. For instance, a missing token at line 7 can be compensated by the appearance of the same token at line 10. Some compiler/interpreters continue processing the code and throw a syntax error at the end, because of a missing token.

In some cases, combining multiple syntactically-invalid code pieces can result in syntactically-valid code containing logical errors. Debugging these kinds of errors is often difficult, because the compiler/interpreter usually doesn't recognize such mistakes.

9465 questions
1976
votes
27 answers

How do I get PHP errors to display?

I have checked my PHP ini file (php.ini) and display_errors is set and also error reporting is E_ALL. I have restarted my Apache webserver. I have even put these lines at the top of my script, and it doesn't even catch simple parse errors. For…
Abs
  • 56,052
  • 101
  • 275
  • 409
766
votes
20 answers

PHP parse/syntax errors; and how to solve them

Everyone runs into syntax errors. Even experienced programmers make typos. For newcomers, it's just part of the learning process. However, it's often easy to interpret error messages such as: PHP Parse error: syntax error, unexpected '{' in…
mario
  • 144,265
  • 20
  • 237
  • 291
642
votes
11 answers

PHP expects T_PAAMAYIM_NEKUDOTAYIM?

Does anyone have a T_PAAMAYIM_NEKUDOTAYIM?
Peter Turner
  • 11,199
  • 10
  • 68
  • 109
549
votes
5 answers

Why is whitespace sometimes needed around metacharacters?

A few months ago I tattooed a fork bomb on my arm, and I skipped the whitespaces, because I think it looks nicer without them. But to my dismay, sometimes (not always) when I run it in a shell it doesn't start a fork bomb, but it just gives a syntax…
spydon
  • 9,372
  • 6
  • 33
  • 63
494
votes
10 answers

Error "(unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape"

I'm trying to read a CSV file into Python (Spyder), but I keep getting an error. My code: import csv data = open("C:\Users\miche\Documents\school\jaar2\MIK\2.6\vektis_agb_zorgverlener") data = csv.reader(data) print(data) I get the following…
Miesje
  • 4,937
  • 3
  • 10
  • 7
457
votes
10 answers

How to correct TypeError: Unicode-objects must be encoded before hashing?

I have this error: Traceback (most recent call last): File "python_md5_cracker.py", line 27, in m.update(line) TypeError: Unicode-objects must be encoded before hashing when I try to execute this code in Python 3.2.2: import hashlib,…
JohnnyFromBF
  • 9,873
  • 10
  • 45
  • 59
338
votes
39 answers

Visual Studio displaying errors even if projects build

I have a problem with Visual Studio on a C# solution. It displays totally random errors, but the projects build. Right now, I have 33 files with errors, and I can see red squiggly lines in all of them. I tried cleaning / rebuilding the solution,…
Cydrick Trudel
  • 9,957
  • 8
  • 41
  • 63
274
votes
11 answers

No visible cause for "Unexpected token ILLEGAL"

I'm getting this JavaScript error on my console: Uncaught SyntaxError: Unexpected token ILLEGAL This is my code: var foo = 'bar';​ It's super simple, as you can see. How could it be causing a syntax error?
bfavaretto
  • 71,580
  • 16
  • 111
  • 150
251
votes
11 answers

JavaScript error (Uncaught SyntaxError: Unexpected end of input)

I have some JavaScript code that works in FireFox but not in Chrome or IE. In the Chrome JS Console I get the follow error: "Uncaught SyntaxError: Unexpected end of input". The JavaScript code I am using is: