Link to home
Start Free TrialLog in
Avatar of rams73
rams73

asked on

simple/complicated

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
Avatar of heddesheimer
heddesheimer

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
ASKER CERTIFIED SOLUTION
Avatar of a.marsh
a.marsh

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
LOL - beat me too it!

:o)

Ant
Avatar of rams73

ASKER

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
Glad to have helped.

:o)

Ant