We help IT Professionals succeed at work.

simple/complicated

rams73
rams73 asked
on
Hi

I have a html form
input type = text name=comment

in the comment the user keys in as

I use old car's

The variable comment ="I use old car's";

I make a post of this html form and in the next link i store this in my data base (oracle);

while doing this i am getting an error" open quotes not ended properly", How to avoid this.

i know because of this (car's) quotes the error is comming, i want the quotes also to be stored in the database, how to do this...

thanks

rams
Comment
Watch Question

First you should not use the apostroph. Plural of car is cars :-)

The string must be escaped by slashes "I use old car\'s", to do that you can use addslashes() in PHP and stripslashes() to remove them later.

So use addslashes($comment) within your SQL statement. If you get the string back from a select statement you should do $commant = stripslashes($sql_result_for_comment) to reverse that.

hope that helps

Marian
Commented:
I would suggest you escape any quotes. You can do that by using:

addslashes()

http://www.php.net/manual/en/function.addslashes.php

And then when you pull it out of the database, do the reverse by using:

stripslashes()

http://www.php.net/manual/en/function.stripslashes.php

:o)

Ant

Commented:
LOL - beat me too it!

:o)

Ant

Author

Commented:
The above things didn't worked for me since i am using oracle database but i could find the correct ans from the url

http://www.php.net/manual/en/function.addslashes.php

You have to search for single quotes and replace with double quotes, that is it.

lesson learned: I should provide some URLs on every answer I give :-)
Marian

Commented:
Glad to have helped.

:o)

Ant

Explore More ContentExplore courses, solutions, and other research materials related to this topic.