|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Parse Error
echo "
<html> <head> <title>Post Your Reply in $topic_title</title> </head> <body> <h1>Post Your Reply in $topic_title</h1> <form method=post action=\"$_SERVER['PHP_SELF']\"> <p><strong>Your Email Address:</strong><br /></p> <input type=\"text\" name=\"post_owner\" size=40 maxlenght=150 /> <p><strong>Post Text:</strong><br /> <textarea name=\"post_text\" rows=8 cols=40 wrap=virtual></textarea></p> <input type=\"hidden\" name=\"op\" value=\"addpost\" /> <input type=\"hidden\" name=\"topic_id\" value=\"$topic_id\" /> <p><input type= \"submit\" name=\"submit\" value=\"Add Post\" /></p> </form> </body> </html>"; I am getting the following error msg on the highlighted line "Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in" If someone could advise it would be greatfully appreciated. |
|
#2
|
||||
|
||||
|
variables used within quoted string you SHOULD put curly braces around them i.e
<form method=post action=\"{$_SERVER['PHP_SELF']}\"> for the most part it's only needed for arrays within a quoted string, but for good coding I'd recommened using them for all variables within a quoted string, here is how your code would look rewritten. PHP Code:
around thing I'd recommend AGAINST using echo for printing out large portions of html like this, instead use heredoc this way you can avoid using all the backslashes PHP Code:
|
|
#3
|
|||
|
|||
|
cheers Viper you are a lifesaver
|
|
#4
|
|||
|
|||
|
Hey Viper_SB! I was just looking at your post and I have to say, it's one hell of an explanation. I wanted to congratulate you for that. Many people wouldn't go through the trouble of rewriting the code, specialy with colors (how Kindergarten of you!!
)Anyway...congratulations and good luck to all of you! Anibal. |
|
#5
|
|||
|
|||
|
Quote:
This was a great post. Would you mind just explaining the reason for the curly braces? I'm a fairly new programmer and I've not done this before. I'm just wondering if I should fix all my old code. ![]() Thanks. |
![]() |
| Viewing: Dev Articles Community Forums > Programming > PHP Development > Parse Error |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|