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
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]