For Programmers: Free Programming Magazines  


Home > Archive > PHP Language > July 2004 > Newbie Parse Error Question









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Newbie Parse Error Question
Vik Rubenfeld

2004-06-30, 8:57 pm

This code works correctly in plain HTML, but in PHP mode, I get a parse
error on the line first line (<form name="menu" action="index.php"
method="POST"> ):

<?php
<form name="menu" action="index.php" method="POST">
<input type="checkbox" name="UseRollingAverages" value="1">

Include Rolling Averages

<br/><br/>
<input type="submit" name="submit" value="Evaluate">
</form>
?>

How do I correct this?

Thanks in advance to all for any info.

-Vik
Michael Vilain

2004-06-30, 8:57 pm

In article <vikr-C744F3.12575430062004@news1.west.earthlink.net>,
Vik Rubenfeld <vikr@mindspring.com.invalid> wrote:

> This code works correctly in plain HTML, but in PHP mode, I get a parse
> error on the line first line (<form name="menu" action="index.php"
> method="POST"> ):
>
> <?php
> <form name="menu" action="index.php" method="POST">
> <input type="checkbox" name="UseRollingAverages" value="1">
>
> Include Rolling Averages
>
> <br/><br/>
> <input type="submit" name="submit" value="Evaluate">
> </form>
> ?>
>
> How do I correct this?
>
> Thanks in advance to all for any info.
>
> -Vik


in php mode, the php interpeter sees the HTML and thinks it's php code
to interpet and execute.

Remove the <?php and ?>

Then go buy a php book.

--
DeeDee, don't press that button! DeeDee! NO! Dee...



Vik Rubenfeld

2004-06-30, 8:57 pm

> in php mode, the php interpeter sees the HTML and thinks it's php code
> to interpet and execute.
>
> Remove the <?php and ?>
>
> Then go buy a php book.


I have PHP5 and MySQL Bible, by Tim Converse, Joyce Park and Clark
Morgan, a 1000-page document, on my desk.

I've previously learned in this forum, that form fields can be
initialized from PHP variables, for example:

<input type=text name="foo" value="{$_POST["foo"]}">

So my question is, how can I reference the PHP variables, if I remove
the <?php and ?> as you advise?

-Vik
ian

2004-07-01, 3:55 am

"Vik Rubenfeld" <vikr@mindspring.com.invalid> wrote in message
news:vikr-BAF68F.14451630062004@news1.west.earthlink.net...
> I've previously learned in this forum, that form fields can be
> initialized from PHP variables, for example:
>
> <input type=text name="foo" value="{$_POST["foo"]}">
>
> So my question is, how can I reference the PHP variables, if I remove
> the <?php and ?> as you advise?
>
> -Vik



<input type=text name="foo" value="<?php $foo ?>">

etc...


Dafydd Monks

2004-07-01, 3:55 am

The form is outside the block of executable code IE, "<?php ?> and in the
plain HTML, with the action of the form being the file name of the page all
this is on - the form is not in the PHP program.

However, It can be - If you use "echo '#html content here';

Note, if you use ' instead of " as I have demonstrated here, you dont' have
to change all the " in your HTML - a useful little trick.

Have Fun!

DafyddMonks,
DragonDesigns.org.uk
"Vik Rubenfeld" <vikr@mindspring.com.invalid> wrote in message
news:vikr-BAF68F.14451630062004@news1.west.earthlink.net...
>
> I have PHP5 and MySQL Bible, by Tim Converse, Joyce Park and Clark
> Morgan, a 1000-page document, on my desk.
>
> I've previously learned in this forum, that form fields can be
> initialized from PHP variables, for example:
>
> <input type=text name="foo" value="{$_POST["foo"]}">
>
> So my question is, how can I reference the PHP variables, if I remove
> the <?php and ?> as you advise?
>
> -Vik



Dafydd Monks

2004-07-01, 3:55 am

Of course you can echo and use this syntax to add PHP things to the output,
here;s an example;

echo '<form things' + $var + 'rest of form data>'

so you have three things, output, the variable, which will be pronted as
output, and the rest of the output!

Ain't PHP good?

Dafydd Monks,
DragonDesigns.org.uk
"Dafydd Monks" <dafydd.monks@dragondesigns.org.uk> wrote in message
news:cbvt77$v70$1@newsg3.svr.pol.co.uk...
> The form is outside the block of executable code IE, "<?php ?> and in the
> plain HTML, with the action of the form being the file name of the page

all
> this is on - the form is not in the PHP program.
>
> However, It can be - If you use "echo '#html content here';
>
> Note, if you use ' instead of " as I have demonstrated here, you dont'

have
> to change all the " in your HTML - a useful little trick.
>
> Have Fun!
>
> DafyddMonks,
> DragonDesigns.org.uk
> "Vik Rubenfeld" <vikr@mindspring.com.invalid> wrote in message
> news:vikr-BAF68F.14451630062004@news1.west.earthlink.net...
>
>



eclipsboi

2004-07-01, 3:55 am

You shouldn't use + to concat strings together. + as concat is for
JavaScript, and . is concat for PHP.

On Thu, 1 Jul 2004 03:38:47 +0100, "Dafydd Monks"
<dafydd.monks@dragondesigns.org.uk> wrote:

>echo '<form things' + $var + 'rest of form data>'


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com