Unable to insert data to table in sqlite using pdo [duplicate] - Hack The Tech - Latest News related to Computer and Technology

Hack The Tech - Latest News related to Computer and Technology

Get Daily Latest News related to Computer and Technology and hack the world.

Sunday, February 27, 2022

Unable to insert data to table in sqlite using pdo [duplicate]

Can someone please help me with this? I am trying to insert the data into the database. I have checked the location of the database to be correct. Also there are no error after executing the query. However, no data has been added to the table. How can i solve this.

<?php

$db = new PDO('sqlite:../cart.db');
$db->query('PRAGMA foreign_keys = ON;');

if($q = $db->prepare("INSERT INTO CATEGORIEy (CATID, NAME) VALUES (?, ?)")) {

    $q->bindParam(1, $catid);
    $q->bindParam(2, $name);
    $catid = 1;
    $name = "test";
    $q->execute();

    echo "end";
    
}else{
    var_dump($db->errorInfo());
}


?>



source https://stackoverflow.com/questions/71279150/unable-to-insert-data-to-table-in-sqlite-using-pdo

No comments:

Post a Comment