RE: Double quotes and HTML

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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:kzhiwei@xxxxxxxxxxxxxx] 
Sent: quinta-feira, 17 de Novembro de 2005 06:59
To: php-windows@xxxxxxxxxxxxx
Subject:  Double quotes and HTML

Content-type: text/plain; charset=us-ascii
Content-transfer-encoding: 7bit
Precedence: bulk
Delivered-to: mailing list php-windows@xxxxxxxxxxxxx
Delivered-to: ezmlm-scan-php-windows@xxxxxxxxxxxxx
Delivered-to: ezmlm-php-windows@xxxxxxxxxxxxx
Thread-index: AcXrRGdMNZ3jMfuSReKEZUx0+urWLA==
Mailing-List: contact php-windows-help@xxxxxxxxxxxxx; 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:php-windows@xxxxxxxxxxxxx>
List-Unsubscribe: <mailto:php-windows-unsubscribe@xxxxxxxxxxxxx>
List-Help: <mailto:php-windows-help@xxxxxxxxxxxxx>

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


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux