Hallo zusammen,
ich habe leider ein kleines Problem. Ich möchte gerne mit einem PHP-Skript Daten in eine Datenbank schreiben. Allerdings bekomme ich immer die folgenden Fehlermeldung:
Code
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000]: General error: 8 attempt to write a readonly database' in /var/www/html/php/functions.php:28 Stack trace: #0 /var/www/html/php/functions.php(28): PDO->query('INSERT INTO Kon...') #1 /var/www/html/php/addConfig.php(37): db_query('INSERT INTO Kon...') #2 {main} thrown in /var/www/html/php/functions.php on line 28
Und hier noch meinen Code dazu:
PHP
<?php
//------------------------------------------------------------------------------
error_reporting(E_ALL);
ini_set('track_errors', 1);
ini_set('display_errors', 1);
ini_set('log_errors', 1);
//------------------------------------------------------------------------------
require_once("config.php");
require_once("functions.php");
//------------------------------------------------------------------------------
// check if sqlite db file exists else create it..
if (!file_exists($DBfile)) {
$db = db_con($DBfile);
$SQL = "CREATE TABLE IF NOT EXISTS Konfiguration (ID INT PRIMARY KEY, ConfigName TEXT, Value TEXT)";
$create = db_query($SQL);
}
if (!empty($_POST)) {
foreach ($_POST AS $arg => $var) {
if ($arg == "intervall") { $intervall = $var; }
}
if ( isset($intervall) ) {
$configName = "Zeit";
$db = db_con($DBfile);
$query = $db->query("SELECT MAX(id) FROM Konfiguration");
while ($result = $query->fetch(PDO::FETCH_NUM)) {
$id = intval($result);
}
$id++;
$SQL = "INSERT INTO Konfiguration (ID, ConfigName, Value) VALUES ('.$id.','.$configName.','.$intervall.')";
$insert = db_query($SQL);
}
}
?>
Alles anzeigen
Wäre echt gut, wenn mir hier jemand helfen könnte... Ich bedanke mich auch schon mal für jede Hilfe!
Gruß Kilian