Using single and double quotes in <form> text fields

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

eyewoo
New php-forum User
New php-forum User
Posts: 71
Joined: Sun Mar 09, 2003 10:29 am
Location: Pennsylvania, USA
Contact:

Using single and double quotes in <form> text fields

Postby eyewoo » Mon Apr 14, 2003 6:11 am

Let's say the following line is in a text file:

he said, "This is an 'A'."

When the line is read into a <form> text field for changing, the single and double quotes are not maintained. In fact the phrase is truncated. Is there a way to read text into the value of a <form> text field and maintain the single and double quotes if they are there?

User avatar
Skeletor
New php-forum User
New php-forum User
Posts: 147
Joined: Tue Nov 19, 2002 7:47 am
Location: US, Ohio
Contact:

Postby Skeletor » Mon Apr 14, 2003 7:16 am

I think you can use the addslashes() function. You can find a detailed description of it on http://www.php.net I believe it adds the /' and /" to your quotes so it preserves the string as you wrote it.

eyewoo
New php-forum User
New php-forum User
Posts: 71
Joined: Sun Mar 09, 2003 10:29 am
Location: Pennsylvania, USA
Contact:

Postby eyewoo » Mon Apr 14, 2003 8:17 am

addslashes does not work... however, using str_replace to replace double quotes with &quot; does work...

Is there a better way?


Return to “PHP coding => General”

Who is online

Users browsing this forum: No registered users and 1 guest