This is a discussion on First script - basic question within the PHP Language forums, part of the PHP Programming Forums category; Hi, I created an HTML page with the following code: <html> <body> <form action="...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hi,
I created an HTML page with the following code: <html> <body> <form action="everif.php" method="post"> Name: <input type="text" name="name" size="12"><br> First name: <input type="text" name="fname" size="12"> <input type="submit" value="OK"> </form> </body> </html> and everif.php contains: <?php $fname= $_POST['fname']; $name= $_POST['name']; echo("<center>Hi $fname $name</center>"); ?> When I press OK from the HTML page 1 get: Parse error: parse error, unexpected T_VARIABLE in /var/www/free.fr/d/c/parispain/everif.php on line 2 where line 2 is: $fname= $_POST['fname']; Why? Thank you. |
|
|||
|
> <?php
> $fname= $_POST['fname']; > $name= $_POST['name']; > echo("<center>Hi $fname $name</center>"); > ?> > > > When I press OK from the HTML page 1 get: > Parse error: parse error, unexpected T_VARIABLE in > /var/www/free.fr/d/c/parispain/everif.php on line 2 > > where line 2 is: > $fname= $_POST['fname']; I am not sure but first of all you should check if $_POST['fname']; is set . so it should be somthing like : if (isset($_POST['fname'])) $fname = $_POST['fname']; else $fname = ""; the same for the $_POST['name'] Try that ... but then again I am not sure if it solves your problem!!! |
|
|||
|
loic_e_bertrand@yahoo.fr wrote:
> (snip) > everif.php contains: > <?php > $fname= $_POST['fname']; > $name= $_POST['name']; > echo("<center>Hi $fname $name</center>"); > ?> > > When I press OK from the HTML page 1 get: > Parse error: parse error, unexpected T_VARIABLE in > /var/www/free.fr/d/c/parispain/everif.php on line 2 Your code looks Ok to me. You don't need any brackets in the echo statement, but it doesn't really matter. Perhaps there's a problem with the line breaks in your PHP source. I think PHP likes to see a carriage return and linefeed at the end of every line. Some editors (especially on Mac systems) use carriage returns but no linefeeds. -- phil [dot] ronan @ virgin [dot] net http://vzone.virgin.net/phil.ronan/ |
|
|||
|
Philip Ronan wrote:
> Perhaps there's a problem with the line breaks in your PHP source. I think > PHP likes to see a carriage return and linefeed at the end of every line. > Some editors (especially on Mac systems) use carriage returns but no > linefeeds. Who told you that? You can write a whole PHP script all on line without any newlines or carriage returns if you want. -- Oli |
|
|||
|
On Tue, 17 May 2005 09:56:07 +0000 (UTC), Angelos wrote:
>> echo("<center>Hi $fname $name</center>"); > > And This is not going to echo your $fname and $name ... Yes it is. > Do that: echo ("Hello".$fname." ".$name); No, no need for that when using double quotes. -- Firefox Web Browser - Rediscover the web - http://getffox.com/ Thunderbird E-mail and Newsgroups - http://gettbird.com/ |
|
|||
|
On Tue, 17 May 2005 11:12:10 +0100, Philip Ronan wrote:
>> <?php >> $fname= $_POST['fname']; >> $name= $_POST['name']; >> echo("<center>Hi $fname $name</center>"); >> ?> >> >> When I press OK from the HTML page 1 get: >> Parse error: parse error, unexpected T_VARIABLE in >> /var/www/free.fr/d/c/parispain/everif.php on line 2 > > Your code looks Ok to me. Me too. Did you copy and paste the code in your news post, or type it? Your error could be from one space too many, for example after <? or $. -- Firefox Web Browser - Rediscover the web - http://getffox.com/ Thunderbird E-mail and Newsgroups - http://gettbird.com/ |
|
|||
|
Oli Filth wrote:
> Philip Ronan wrote: >> Perhaps there's a problem with the line breaks in your PHP source. I > think >> PHP likes to see a carriage return and linefeed at the end of every > line. >> Some editors (especially on Mac systems) use carriage returns but no >> linefeeds. > > Who told you that? You can write a whole PHP script all on line without > any newlines or carriage returns if you want. I just seem to recall having a few parse errors of my own before I set my text editor up to use DOS line breaks. I can't see what else could be wrong with the OP's script. Can you? -- phil [dot] ronan @ virgin [dot] net http://vzone.virgin.net/phil.ronan/ |