There is nothing wrong with escaping the quotes.
Your problem is a bad syntax.
You need to "execute" the $_POST command, not print it.
Try this
if (isset($_POST["user_id"]))
echo "<br><input type='text' name='user_id' size='40' maxlength='15'
value='{$_POST['user_id']}'>";
else
echo "<br><input type='text' name='user_id' size='40'
maxlength='15'>";
Luis
-----Original Message-----
From: Wayne Khan [mailto:[EMAIL PROTECTED]
Sent: quinta-feira, 17 de Novembro de 2005 06:59
To: [email protected]
Subject: [PHP-WIN] Double quotes and HTML
Content-type: text/plain; charset=us-ascii
Content-transfer-encoding: 7bit
Precedence: bulk
Delivered-to: mailing list [email protected]
Delivered-to: [EMAIL PROTECTED]
Delivered-to: [EMAIL PROTECTED]
Thread-index: AcXrRGdMNZ3jMfuSReKEZUx0+urWLA==
Mailing-List: contact [EMAIL PROTECTED]; run by ezmlm
X-Host-Fingerprint: 216.92.131.4 lists.php.net
X-Host-Fingerprint: 165.21.6.24 smtp14.singnet.com.sg Linux 2.4/2.6
List-Post: <mailto:[email protected]>
List-Unsubscribe: <mailto:[EMAIL PROTECTED]>
List-Help: <mailto:[EMAIL PROTECTED]>
Hi all,
I'm rather new to PHP... Am taking a maximal PHP, minimal HTML approach;
came from a C/Java background.
I'm use a staged (e.g. stage1, stage2) forms page for the creation of new
user accounts, so I'm getting variables out of $_POST if there are any.
Problem is... I'm getting a weird parse error:
Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or
`T_NUM_STRING' in ...
My code is as follows:
1 if (isset($_POST["user_id"]))
2 echo "<br><input type='text' name='user_id' size='40'
maxlength='15' value='$_POST[\"user_id\"]'>";
3 else
4 echo "<br><input type='text' name='user_id' size='40'
maxlength='15'>";
I know it has something to do with line 2, because HTML does not support the
use of slashes to escape double quotes. I guess the solution would be to
simply declare an additional variable and refer to it in the if..else part.
1 $user_id = $_POST["user_id"];
2
3 if (isset($_POST["user_id"]))
4 echo "<br><input type='text' name='user_id' size='40'
maxlength='15' value='$user_id'>";
5 else
6 echo "<br><input type='text' name='user_id' size='40'
maxlength='15'>";
But it just seems so... Inelegant. Is there anyway I can just refer to
$_POST variables directly, instead of having to declare a new variable?
Thanks a lot! =)
--
PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit:
http://www.php.net/unsub.php
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php