RE: [PHP] Complex escape string

2008-05-03 Thread Steven R. Ringwald
-Original Message-
From: cyaugin [mailto:[EMAIL PROTECTED] 
Sent: Saturday, May 03, 2008 10:20 AM
To: php-general@lists.php.net
Subject: [PHP] Complex escape string

I have this line of code:

$q = "This is the string that will go into the query:
{${mysql_real_escape_string($_GET['searchstring'])}}";

What happens then is the user supplies 'foo' as the search string, and I get
a debug notice "Undefined variable: foo". Why is it treating the value as an
identifier and how do I make it do what I actually want it to do? This is on
PHP5, latest release.




---

It looks to me like what is happening is this piece:
${mysql_real_escape_string($_GET['searchstring'])}

Gets collapsed to $foo when mysql_real_escape_string($_GET['searchstring'])
== 'foo'. ${'a'} will expand to $a. I think that your problem is that you
need to drop that '$' before the brace around the function call.





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] RE: XHTML Validation problem

2008-05-02 Thread Steven R. Ringwald
>>> I have a page that displays data entered by the user. There is one  
>>> user that entered the character "&" inside the text he typed. For  
>>> this case the xhtml validation fails and gives me the following  
>>> error:
>>> "character "&" is the first character of a delimiter but occurred  
>>> as data."
>>>
>>> I'm wondering if there is a way to avoid this error. The page  
>>> itself is valid and fails just in the case the user enters the &  
>>> character.

> Try replacing the '&' character with ' '. That is what I did to get rid
> of that warning in my xhtml documents.

Sorry y’all. I meant to say & rather than  . Ought to teach me to 
check email before eating dinner. ☺

Steve



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] XHTML Validation problem

2008-05-02 Thread Steven R. Ringwald

Begin forwarded message:

>> I have a page that displays data entered by the user. There is one  
>> user that entered the character "&" inside the text he typed. For  
>> this case the xhtml validation fails and gives me the following  
>> error:
>> "character "&" is the first character of a delimiter but occurred  
>> as data."
>>
>> I'm wondering if there is a way to avoid this error. The page  
>> itself is valid and fails just in the case the user enters the &  
>> character.





Try replacing the '&' character with ' '. That is what I did to get rid
of that warning in my xhtml documents.


Steve




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php