PHP - Write To MySQL Database -


i'm writing values mysql database using following snippets of code.

please note, when run select queries, information correctly displayed using echo etc.

however when try write database using insert, code executes no errors, when check database there nothing written it.

 private $db;   function __construct() {  $this->db = new mysqli('localhost', 'xyz', '123', 'testdb');  $this->db->autocommit(false);  if (isset($_post["id"]) && isset($_post["number"]) && isset($_post["address"]) && isset($_post["ticket"])) {  $id= $_post["id"]; $number= $_post["number"]; $address= $_post["address"]; $ticket= $_post["ticket"];  $stmt = $this->db->prepare("insert tickets (id, number, address, ticket) values (?,?,?,?)"); $stmt->bind_param("iiss", $id, $number, $address, $ticket); $stmt->execute();  $stmt->close()  return true } 

any appreciated.

edit

question - write access database? i've checked user account privileges , has privileges.

when using insert auto_commit must true.

$this->db->autocommit(true); 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -