[b]"Getting a Parse error in my code - what am I missing?"[/b] or [b]"Parse error: unexpected token - how do I fix

20 Replies, 1072 Views

"Parse error on line 15 - any idea what's causing this?"

Hey folks,

I'm stuck with a parse error in my script and can't figure out what's tripping it up. The error points to line 15, but everything *looks* fine to me?

Here's the snippet:
```
if ($x == 10 {
echo "Done";
}
```
Yeah, I know, probably something dumb lol. But my brain's fried from staring at it.

Anyone spot the issue? Missing a bracket? Wrong syntax?

Thanks in advance!

---

OR

"Help! My script throws a parse error - where should I look first?"

Ugh, parse error strikes again.

It says *"unexpected '}' on line 22"* but I don’t see anything weird there.

Common culprits I’ve checked:
- Missing semicolons
- Mismatched brackets/quotes
- Typos in keywords

Still no luck. Any tips for debugging this?

Code’s a mess rn, but here’s the gist:
```
function foo() {
return "bar"
}
```

Am I blind or what? 😅

---

OR

"Parse error: unexpected token - how do I fix this?"

Keep getting this parse error and it’s driving me nuts.

Error: *"unexpected T_STRING"* near `$var = new Thing();`

Thing is, `Thing` *is* a valid class!

Weird part? It works on my local machine but not on the server. PHP versions match too.

Any clues? Could it be a file encoding thing?

Thanks y’all!

Messages In This Thread
[b]"Getting a Parse error in my code - what am I missing?"[/b] or [b]"Parse error: unexpected token - how do I fix - by - 31-08-2024, 09:01 PM



Users browsing this thread: 1 Guest(s)