<!DOCTYPE html>
<?php
global $db;
$sqliteerror = null;
try{
$db = new PDO('sqlite:mysqlitedb.sqlite3');
}
catch(Exception $e){
echo htmlentities($e->getMessage());
echo "<br><br><br>";
die('Error opening or creating new sqlite DB. Check write permissions for '.dirname(__FILE__));
}
//Save
if(isset($_POST['answer']) && trim($_POST['answer'])){
$sql = 'INSERT INTO survey (answer) VALUES (\''.$_POST['answer'].'\')';
$db->query($sql);
}
?>
<html>
<head>
<title></title>
</head>
<body>
<fieldset>
<legend>SURVEY: What is the best food?</legend>
<form method="POST">
<label>Answer: <input type="text" name="answer"></label>
<input type="submit">
</form>
</fieldset>
<fieldset>
<legend>SURVEY: Previous Answers</legend>
<?php
$sql = 'SELECT COUNT(*) as x, `answer` FROM survey WHERE `answer` != \'\' GROUP BY `answer`';
foreach ($db->query($sql) as $row) {
echo $row['x'] . "x ".$row['answer'].'<br>';
}
?>
</fieldset>
</body>
</html>
- Output for 7.4.26 - 7.4.32, 8.0.14 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.7
- <!DOCTYPE html>
open_basedir prohibits opening mysqlitedb.sqlite3<br><br><br>Error opening or creating new sqlite DB. Check write permissions for /in
- Output for 7.1.0 - 7.1.33, 7.2.0 - 7.2.34, 7.3.0 - 7.3.33, 7.4.0 - 7.4.25, 7.4.33, 8.0.0 - 8.0.13
- <!DOCTYPE html>
SQLSTATE[HY000] [14] unable to open database file<br><br><br>Error opening or creating new sqlite DB. Check write permissions for /in
preferences:
177.64 ms | 403 KiB | 226 Q