php - Textarea data sometimes does not insert into mysql database with copy and paste -
i've been having issue difficult pin-point, thought i'd ask community it. issue difficult describe, because odd user complains of circumstance can't reproduce life of me, occurs consistently enough across enough users know it's real.
essentially, have site users can post ads, there's textarea can place 3000 characters of text, posted db. text checked on submit jquery char length , php post confirms before else processed. don't use mysqli_real_escape_string because messes users posts , makes them unhappy, clean data function:
`function datasecure($data){ $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); $data = strip_tags($data); $data = addslashes($data); return $data; }` before inserting prepared statement mysql database text, utf8-unicode-ci, default null. function may seem overkill, prevents type of sql injection i'm able come with. if script determines stmt executed successfully, deducts user's account, if not, in returns false , allows user edit details.
note: script works 95% of posts, statement prepared properly, etc., , not posted here because script isn't issue. issue arises when users attempt copy , paste ad either word document or e-mail text-area. in case, stmt executed , money deducted user's account, no data inserted db. have tried in power reproduce error (using msword documents, copying forwarded e-mails, adding odd characters, different browsers, using uft8_encode() prevent error, etc.) doesn't work. others have complained on of copy-and-pasted textareas failing insert, appear have remained unsolved.
my best bet in textarea isn't jiving db, i'm hoping experience can shed light on problem is.
Comments
Post a Comment