problem with apostrophes in text to be entered in db
Posted: Fri Aug 19, 2005 3:58 pm
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
$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