Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7082751
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:05:36+00:00 2026-05-28T07:05:36+00:00

Using PDO to CRUD with SQLITE3. When I insert a string ‘didn’t’, the string

  • 0

Using PDO to CRUD with SQLITE3. When I insert a string ‘didn’t’, the string goes into the table as ‘didn\’t’.

So, later when I read the string back out, to ouput to HTML, I get didn\’t in my web page.

So, if PDO is escaping the single quote on the INSERT with the backslash, how do I strip out the escaping backslashes for presentation?

Does that make sense?

EDIT – Including code. $eventBody is the string in question.

try {
               $db = new PDO('sqlite:../posts.sqlite');
                $db->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
                }
            catch(PDOException $e)
                {
                    echo $e->getMessage();
                    die;
                }
                    //using the sqlite functions to do date/time stuff
        $query = 'INSERT INTO posts (eDay, eMonth, eYear, eTitle, eBody,author, eURL, eTime)
                  VALUES( strftime(\'%d\',\'now\') , strftime(\'%m\',\'now\') , strftime(\'%Y\',\'now\') ,"'. $eventTitle .'","'.$eventBody.'","' . $eventAuthor. '","' . $eventURL . '",time(\'now\',\'localtime\'));' ;

                try
                {
                $result=$db->query($query);
                if(!($result))
                {
                    echo "INSERT FAILED.<br>";
                    echo "QUERY STRING: ".$query ." <br>";
                    die;

                }
                    echo "Successfully Added Record";
                    $eventTitle = '';
                    $eventBody='';
                    $eventURL='';
                    $eventAuthor='';
            //      urlRedirect("Referback.php");
                }
                catch (PDOException $ex)
                {
                    echo $ex->getMessage();
                    die;
                }
                catch (Exception $exc)
                {
                    echo $exc->getMessage();
                    die;
                }
        }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T07:05:37+00:00Added an answer on May 28, 2026 at 7:05 am

    PDO works the way it should, you should check how you do your insert (build the queries) and the data source (meaning what’s coming from $_POST/$_GET).

    And specially the magic quotes gpc. If you don’t know what it is, check it out. It’s a very recurrent problem. Before you start using stripslashes/addslashes and such.

    You should also use the prepared statement, it’s not only nicer, but a lot less work and safer.

    $stmt = $db->prepare('INSERT INTO posts '.
        '(eDay, eMonth, eYear, eTitle, eBody, author, eURL, eTime) '.
        'VALUES (?, ?, ?, ?, ?, ?, ?, ?);');
    $result = $stmt->execute(array(
        date('d'),
        date('m'),
        date('Y'),
        $eventTitle,
        $eventBody,
        $eventAuthor,
        $eventURL,
        time('now', 'localtime')
    ));
    

    You could also print the data you give to ̀ execute` to make sure, it is what you want.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my php script,I'm using PDO to insert csv data into database. $sqlsmttempl =
I am trying to insert a serialize data into mySQL using PDO and I'm
I am currently writing a CRUD class in PHP using PDO. I like the
I have run into a problem using PDO because an error was not caught.
I'm using PDO's fetch_class feature to retrieve data from my database row into object,
I am trying to place cleaned form data into a MySQL database using PDO.
I am using PDO against an Oracle server and pulling query results into a
The below MYSQL INSERT command, using PDO, just fails. And after it fails and
I'm using PDO inside a database abstraction library function query that I've made. I'm
I am using PDO to talk to my database, and I wonder if casting

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.