• Howdy! Welcome to our community of more than 130.000 members devoted to web hosting. This is a great place to get special offers from web hosts and post your own requests or ads. To start posting sign up here. Cheers! /Peo, FreeWebSpace.net
managed wordpress hosting

What's wrong with this PHP code?

coolblu

Member
Hi all.

I can't see what the problem with this code might be. Can anyone help?

I get the following error when the file is run:

Parse error: parse error in /path/to/my_directory/ja/add3.php on line 92

I think this relates to the end statement:
PHP:
?>
but I can't see what else is wrong with the code.

Thanks

Nick

P.S. I have included the code in the attached file bad.txt
 

Attachments

  • bad.txt
    2.8 KB · Views: 30
The syntax for most of your print lines is wrong, i.e there isn't any.

You can't just

PHP:
print <HTML>

Such as

PHP:
print <<<END

<FORM action="add.php" method="GET">

etc

For a start, each php statement needs to end with a semicolon, so

PHP:
print ('<<<END<br><FORM action="add.php" method="GET">');

and so on ....
 
That syntax of:

PHP:
print <<<END
This is what I want to print
END;

seems to be fine when it is run through PHP and doesn't cause any errors in other applications I have used it in :confused5

BTW would it not follow that the last "END" has the semicolon and is therefore just the same as the php statement you gave as an example?
 
seems to be fine when it is run through PHP

huh?

I've told you what's wrong, there's not even any quotes in half those lines so it's trying to process them as standalone commands, which obviously they are not.

What are you viewing your code in? any editor that hightlights php properly would make it obvious what the problem is.

http://php.net/manual/en/language.basic-syntax.php

I'm not sure what you're trying to do with "end" end will basically point to the last element in an array, for example.

PHP:
<?

  $days = array('monday', 'tuesday', 'wednesday', 'thursday');
   
  print end($days);
     
?>

would print "thursday"

* edit, sorry if i sound grumpy, long day :cry2:
 
Last edited:
Back
Top