mysql - How Apostrophe is stored in database using php form text area? -


i have code file name of "form.php". in create web form , using text area tag in it. have problem. when write in text area , use apostrophe in text data can not store in database. when write text without apostrophe data stored in database. how can fix problem?

my code below:

<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"><?php $connection = mysql_connect("localhost", "root", ""); // establishing connection server $db = mysql_select_db("aaaaa", $connection); // selecting database server if(isset($_post['submit'])){ // fetching variables of form travels in url $txttitle = $_post['txttitle']; $txtreferance = $_post['txtreferance']; $txttoname = $_post['txttoname']; $chkconfidential = $_post['chkconfidential']; $txttodesignation = $_post['txttodesignation']; $txtdate = $_post['txtdate']; $cmbsolutation = $_post['cmbsolutation']; $txttoentity = $_post['txttoentity']; $txttoadd1 = $_post['txttoadd1']; $txtthankyou = $_post['txtthankyou']; $txttoadd2 = $_post['txttoadd2']; $cmbyourstruely = $_post['cmbyourstruely']; $txttoadd3 = $_post['txttoadd3']; $txtsignaturename = $_post['txtsignaturename']; $txttocity = $_post['txttocity']; $cmbsdesignation = $_post['cmbsdesignation']; $txtheading1 = $_post['txtheading1']; $txtench1 = $_post['txtench1']; $txtheading2 = $_post['txtheading2']; $txtench2 = $_post['txtench2']; $txtheading3 = $_post['txtheading3']; $txtench3 = $_post['txtench3']; $txtrational = $_post['txtrational'];   //insert query of sql $query = mysql_query("insert test(file_name, ref_no, to_name, confidential, designation, date, solutation, entity, add_1, thank_you, add_2, yours_truly, add_3, sign_name, city, s_designation, heading_line_1, encl_line_1, heading_line_2, encl_line_2, heading_line_3, encl_line_3, text)   values       ('$txttitle', '$txtreferance', '$txttoname', '$chkconfidential', '$txttodesignation', '$txtdate', '$cmbsolutation', '$txttoentity', '$txttoadd1', '$txtthankyou', '$txttoadd2', '$cmbyourstruely', '$txttoadd3', '$txtsignaturename', '$txttocity', '$cmbsdesignation', '$txtheading1', '$txtench1', '$txtheading2', '$txtench2', '$txtheading3', '$txtench3', '$txtrational')"); echo "<br/><br/><span>data inserted successfully...!!</span>"; } else{ echo "<p>insertion failed <br/> fields blank....!!</p>"; }  //mysql_close($connection); // closing connection server ?> 

this you're looking for: mysql_real_escape_string

use on every field escape such characters.

$txttitle = mysql_real_escape_string( $_post['txttitle'] ); // same other columns 

ps: use mysqli , mysql deprecated , slow too.


Comments

Popular posts from this blog

How to connect android app to App engine -

gcc - MinGW's ld cannot perform PE operations on non PE output file -

php - display validation error message next to the textbox in codeigniter -