gehrenfeld gehrenfeld - 10 months ago 45
SQL Question

My crud is not creating, updating, and deleteing records

I thought this was a good question but someone gave me a -1 and now I can not post.

Would someone please vote positive so I can get my posting ability back?

Thank you


One point worth mentioning is that you have told PDO to throw exceptions on error conditiona but you are not catching them if they are thrown. Maybe you are just missing there existance completely.

// insert data
if ($valid) {

    try {
        $pdo = Database::connect();
        $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        $sql = "INSERT INTO customers (name,email,mobile) values(?, ?, ?)";
        $q = $pdo->prepare($sql);
        header("Location: index.php");
        //add exit after a Location header is sent as 
        // code will continue to be executed after the header() is run
    catch ( PDOException $e ) {
        echo $e->getMessage();