예제 #1
0
 /**
  * Connects and selects the database
  * @return resource MySQL link identifier
  * On Error outputs message and exits.
  */
 protected function opendb()
 {
     // Only do one open
     if ($this->db) {
         return $this->db;
     }
     $db = new SQlite3($this->database);
     $db->enableExceptions(true);
     $this->db = $db;
     // set this right away so if we get an error below $this->db is valid
     return $db;
 }
예제 #2
0
파일: delete.php 프로젝트: hliasa/aggelies
        <?php 
include "menu.php";
?>
        <div id="center">
        <?php 
$id = $_POST[id];
$form = <<<FORM
    <form action="delete.php" method="post">
        Παρακαλώ δώστε το <strong>αναγνωριστικό</strong> της αγγελίας που θέλετε να διαγράψετε:<br /><br />
        <input type="text" name="id" id="id"> <input type="submit" id="btn" value="Δαγραφή" / >
    </form>
FORM;
if (isset($id)) {
    //delete code
    $id = SQLite3::escapeString($id);
    $db = new SQlite3('data.db');
    $result = $db->query("SELECT titlos,id,img FROM aggelies WHERE uniqid='{$id}'");
    if ($row = $result->fetchArray()) {
        unlink($row[img]);
        rmdir("images/" . $row[id]);
        $db->exec("DELETE FROM aggelies WHERE uniqid='{$id}'");
        echo "Η αγγελία με τίτλο {$row['titlos']} διαγράφηκε!";
    } else {
        echo "Η αγγελία δε βρέθηκε...<br />" . $form;
    }
} else {
    echo $form;
}
?>

        </div>