I just started working with sqlite3 and my page keeps refreshing on me and keeps inserting data into the database. If I comment out the insert execute command the page does not refresh. I am thinking that it may have to do with my connection to the database but I am not sure. Thanks in advance. Here is the complete code:
<?php
class create {
function makeDB() {
$pdo = new PDO("sqlite:db/SSDB");
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$mainDB = "CREATE TABLE IF NOT EXISTS pass (
'rowID' INTEGER,
'username' CHAR(256) NOT NULL,
'pass' CHAR(256) NOT NULL,
'iv' CHAR(256) NOT NULL
)";
$pdo->query($mainDB);
}
}
class connectDB {
public function connect() {
try {
$dbh = new PDO("sqlite:db/SSDB");
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
return $dbh;
} catch (PDOException $ex) {
echo $ex->getMessage();
die();
}
}
}
$connDb = new connectDB();
$conn = $connDb->connect();
$createDB = new create();
$createDB->makeDB();
$string = "hi1";
$salt = 'salt';
$encrypted_string = 'test';
$iv = 4;
$sql = "INSERT INTO pass VALUES(1,:encrypted,:salt,:iv)";
$sqlPrepare = $conn->prepare($sql);
$sqlPrepare->execute(array(':encrypted' => $encrypted_string, ':salt' => $salt,:iv'=> $iv));
executeline, you are missing a'.`