HTML Basix - HTML tutorials and online webmaster tools

Htaccess code generators Code generators Tutorials

Online and offline code generators

Subscribe to RSS feed
Subscribe to the HTML Basix RSS feed.

Internal Server Errors

Syntax errors

The dreaded syntax error. This is where you need a crash course on programming. There's something wrong in there somewhere which needs changing, and you have to know what it is. Here's where line numbers are everything, and notepad just won't cut it. Pick up a good html editor that gives you the option to display line numbers, it will save you a hell of a lot of time counting the lines out (especially when the error is on line 2075!!).

syntax error at test.cgi line 12, near "my "

Line 12 is: my $browser;
This one is usually a missing semi-colon(';') at the end of the previous line. As it's hard to have an error at the start of the line unless there's something desperately wrong, chances are it's at the end of the previous line. Check the line number before the line number stated in this error to see if it has a semi-colon at the end of it.

syntax error at test.cgi line 41, near ""black":"

The code:
    41: my $color = "black":

The problem here is as the error states - an error with ""black":" The problem here is a colon was used instead of a semi-colon at the end of the line. Easy to do, but it will throw an error every time.

It should be:
    my $color = "black";

syntax error at test.cgi line 50, near ")

The code:

    50: (
not a lot to go on there, let's look up one line:
    49: foreach $line(@lines)
    50: (
Now that's more like it - when you use a 'foreach', it should be:
'foreach $variable(@variables){...}'.
The error states that a '(' has been used instead of a '{'. These lines should look like:
    foreach $line(@lines)

Unmatched right curly bracket at test.cgi line 144, at end of line

You have either an extra '}' in where it shouldn't be, on line 144, or you have missed an opening '{' further up. If there were no other errors reported before this error, you could safely assume that there is no opening one missing further up, or else it would have thrown errors before this. In this case, just remove the extra one at line 144. If it threw earlier errors, check what line it occured on and put the '{' in where it's needed (usually afer an if(...) or foreach(...)

syntax error at test.cgi line 239, near "else"
syntax error at test.cgi line 242, near "}"

The lines are:

    235: foreach ($line(@lines){
    236: if ($color eq "black")
    237:     {
    238:     $color = "white";
    239: else
    240:     {
    241:     $color = "black";
    242:     }
    242: }
If you look at the above code on line 239, you will see only the word 'else'. Nothing wrong with that, so look up a line. There is a missing '}' in the 'if($color eq "black"){$color = "white"' bit. Change it to
    foreach ($line(@lines){
    if ($color eq "black")
        $color = "white";
        $color = "black";

and it will fix this problem.

The error at line 242 was reported because the balance of opening and closing parenthesis was messed up.

<< debugging your script Let's look at some other errors >>

Site Stats     
Total: 9,637,839 Total: 27,994,867
Today: 344 Today: 1,378
Yesterday: 500 Yesterday: 1,674
Past Month: 15,500 Past Month: 51,894

551 visitors in the last 24 hours
This page has been visited 6,012 times
There are currently 2 visitors online
click to see where
most people online at once:
286 visitors on 06/27/2012
   You beaut

This site is © HTML Basix 2003 - 2009