Connecting Tech Pros Worldwide Forums | Help | Site Map

Help passing variables to other php pages

Mike
Guest
 
Posts: n/a
#1: Jul 17 '05
Hello, I am trying to write a script to pass the value of the variable $cost
to buy.php but I keep getting a parse error. Here is an example of what I am
trying to do:

$cost=5.45

echo "<Form Action="buy.php?Price=$cost" METHOD="POST">";

Hope someone can help

Thanks







Pertti Kosunen
Guest
 
Posts: n/a
#2: Jul 17 '05

re: Help passing variables to other php pages


"Mike" <thereis@noemail.com> wrote in message
news:40572eb6$0$28267$cc9e4d1f@news.dial.pipex.com ...[color=blue]
> Hello, I am trying to write a script to pass the value of the variable[/color]
$cost[color=blue]
> to buy.php but I keep getting a parse error. Here is an example of what I[/color]
am[color=blue]
>
> echo "<Form Action="buy.php?Price=$cost" METHOD="POST">";[/color]

echo "<Form Action=\"buy.php?Price=$cost\" METHOD=\"POST\">";

Add escape chars.


Alvaro G Vicario
Guest
 
Posts: n/a
#3: Jul 17 '05

re: Help passing variables to other php pages


*** Mike wrote/escribió (Tue, 16 Mar 2004 16:43:32 -0000):[color=blue]
> echo "<Form Action="buy.php?Price=$cost" METHOD="POST">";[/color]

Some ideas:

echo "<Form Action=\"buy.php?Price=$cost\" METHOD=\"POST\">";

echo '<Form Action="buy.php?Price='.urlencode($cost).'" METHOD="POST">';

echo '<Form Action="buy.php" METHOD="POST">';
echo '<input type="hidden" name="Price" value="'.$cost.'">';


--
-- Álvaro G. Vicario - Burgos, Spain
--
Pedro Graca
Guest
 
Posts: n/a
#4: Jul 17 '05

re: Help passing variables to other php pages


Mike wrote:[color=blue]
> but I keep getting a parse error. Here is an example of what I am
> trying to do:
>
> $cost=5.45
>
> echo "<Form Action="buy.php?Price=$cost" METHOD="POST">";[/color]
# ^_____________^ ^________^ ^_^

try

echo "<Form Action=\"buy.php?Price=$cost\" METHOD=\"POST\">";
# ^_____________--___________________--________--____--_^
--
USENET would be a better place if everybody read: : mail address :
http://www.catb.org/~esr/faqs/smart-questions.html : is valid for :
http://www.netmeister.org/news/learn2quote2.html : "text/plain" :
http://www.expita.com/nomime.html : to 10K bytes :
Allan Rydberg
Guest
 
Posts: n/a
#5: Jul 17 '05

re: Help passing variables to other php pages




do it properly!

print "<Form Action=\"buy.php?Price=" . $cost . "\" METHOD=\"POST\">\n";


Mike wrote:
[color=blue]
> Hello, I am trying to write a script to pass the value of the variable $cost
> to buy.php but I keep getting a parse error. Here is an example of what I am
> trying to do:
>
> $cost=5.45
>
> echo "<Form Action="buy.php?Price=$cost" METHOD="POST">";
>
> Hope someone can help
>
> Thanks
>
>
>
>
>
>[/color]

Richard Allsebrook
Guest
 
Posts: n/a
#6: Jul 17 '05

re: Help passing variables to other php pages


Mike wrote:
[color=blue]
> Hello, I am trying to write a script to pass the value of the variable $cost
> to buy.php but I keep getting a parse error. Here is an example of what I am
> trying to do:
>
> $cost=5.45
>
> echo "<Form Action="buy.php?Price=$cost" METHOD="POST">";
>
> Hope someone can help
>
> Thanks
>
>
>
>
>
>[/color]

Dont mess about with escaping your quotes (\") it makes the code messy
(IMHO) - try this instead:

echo "<Form Action='buy.php?Price=$cost' METHOD='POST'>";

Hope this helps

Submerged
Guest
 
Posts: n/a
#7: Jul 17 '05

re: Help passing variables to other php pages


Mike wrote:[color=blue]
> *Hello, I am trying to write a script to pass the value of th
> variable $cost
> to buy.php but I keep getting a parse error. Here is an example o
> what I am
> trying to do:
>
> $cost=5.45
>
> echo "<Form Action="buy.php?Price=$cost" METHOD="POST">";
>
> Hope someone can help
>
> Thanks *[/color]

sorry if this is below your level of intelligence, but i made thi
mistake when i was JUST beginning to deal witht the whole variable i
the URL stuff. Course, that was about 3 hours ago :P

anyways, make sure that the form is in a .php file, if its in an htm
file in wont work
-
Submerge
-----------------------------------------------------------------------
posted via www.WebFrustration.com

Closed Thread