Page 1 of 1

unexpected character in input!?(PHP)

Posted: Sat Oct 06, 2007 11:01 am
by earlz
Ok, I am really just wanting to knowexactly why PHP gives a warning on somethign liek this...
$bah='\' ';
(those are all single quotes)

I could just disable the warning, but that just doesn't seem right...


edit:
ok...now know how to probably fix it, but it doesn't really matter....never allow people to inject code...even if it is into quoteation marks...

Posted: Sat Oct 06, 2007 12:54 pm
by os64dev
no, clue about warning but "'" works in php.

Posted: Wed Nov 07, 2007 11:36 am
by TomB
Escape characters do not work in single quotes, you must use double quotes for escaped characters.

Posted: Wed Nov 07, 2007 11:44 am
by SpooK
TomB wrote:Escape characters do not work in single quotes, you must use double quotes for escaped characters.
Not true, at least in PHP... and doubly for Regular Expressions.

Posted: Wed Nov 07, 2007 12:58 pm
by Zacariaz
SpooK wrote:
TomB wrote:Escape characters do not work in single quotes, you must use double quotes for escaped characters.
Not true, at least in PHP... and doubly for Regular Expressions.
It is indeed true, in some version/builds at least. also i have experience "echo" not being able to display escape charecters at all, but having no problems with "print".

Posted: Wed Nov 07, 2007 6:15 pm
by SpooK
Zacariaz wrote:
SpooK wrote:
TomB wrote:Escape characters do not work in single quotes, you must use double quotes for escaped characters.
Not true, at least in PHP... and doubly for Regular Expressions.
It is indeed true, in some version/builds at least. also i have experience "echo" not being able to display escape charecters at all, but having no problems with "print".
You are probably right :!:

I remembered that whenever I install PHP, I ensure that Magic Quotes are disabled in the PHP initialization file. Something I usually and happily forget there-on after :P

Look in to this (or simply disable at script runtime) if any of you are having awkward escape character issues :idea: