[PHP] Escaping '#' Sign
I have a string I'm returning from a database. Some entries have # signs in the names ie (COMPANY #42, COMPANY #43...). When I display results all I have is COMPANY. Everything after the # is dropped off. I tried: If ($cust) { $cust2=ereg_replace('#','no',$cust); //tried $cust2=ereg_replace(#,no,$cust); too } but that still returns the same thing (COMPANY). Also tried: $cust2 = preg_replace ('(pound|#163);'i, chr(163), $cust); Any help is appreciated. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Escaping '#' Sign
Why don't you just try: $cust2 = str_replace('#','#35;',$cust); That should replace all instances of # with it's html entity equivalent. If that doesn¹t work then there is something else wrong with your script and we'll need to see it all! :) Rick People who drink to drown their sorrow should be told that sorrow knows how to swim. - Ann Landers I have a string I'm returning from a database. Some entries have # signs in the names ie (COMPANY #42, COMPANY #43...). When I display results all I have is COMPANY. Everything after the # is dropped off. I tried: If ($cust) { $cust2=ereg_replace('#','no',$cust); //tried $cust2=ereg_replace(#,no,$cust); too } but that still returns the same thing (COMPANY). Also tried: $cust2 = preg_replace ('(pound|#163);'i, chr(163), $cust); Any help is appreciated. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Escaping '#' Sign
Have to be a bit more specific, cause I can't reproduce your problem... Do you have some code examples that show it clearer? name for client is COMPANY #1 in DB ?php include dbconnect.inc; //sets up db connection $sel = mysql_query(select name from client where clntid='1000', $connection); $result = mysql_fetch_object($sel); $name = $result-name; echo This is the name: $namebr; ? Output: This is the name: COMPANY #1 A # sign is just another character in HTML, and all php is doing is creating the html for you. the # sign would only effect a difference in PHP code within the ?php ?, which when you are doing a query that doesn't happen. -- Tom On Wed, 11 Dec 2002 15:45:18 -0800 Mike Smith [EMAIL PROTECTED] wrote: I have a string I'm returning from a database. Some entries have # signs in the names ie (COMPANY #42, COMPANY #43...). When I display results all I have is COMPANY. Everything after the # is dropped off. I tried: If ($cust) { $cust2=ereg_replace('#','no',$cust); //tried $cust2=ereg_replace(#,no,$cust); too } but that still returns the same thing (COMPANY). Also tried: $cust2 = preg_replace ('(pound|#163);'i, chr(163), $cust); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Escaping characters won't work
Hello, Ernest E Vogelsinger [EMAIL PROTECTED] wrote: At 23:53 14.11.2002, Lars Espelid said: [snip] Try to execute this code: if (ereg[^0-9], $num)) print That's not a number!; result: parsing error, expects ')' on the if-line. You forgot an opening bracket, and need to quote the regex, like if (ereg('[^0-9]', $num)) print That's not a number!; I think I'm missing something here but while the regex might be correct, don't you think the print ... part is incorrect? I mean, _negative_ numbers are numbers, no? Wouldn't it be better just to use is_int() or is_numeric()? - E ...[snip]... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Escaping characters won't work
Hello, I'm running Apache 1.3.26, PHP 4.0.5 and WinXPpro. My problem is as follows: Try to execute this code: if (ereg[^0-9], $num)) print That's not a number!; result: parsing error, expects ')' on the if-line. Have also tried other expressions where I escape characters. They won't work. When I write: echo HELLO \n; echo WORLD; I get: HELLO WORLD (on one line!?) Anyone know what's wrong? Do I need to install an extension? Bottom of my httpd.conf: LoadModule php4_module c:/php/sapi/php4apache.dll AddModule mod_php4.c AddType application/x-httpd-php .php AddType application/x-httpd-php-source .phps Thanks, Lars -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Escaping characters won't work
Hello again... Lars Espelid wrote: Hello, I'm running Apache 1.3.26, PHP 4.0.5 and WinXPpro. My problem is as follows: Try to execute this code: if (ereg[^0-9], $num)) print That's not a number!; result: parsing error, expects ')' on the if-line. This one does have a parse error if ( ereg ( [^0-9], $num ) ) ^ Have also tried other expressions where I escape characters. They won't work. When I write: echo HELLO \n; echo WORLD; I get: HELLO WORLD (on one line!?) Anyone know what's wrong? Do I need to install an extension? Bottom of my httpd.conf: LoadModule php4_module c:/php/sapi/php4apache.dll AddModule mod_php4.c AddType application/x-httpd-php .php AddType application/x-httpd-php-source .phps Thanks, Lars -- By-Tor.com It's all about the Rush http://www.by-tor.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Escaping characters won't work
At 23:53 14.11.2002, Lars Espelid said: [snip] Try to execute this code: if (ereg[^0-9], $num)) print That's not a number!; result: parsing error, expects ')' on the if-line. You forgot an opening bracket, and need to quote the regex, like if (ereg('[^0-9]', $num)) print That's not a number!; When I write: echo HELLO \n; echo WORLD; I get: HELLO WORLD (on one line!?) You need to tell the browser to create a newline when displaying HTML: echo HELLObrWORLD will look identical to echo HELLObr\nWORLD You can also use the nl2br() function to convert all newlines to a line break: echo nl2br(HELLO\nWORLD); If you display preformatted text you'll see the linebreak: echo preHELLO\nWORLD/pre; -- O Ernest E. Vogelsinger (\)ICQ #13394035 ^ http://www.vogelsinger.at/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Escaping escaped chars
Im trying to move some binary strings from mysql to postgresql, and the binary strings has escape chars '\' in them. I was told to double escape them like so - '\\\' Here is what Im trying - $data = '\0PZ\0Îê˜Úµ'; // This is a representation from an mysql dump $data2 = str_replace('/\', '/\/\/\', $data); Im getting - Unexpected character in input: '\' (ASCII=92) state=1 I guess my str_replace() isn't correct. Am I going about the right way to double escape them. Thanks. -- Gerard Samuel http://www.trini0.org:81/ http://dev.trini0.org:81/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Escaping escaped chars
Just escape the \ with a single escape character. eg. your string '\0PZ\0Îê˜Úµ' would end up as '\\0PZ\\0Îê˜Úµ' - each \ simply escapes the backslash following it. If you add two backslashes, you end up with one too many which is what the error is referring to. ..micahel.. On Thu, 2002-06-20 at 10:59, Gerard Samuel wrote: Im trying to move some binary strings from mysql to postgresql, and the binary strings has escape chars '\' in them. I was told to double escape them like so - '\\\' Here is what Im trying - $data = '\0PZ\0Îê˜Úµ'; // This is a representation from an mysql dump $data2 = str_replace('/\', '/\/\/\', $data); Im getting - Unexpected character in input: '\' (ASCII=92) state=1 I guess my str_replace() isn't correct. Am I going about the right way to double escape them. Thanks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Escaping escaped chars
One of the guys over on the php-db list told me that to store the binary string correctly in postrgresql, that I would have to double quote whats already there. So in essence, by the time it hits the database, it has to be - \\\0PZ\\\0Îê˜Úµ Any suggestions to modify the string like this... Maybe I should be looking into one of the preg functions Thank You. Michael Sweeney wrote: Just escape the \ with a single escape character. eg. your string '\0PZ\0Îê˜Úµ' would end up as '\\0PZ\\0Îê˜Úµ' - each \ simply escapes the backslash following it. If you add two backslashes, you end up with one too many which is what the error is referring to. ..micahel.. On Thu, 2002-06-20 at 10:59, Gerard Samuel wrote: Im trying to move some binary strings from mysql to postgresql, and the binary strings has escape chars '\' in them. I was told to double escape them like so - '\\\' Here is what Im trying - $data = '\0PZ\0Îê˜Úµ'; // This is a representation from an mysql dump $data2 = str_replace('/\', '/\/\/\', $data); Im getting - Unexpected character in input: '\' (ASCII=92) state=1 I guess my str_replace() isn't correct. Am I going about the right way to double escape them. Thanks. -- Gerard Samuel http://www.trini0.org:81/ http://dev.trini0.org:81/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] escaping quotes in forms and redisplaying variables in form fields
I'm stumbling over how to allow people to put single or double quotes in a form text field. I am passing the form to itself ($PHP_SELF) and on the second time through previewing what the form data will look like and also re-creating the form with the data already filled in. Here's an example of one text field: $display_line .=input type='text' name='signature' value='$noslash_signature' size='35' maxlength='100'; (I have stripslashes() the $signature variable to create $noslash_signature.) If someone signs their name O'Brien, the preview shows O'Brien, but all that shows in the form field is O. However, Joe Bruiser Jones displays correctly in preview and the form. If I change the code like this (adding the \ around the variable): $display_line .=input type='text' name='signature' value=\$noslash_signature\ size='35' maxlength='100'; O'Brien will display OK, but Joe Bruiser Jones shows just Joe in the form field. One solution is to change the text form to textarea, but I'd prefer to be able to redisplay at text form field if possible. TIA, John Hughes __ Do You Yahoo!? Yahoo! Health - your guide to health and wellness http://health.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] escaping quotes in forms and redisplaying variables in form fields
See: http://www.php.net/manual/en/function.htmlspecialchars.php John Hughes wrote: I'm stumbling over how to allow people to put single or double quotes in a form text field. I am passing the form to itself ($PHP_SELF) and on the second time through previewing what the form data will look like and also re-creating the form with the data already filled in. Here's an example of one text field: $display_line .=input type='text' name='signature' value='$noslash_signature' size='35' maxlength='100'; (I have stripslashes() the $signature variable to create $noslash_signature.) If someone signs their name O'Brien, the preview shows O'Brien, but all that shows in the form field is O. However, Joe Bruiser Jones displays correctly in preview and the form. If I change the code like this (adding the \ around the variable): $display_line .=input type='text' name='signature' value=\$noslash_signature\ size='35' maxlength='100'; O'Brien will display OK, but Joe Bruiser Jones shows just Joe in the form field. One solution is to change the text form to textarea, but I'd prefer to be able to redisplay at text form field if possible. -- .-. | Robert Cummings | :-`. | Webdeployer - Chief PHP and Java Programmer | :--: | Mail : mailto:[EMAIL PROTECTED] | | Phone : (613) 731-4046 x.109 | :--: | Website : http://www.webmotion.com | | Fax : (613) 260-9545 | `--' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] escaping quotes in forms and redisplaying variables in form fields
Yeah, you have to convert the single and double quotes to html entities so they are not mistaken for the end of the string. If you look at your source code, you'll see why it's happening. value = 'O'Bryan' value = Joe Bruiser Smith You can see how the 'O' is taken as the string, and the rest is ignored. Same for the double quotes. ---John Holmes... - Original Message - From: Robert Cummings [EMAIL PROTECTED] To: John Hughes [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Monday, May 06, 2002 5:06 PM Subject: Re: [PHP] escaping quotes in forms and redisplaying variables in form fields See: http://www.php.net/manual/en/function.htmlspecialchars.php John Hughes wrote: I'm stumbling over how to allow people to put single or double quotes in a form text field. I am passing the form to itself ($PHP_SELF) and on the second time through previewing what the form data will look like and also re-creating the form with the data already filled in. Here's an example of one text field: $display_line .=input type='text' name='signature' value='$noslash_signature' size='35' maxlength='100'; (I have stripslashes() the $signature variable to create $noslash_signature.) If someone signs their name O'Brien, the preview shows O'Brien, but all that shows in the form field is O. However, Joe Bruiser Jones displays correctly in preview and the form. If I change the code like this (adding the \ around the variable): $display_line .=input type='text' name='signature' value=\$noslash_signature\ size='35' maxlength='100'; O'Brien will display OK, but Joe Bruiser Jones shows just Joe in the form field. One solution is to change the text form to textarea, but I'd prefer to be able to redisplay at text form field if possible. -- .-. | Robert Cummings | :-`. | Webdeployer - Chief PHP and Java Programmer | :--: | Mail : mailto:[EMAIL PROTECTED] | | Phone : (613) 731-4046 x.109 | :--: | Website : http://www.webmotion.com | | Fax : (613) 260-9545 | `--' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] escaping PHP's closing tags
Hi -- I'm trying to use a string of XML data which includes the use of the ?xml ? tags. I've noticed that my editor (BBEdit) shows that \? will escape the tag so that PHP does not treat it as a true close the PHP code tag, but was hoping that someone here could give me an official ruling. There is no reference to escaping the ? tag on the man page (currently) that I could find, or in the annotations. Erik Erik Price Web Developer Temp Media Lab, H.H. Brown [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Escaping Quotes in a String and Ending With A Quote
Well, this is a fairly simple problem. I'm having problems with escaping a string, and then ending the string right after the escape! For example, echo Then Johnathan said, \That's exactly what I said!\; I get a parse error on the line where the string is. Very simple problem, I just can't seem to solve it though. Maybe I'm going crazy =) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Escaping Quotes in a String and Ending With A Quote
On Tue, 19 Mar 2002, Dr. Shim wrote: Well, this is a fairly simple problem. I'm having problems with escaping a string, and then ending the string right after the escape! For example, echo Then Johnathan said, \That's exactly what I said!\; I get a parse error on the line where the string is. Very simple problem, I just can't seem to solve it though. Maybe I'm going crazy =) There's nothing wrong with that PHP code. Are you sure you really copied and pasted it directly from the problem code - or that the parse error isn't somewhere else? miguel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Escaping Quotes in a String and Ending With A Quote
Hmmm. How about this? echo form name=\frmMovies\ method=\post\ action=\ . echo $PHP_SELF . \; Miguel Cruz [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... On Tue, 19 Mar 2002, Dr. Shim wrote: Well, this is a fairly simple problem. I'm having problems with escaping a string, and then ending the string right after the escape! For example, echo Then Johnathan said, \That's exactly what I said!\; I get a parse error on the line where the string is. Very simple problem, I just can't seem to solve it though. Maybe I'm going crazy =) There's nothing wrong with that PHP code. Are you sure you really copied and pasted it directly from the problem code - or that the parse error isn't somewhere else? miguel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Escaping Quotes in a String and Ending With A Quote
You need to remove the second echo. On Tue, 19 Mar 2002, Dr. Shim wrote: Hmmm. How about this? echo form name=\frmMovies\ method=\post\ action=\ . echo $PHP_SELF . \; Miguel Cruz [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... On Tue, 19 Mar 2002, Dr. Shim wrote: Well, this is a fairly simple problem. I'm having problems with escaping a string, and then ending the string right after the escape! For example, echo Then Johnathan said, \That's exactly what I said!\; I get a parse error on the line where the string is. Very simple problem, I just can't seem to solve it though. Maybe I'm going crazy =) There's nothing wrong with that PHP code. Are you sure you really copied and pasted it directly from the problem code - or that the parse error isn't somewhere else? miguel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Escaping Quotes in a String and Ending With A Quote
On Tue, 19 Mar 2002, Dr. Shim wrote: Hmmm. How about this? echo form name=\frmMovies\ method=\post\ action=\ . echo $PHP_SELF . \; You're concatenating echo $PHP_SELF rather than just $PHP_SELF, which isn't necessarily helping. But just between me and you, life would be a lot easier if you simply did: echo 'form name=frmMovies method=post action=' . $PHP_SELF . ''; miguel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Escaping Quotes in a String and Ending With A Quote
Strangley enough, $PHP_SELF is empty. Nothing appears when I do it the way Bob and you suggested, the action property equals . Miguel Cruz [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... On Tue, 19 Mar 2002, Dr. Shim wrote: Hmmm. How about this? echo form name=\frmMovies\ method=\post\ action=\ . echo $PHP_SELF . \; You're concatenating echo $PHP_SELF rather than just $PHP_SELF, which isn't necessarily helping. But just between me and you, life would be a lot easier if you simply did: echo 'form name=frmMovies method=post action=' . $PHP_SELF . ''; miguel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Escaping Quotes in a String and Ending With A Quote
Are you inside a function, having neglected to do global $PHP_SELF; ? miguel On Tue, 19 Mar 2002, Dr. Shim wrote: Strangley enough, $PHP_SELF is empty. Nothing appears when I do it the way Bob and you suggested, the action property equals . Miguel Cruz [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... On Tue, 19 Mar 2002, Dr. Shim wrote: Hmmm. How about this? echo form name=\frmMovies\ method=\post\ action=\ . echo $PHP_SELF . \; You're concatenating echo $PHP_SELF rather than just $PHP_SELF, which isn't necessarily helping. But just between me and you, life would be a lot easier if you simply did: echo 'form name=frmMovies method=post action=' . $PHP_SELF . ''; miguel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Escaping Quotes in a String and Ending With A Quote
*screams, I'm such a newbie!!* I didn't know I had to declare $PHP_SELF with global before using it inside a function. Sorry! Works now! Thanks very much! =) Miguel Cruz [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Are you inside a function, having neglected to do global $PHP_SELF; ? miguel On Tue, 19 Mar 2002, Dr. Shim wrote: Strangley enough, $PHP_SELF is empty. Nothing appears when I do it the way Bob and you suggested, the action property equals . Miguel Cruz [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... On Tue, 19 Mar 2002, Dr. Shim wrote: Hmmm. How about this? echo form name=\frmMovies\ method=\post\ action=\ . echo $PHP_SELF . \; You're concatenating echo $PHP_SELF rather than just $PHP_SELF, which isn't necessarily helping. But just between me and you, life would be a lot easier if you simply did: echo 'form name=frmMovies method=post action=' . $PHP_SELF . ''; miguel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] escaping ?
this should work $contents = str_replace(?xml version=\1.0\?, , $contents); btw. a welformed xml documented uses a space between 1.0 and ? -Original Message- From: Martin Towell [mailto:[EMAIL PROTECTED]] Sent: Sunday, February 10, 2002 11:07 PM To: 'Steven Jarvis'; [EMAIL PROTECTED] Subject: RE: [PHP] escaping ? what about this? $contents = str_replace('?xml version=1.0?'.'', '', $contents); -Original Message- From: Steven Jarvis [mailto:[EMAIL PROTECTED]] Sent: Saturday, February 09, 2002 8:46 AM To: [EMAIL PROTECTED] Subject: [PHP] escaping ? I'm trying to do some string replaces on XML files to import them into a prprietary db that doesn't understand XML. I need to strip the XML tags out of the file. However, when I use this line: $contents = str_replace('?xml version=1.0?', '', $contents); The ? in the string ends my php block. I know there's an easy answer to this, and I'm probably just suffering from Friday afternoon burnout, but can someone let me know how to escape those so that I can search for them in the string? thanks, Steven -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php The information contained in this email is confidential and may be legally privileged. It is intended solely for the addressee. Access to this email by anyone else is unauthorized. If you are not the intended recipient, any form of disclosure, production, distribution or any action taken or refrained from in reliance on it, is prohibited and may be unlawful. Please notify the sender immediately. The content of the email is not legally binding unless confirmed by letter bearing two authorized signatures. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] escaping ?
what about this? $contents = str_replace('?xml version=1.0?'.'', '', $contents); -Original Message- From: Steven Jarvis [mailto:[EMAIL PROTECTED]] Sent: Saturday, February 09, 2002 8:46 AM To: [EMAIL PROTECTED] Subject: [PHP] escaping ? I'm trying to do some string replaces on XML files to import them into a prprietary db that doesn't understand XML. I need to strip the XML tags out of the file. However, when I use this line: $contents = str_replace('?xml version=1.0?', '', $contents); The ? in the string ends my php block. I know there's an easy answer to this, and I'm probably just suffering from Friday afternoon burnout, but can someone let me know how to escape those so that I can search for them in the string? thanks, Steven -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] escaping ?
I'm trying to do some string replaces on XML files to import them into a prprietary db that doesn't understand XML. I need to strip the XML tags out of the file. However, when I use this line: $contents = str_replace('?xml version=1.0?', '', $contents); The ? in the string ends my php block. I know there's an easy answer to this, and I'm probably just suffering from Friday afternoon burnout, but can someone let me know how to escape those so that I can search for them in the string? thanks, Steven -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] escaping ?
Hi, try this: str_replace(?xml version=\1.0\? Jeff At 03:45 PM 2/8/2002 -0600, Steven Jarvis wrote: I'm trying to do some string replaces on XML files to import them into a prprietary db that doesn't understand XML. I need to strip the XML tags out of the file. However, when I use this line: $contents = str_replace('?xml version=1.0?', '', $contents); The ? in the string ends my php block. I know there's an easy answer to this, and I'm probably just suffering from Friday afternoon burnout, but can someone let me know how to escape those so that I can search for them in the string? thanks, Steven -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Escaping a double-quote problem
Any idea why when I print the value of $text, I get a backslash in front of the result? $text=preg_replace(/\/, quot;, $text); $text=preg_replace(/\/, A, $text); $text=str_replace(\, A, $text); Contrary: $text=preg_replace(//, amp;, $text); works quite well. cheerz -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Escaping from
I'm tring to print the variable tmp, but the echo is just printing abcd, the rest he can't print. Why? regards, Augusto $tmp=abcdefg; echo $tmp.br; echo br; $tmp=addslashes($tmp); echo $tmp.br; echo br; $tmp=stripslashes($tmp); echo $tmp.br; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Escaping from
on 5/16/01 9:12 PM, Augusto Cesar Castoldi at [EMAIL PROTECTED] wrote: I'm tring to print the variable tmp, but the echo is just printing abcd, the rest he can't print. Why? regards, Augusto $tmp=abcdefg; echo $tmp.br; echo br; $tmp=addslashes($tmp); echo $tmp.br; echo br; $tmp=stripslashes($tmp); echo $tmp.br; Try htmlspecialchars() instead of addslashes(); $tmp=abcdefg; echo htmlspecialchars($tmp); -- /chris/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Escaping Characters
""Wade"" [EMAIL PROTECTED] wrote in message 9c6dcb$h8e$[EMAIL PROTECTED]">news:9c6dcb$h8e$[EMAIL PROTECTED]... Aside from " (quotes), which HTML characters should be preceded with a \ (backslash) to avoid parsing errors? No. I have the following, which I have in an .inc file outside my web root. I have tried sticking the \ in front of the # (pound) and the = (equal) -- not out of any reason, but more out of frustration. I have been sticking dropdown menu in inc files with no troubles, but this is the first table I've tried to stick in there. I'm trying not to ask questions here until after trying to find an answer in PHP.net, but I've had no luck on this one. ? table width=\"90%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\" tr bgcolor=\"#ebebd6\" ? Why you put HTML like this inside PHP code tag? If you need HTML. Try this ?php if ($var === TURE) { ? h1 $var is true /h1 ?php } else { ? h1 $var is false /h1 ?php } ? Regards, -- Yasuo Ohgaki Much Thanks, Wade -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] Escaping Characters
double quotes ' single quotes (yes, they are used quite often) \ backslash (JavaScripts etc.) there are your enemies, nothing else. forget about + = $ ... Sincerely, Maxim Maletsky Founder, Chief Developer PHPBeginner.com (Where PHP Begins) [EMAIL PROTECTED] www.phpbeginner.com -Original Message- From: Wade [mailto:[EMAIL PROTECTED]] Sent: Wednesday, April 25, 2001 8:47 PM To: [EMAIL PROTECTED] Subject: [PHP] Escaping Characters Aside from (quotes), which HTML characters should be preceded with a \ (backslash) to avoid parsing errors? I have the following, which I have in an .inc file outside my web root. I have tried sticking the \ in front of the # (pound) and the = (equal) -- not out of any reason, but more out of frustration. I have been sticking dropdown menu in inc files with no troubles, but this is the first table I've tried to stick in there. I'm trying not to ask questions here until after trying to find an answer in PHP.net, but I've had no luck on this one. ? table width=\90%\ border=\0\ cellspacing=\0\ cellpadding=\0\ align=\center\ tr bgcolor=\#ebebd6\ ? Much Thanks, Wade -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Escaping Characters
My previous post is a bit misleading. ""Wade"" [EMAIL PROTECTED] wrote in message 9c6dcb$h8e$[EMAIL PROTECTED]">news:9c6dcb$h8e$[EMAIL PROTECTED]... Aside from " (quotes), which HTML characters should be preceded with a \ (backslash) to avoid parsing errors? No and Yes. NO: You don't have to escape PHP special characters in HTML. YES: You need to escape PHP special characters in string. (Generally speaking) I have the following, which I have in an .inc file outside my web root. I have tried sticking the \ in front of the # (pound) and the = (equal) -- not out of any reason, but more out of frustration. I have been sticking dropdown menu in inc files with no troubles, but this is the first table I've tried to stick in there. I'm trying not to ask questions here until after trying to find an answer in PHP.net, but I've had no luck on this one. ? table width=\"90%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\" tr bgcolor=\"#ebebd6\" ? You cannot write HTML like this in PHP code. You can write HTML in conditional statement as my previous post. You also could write it as follows $html =EOH table width="90%" border="0" cellspacing="0" cellpadding="0" align="center" tr bgcolor="#ebebd6" EOH; print $html; Heredoc does not require to escape ", ',newline,etc even if it is similar to string with " or '. Regards, -- Yasuo Ohgaki -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Escaping Characters - URL Encoding.
H- I've been able to escape the 'space' character in a variable so it can be safely passed through a URL but I'm having trouble finding anything that works for escaping the '' ampsand. Here is a snippet of code. $topic = Aerospace Commercial Space; $link_value = str_replace(, '%26', $topic); $link_value = str_replace(' ', '%20', $topic); Here's the strange part. If the ampersand replace is in front of the space replace the space replace gets done but the ampersand doesn't. If the ampersand replace is done after the space replace the ampersand get's replaced but the spaces do not. So for the code above the %20 was replaced but the remained . I split the lines up for simplicity. Is that's what's causing the problems? What am I missing here? Very confusing. Thanks for any info any one might have on this. Thoughts, Comments, Anecdotes? -Sterling -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Escaping Characters - URL Encoding.
Sterling wrote: $topic = Aerospace Commercial Space; $link_value = str_replace(, '%26', $topic); $link_value = str_replace(' ', '%20', $topic); This should be $link_value = str_replace(, '%26', $topic); $link_value = str_replace(' ', '%20', $link_value); Anyway, this is this wrong way to go about it. This line $link_value = rawurlencode($topic); will do the whole job. regards Wagner -- In place of infinity we usually put some really big number, like 15. - Anonymous Computer Science professor -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Escaping Characters - URL Encoding.
I've been able to escape the 'space' character in a variable so it can be safely passed through a URL but I'm having trouble finding anything that works for escaping the '' ampsand. php.net/urlencode as for your code: $topic = Aerospace Commercial Space; $link_value = str_replace(, '%26', $topic); $link_value = str_replace(' ', '%20', $topic); You are using $topic both times. Your second line should be: $link_value = str_replace(' ', '%20', $link_value); -Rasmus -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] escaping php syntax within perl
Hey everyone, Doesn anyone knowhow to escape the following line in a perl print statement? if(!isset($mainfile)) { include("mainfile.php"); } ie: sub header{ print "?php echo if(!isset($mainfile)) { include(\"mainfile.php\"); } ?\n"; } What all needs to be escaped? Thanks! Clayton DukesCCNA, CCDA, CCDP, CCNPInternetwork Solutions EngineerInternetwork Management Engineer-Download Free Essays, Term Papers and Cisco Training from http://www.gdd.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Escaping double quotes?
How do you escape double quotes? I have the following which is supposed to make any " in a string into \" but it doesn't seem to work. What's wrong with it? $tmp_string = str_replace ("\"", "\\\"", $tmp_string); -Ben -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Escaping double quotes?
addslashes() usually works for me... --Joe On Sun, Feb 25, 2001 at 01:46:30AM -0500, Ben Cheng wrote: How do you escape double quotes? I have the following which is supposed to make any " in a string into \" but it doesn't seem to work. What's wrong with it? $tmp_string = str_replace ("\"", "\\\"", $tmp_string); -Ben -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- --- Joe Stump, PHP Hacker, [EMAIL PROTECTED] -o) http://www.miester.org http://www.care2.com /\\ "It's not enough to succeed. Everyone else must fail" -- Larry Ellison _\_V --- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]