troubleshooting Question

apostrophe issues when sending text to db

Avatar of chandldj
chandldj asked on
10 Comments1 Solution333 ViewsLast Modified:
I need to send data in a textarea to a memo field in the db(access 2000). the problem is apostrophes or quotes or single quotes can easily end up in the text. I have tried the following but the apostrophe keeps causing an error. I cannot find a solution for this.

        $squo = "'";
        $dquo = """;
        $notes = stripslashes(ereg_replace("'",$squo,$_POST["other_notes"]));
        $notes = stripslashes(ereg_replace('"',$dquo,$_POST["other_notes"]));
        $str_lines = "Insert into lead_lines(empID, leadID, date_, notes) VALUES(".$_POST["pick_emp"].",".odbc_result($rs_leadid, "callID").",'".$_POST["date_entered"]."','".$notes."')";

the resulting sql statement is:

Insert into lead_lines(empID, leadID, date_, notes) VALUES(1,14,'8/19/2005',' This guy seems like a real easy going dude. Might've been high when he ordered.')

The problem is in the might've, i've also tried to insert it like might\'ve -- doesn't work

Is there a way to make it literally write ' instead of placing a ' ?

Because I ran the query in access with the character code rather than the apostrophe and it worked.

Any help is appreciated
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 10 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 10 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros