1

I have a simple form that inserts data into my sqlite database. It works just fine on my localhost, however, I am not getting the insert to work on my remote server. How do I get error messages if my execute() never happens or === false?

Here is my code:

if (isset($_POST["submit"])) {
    $email = $_POST["Email"];
    $name = $_POST["txt_Name"];
    $agency = $_POST["sel_Agency"];
    $subagency = $_POST["txt_SubAgency"];
    $location = $_POST["txt_Location"];

    $params = array(
        ':email' => $email,
        ':name' => $name,
        ':agency' => $agency,
        ':subagency' => $subagency,
        ':location' => $location
    );

    $stmt = $db->prepare($sql);

    if ($stmt->execute($params) === FALSE) {
        //HOW TO SHOW ERROR CODE HERE
    }
}

I tried a try-catch, but didn't get anything. However, if I echo "ERROR" for example, I get the echo ERROR on screen.... I know it isn't working also, since the db has no new rows.

Any help would be appreciated. Thanks!

1

1 Answer 1

1

If you are using PDO, to get the last error use $db->errorCode() to get erro code and $db->errorInfo() get error info

Sign up to request clarification or add additional context in comments.

1 Comment

This sure is a solution, but for those who just want a light interface using the built-in SQlite3 provided with PHP. Too bad the documentation isn't efficient for such a specific needs...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.