Web Hosting Talk







View Full Version : ignore $sign


Codebird
03-04-2008, 02:14 PM
how can I make php ignore a $ sign??? for example if I have such password
$hy$ll

I want to read as is. how?

AmyWilliams
03-04-2008, 03:12 PM
Use the escape character:

\$hy\$ll

Codebird
03-04-2008, 03:19 PM
thanks a lot, It was actually too easy but I didn't see it!!! I have put the string in single quotes
'' cause when I used addcslashes($pass, "$") there were slashes but not in the $ sign was parsed before

Saeven
03-06-2008, 12:18 PM
Sorry for the unsolicited interjection, but is it that you're inserting this into a MySQL database? If so, do consider mysql_real_escape_string instead of addslashes or any of its variants. This is a well-beaten topic, should find many articles online :)

Cheers.
Alex

Codebird
03-06-2008, 12:26 PM
no I wasn't inserting it into mysql database, It is a server password to create a whm reseller. Now it is solved but the idea was that no matter what function I used the $ sign was still parsed before the function was ran.

for example mysql_real_escape_string("$hl$xx");
was becoming mysql_real_escape_string("");

the solution was to put it between single quotes ''

Thanks for you trying to help me, the problem was solved :D:) Cheers

Saeven
03-06-2008, 01:24 PM
I had assumed that you were using single quotes, and had experienced difficulty with character encoding/storage; I think Amy's response threw me off course (rereading it now in light of your response)

Glad you got it!

hamdusa
03-07-2008, 10:01 PM
Following may be solutions of your problem:

1) if you are submitting password using forms, you need not worry.
2) If you are using single quotes '' , nothing to do extra. PHP will interpret $ as a character.

3) if you are using $ sign inside a double quoted string, use escaping character. \. In this particular case, your password (or string) becomes like "Hello\$mylove"