/    Sign up×
Community /Pin to ProfileBookmark

Saving LineControl Editor content to the database

Hello,

I’m using the [LineControl Editor](https://www.jqueryscript.net/demo/Responsive-WYSIWYG-Text-Editor-with-jQuery-Bootstrap-LineControl-Editor/) editor

MySQL column “longtext” selected
I want to write editor text to database with PDO and insert and update to editor
I use this when uploading to the editor and writing to the database “addslashes($text[‘txtEditor’])”

However I get the following error,
Fatal error: Uncaught PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@NogDogNov 22.2020 — Why addslashes()? If using PDO, your best bet would be to use a prepared statement with a bound parameter, something like:
<i>
</i>$stmt = $pdo-&gt;prepare("INSERT INTO my_table (text_column_name) VALUES (:text)");
$stmt-&gt;execute(array(':text' =&gt; $text['txtEditor']));

Then just let PDO take care of whatever types of escaping need to be done for the DBMS being used.
Copy linkTweet thisAlerts:
@gecekuleauthorNov 23.2020 — So am I making a mistake here?
<i>
</i>$text = $text['txtEditor'];
$stmt-&gt;bindParam(5, $text, PDO::PARAM_STR);

__(Added ... tags ~ MOD)__
Copy linkTweet thisAlerts:
@gecekuleauthorNov 23.2020 — I found the problem

xxxx = ?,

xxxx =?

html_text =?

I forgot to put commas before html text

Excuse me

Thank you
×

Success!

Help @gecekule spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...