Hi folks,
I'm very new to PHP and have been having trouble configuring my installation on Windows XP Professional. I have installed Apache HTTP Server 1.3.27 and am using PHP 4.2.3 using the Apache Module DLL (Sapi Module). I run Apache in a console window also (not as a service) and the status line at the top of the console window says "Apache/1.3.27 (Win32) PHP/4.2.3 running...
So it all appears fine to me and I have run some sample PHP scripts with no problems. However, as soon as I try to do something to do with variables like create a simple form and pass a variable from one to another it won't work.
My sample code is below;
test1.php
------------------------------------------------------------------------
<?php
# test1.php
echo "<FORM METHOD=\"POST\" ACTION=\"test2.php\">";
echo "<INPUT TYPE=\"TEXT\" NAME=\"var1\" VALUE=\"$var1\">";
echo "<INPUT TYPE=\"SUBMIT\" VALUE=\"TEST\">";
echo "</FORM>";
?>
test2.php
------------------------------------------------------------------------
<?php
# test2.php
echo "The value of \$var1 is \"$var1\"";
?>
My output is always;
The value of $var1 is ""
I have experimented with POST and GET and neither helps, so I have come to the conclusion that somewhere in my configuration of PHP with Apache I have gone wrong... I am getting a little bit frustrated and would appreciate any help that can be offered. Thanks in advance!
Cheers,
Adrian.
email: letsdosomethingthatreallycooks@hotmail.com.
Passing Variables Between Forms.
Moderator: General Moderators
- Bill H
- DevNet Resident
- Posts: 1136
- Joined: Sat Jun 01, 2002 10:16 am
- Location: San Diego CA
- Contact:
Try:
I'd suggest you read the sticky posts at the top of this forum.
Specifically, viewtopic.php?t=511
.
Code: Select all
<?php
echo "The value of \$var1 is "$_POSTї'var1']"";
?>Specifically, viewtopic.php?t=511
.
Thanks Bill,
Just gave that a go and got this result...
"Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in c:\apache\htdocs\test2.php on line 4"
Is there any particular reason why my first test code shouldn't work? This was copied from a test I used with an older version of PHP and it worked fine.
Thanks!
Just gave that a go and got this result...
"Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in c:\apache\htdocs\test2.php on line 4"
Is there any particular reason why my first test code shouldn't work? This was copied from a test I used with an older version of PHP and it worked fine.
Thanks!
common mistake. read http://www.php.net/manual/en/language.t ... ng.parsing to learn more about it and try
ororI prefer the last one but that's matter of opinion.
Code: Select all
<?php
echo "The value of \$var1 is "$_POSTїvar1]"";
?>Code: Select all
<?php
echo "The value of \$var1 is "{$_POSTї'var1']}"";
?>Code: Select all
<?php
echo 'The value of $var1 is "', $_POSTї'var1'], '"';
?>Is this style of using string variables new?
Thanks a lot Volka! That works fine. I am still a little lost with how variables are being passed from form to form though.
Why does the following code echo FALSE? It used to echo TRUE with PHP 4.1.1?
test2.php
-----------------------------------------------------
<?php
# test2.php
if ($var1)
echo 'TRUE';
else
echo 'FALSE';
?>
Thanks for your help!
Why does the following code echo FALSE? It used to echo TRUE with PHP 4.1.1?
test2.php
-----------------------------------------------------
<?php
# test2.php
if ($var1)
echo 'TRUE';
else
echo 'FALSE';
?>
Thanks for your help!
that's the topic of the thread Bill H mentioned
viewtopic.php?t=511
viewtopic.php?t=511