/    Sign up×
Community /Pin to ProfileBookmark

sqlite and quotes within field values

[code=php]
tep_db_query( “insert into ” . TABLE_CONFIGURATION . ”
(
configuration_title,
configuration_key,
configuration_value,
configuration_description,
configuration_group_id,
sort_order,
set_function,
date_added
)values (
‘Enable Authorize.net Module’,
‘MODULE_PAYMENT_AUTHORIZENET_STATUS’,
‘True’,
‘Do you want to accept Authorize.net payments?’,
‘6’,
‘0’,
‘tep_cfg_select_option(array(‘True’, ‘False’), ‘,
datetime(‘now’)
)”
);
[/code]

Sqlite doesn’t like th escaped single quotes. addslashes doesn’t seem to work either. How do I go about this?

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@sitehatcheryauthorFeb 07.2007 — Ok, I think I got the answer here:

http://www.sqlite.org/faq.html#q16
Copy linkTweet thisAlerts:
@sitehatcheryauthorFeb 09.2007 — Excellent, it looks like mysql can accept two single quotes together as well.

for instance,
[code=php]
$result="insert into products values title="can''t say more";
[/code]

inserting strings with single quotes in this way makes the insert statement compatible with mysql and sqlite - haven't tested anything else. Of the two database-types, if you escape single quotes with a backslash, it's only compatible with mysql.
×

Success!

Help @sitehatchery 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 5.6,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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