0

//Here is my attempt:

<?php
//PDO prepare statement to create a row in the database'

$pdo = new PDO("sqlite:customer.db");

$statement = 
$pdo->prepare("INSERT INTO customer(CustomerID, CustomerName) VALUES('LA002', 'Alex Matrix')");
$statement->execute();
$numberOfRowsCreated = $statement->rowCount();
echo "Created ".$numberOfRowsCreated." new rows";

//I get 0 new rows. what am I doing wrong?

Irene
  • 23
  • 2
  • Hello Irene. Your question is rather not "How do I create a new row" (which you already know), but "why it doesn't insert a new row?". It doesn't insert because there is an error. You need to get the error message and fix it. Refer to this answer for how to: https://stackoverflow.com/a/32648423/285587 – Your Common Sense Apr 22 '20 at 16:42
  • I read your post and the few other ones before posting the question. I figured it out. The code was correct, the database was the problem. It's working now. – Irene Apr 23 '20 at 02:10

0 Answers0