• Sign in to Neowin Faster!

    Create an account on Neowin to contribute and support the site.

  • 0
Sign in to follow this  

SQlite Escape String

Question

Scarenius    0

When trying to insert strings with quotes into an SQLite database, I run into errors. Is there a proper way to escape a string for an SQLite query without using htmlspecialchars() or htmlentities()? sqlite_escape_string() and addslashes() don't do anything.

Share this post


Link to post
Share on other sites

1 answer to this question

Recommended Posts

  • 0
Scarenius    0

Update: Since SQLite isn't a native to PHP, but more a port, syntax has to be in SQL format. Escaping quotes and colons in SQL simple involves double quotes and double colons. So if you need to escape a string with quotes for use in SQLite queries.

$string=str_replace("\"","\"\"",$string);

Honestly, I wonder if str_replace() is my favorite function.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.