Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

adding backslashes in form

Status
Not open for further replies.

riffy

Programmer
Mar 29, 2001
106
0
0
US
Hi guys,

I have a multi-page form and as the user proceeds through each step, the variables from the previous page(s) are carried over into the next page. The final page inserts all values into a mysql database. However, I can't seem to get the apostrophes to work. It seems that thru each step, backslashes keep being added and by the time the form gets to the last page, there are about 20 or so backslashes for one apostrophe.
Can someone please advise? Do I have to do something on EACH page to get rid of the backslashes or just on the last page?

Arif
 
You need to use strip slashes on the way out of the database, and add slashes on the way into the database.

The slashes are used because SQL commands use the single quote... Which adding to the database might fail if you don't escape them, and the output will look strange if you do escape them. so before putting it into the database, use addslashes() and after retreival use stripslashes()...

Also note the security risk of not escaping them, the user would be able to issue commands straight to your database.
 
stripslashes($variable);

for each of the vars which have slashes added to them...

U might even be able to just use

stripslashes($var1, $var2, $var3....etc

 
another way is use the addslashes() function works the same eather will work..

Nothing is hard when you realy want to learn it.

Max
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top