jeudi 28 avril 2016

PHP - SQLLite/PDO Query Issues

I am working on a webpage that should display the list of queried result from an Sqlite DB as a list.

Unfortunately, when I run it, it does not perform as expected. It has the header "Current Images" and then nothing. When I viewed the source, it is simply "cut-off" after the <ul> following the <h3></h3>.

Any ideas what the issue might be?

  <?php 
session_start();
$user = $_SESSION['store'];


$image;
$label;


if($_SERVER['REQUEST_METHOD'] == "POST") {
$label = $_POST['label'];

$image = file_get_contents($_FILES['image']['tmp_name']);





 $con = new PDO("sqlite:bk.db");


$statement = $con->prepare("INSERT INTO slides (image, label) VALUES (:image, :label)");

$statement->bindParam(":label", $label);

$statement->bindParam(":image", $image);





    $statement->execute();

    touch("update.txt");


    }
    ?>
    <!DOCTYPE html>
    <!-- css/js links omitted -->>



    <!-- begin page / some code omitted -->



                    <div role="main" class="main">
              <div class="col-md-12">
                <?php 
    if($user != "00") {
    echo "<p>You do not have permission to view this page.</p>";
    } else {
    echo "<h2>Add Images</h2>
    <form class='form-horizontal' method='post' enctype='multipart/form-data'  action='editImages.php'> 
              <div class='form-group'>

              <label for='image'>Select Image File:</label> 
                <input type='file' name='image' />
              </div>

                <div class='form-group'>
              <label for='label'>Label (optional):</label>
        <input type='text' name='label' id='label' />
               </div>         

                  <input type='submit'  value='Add Image' />
              </form>
              <h3>Current Images</h3>
              <ul>";

              $result = $con->query("SELECT image FROM slides");

              foreach($result as $row) {
              echo "<li>base64_decode($row[0])</li>";
              };
              echo "</ul>";
              } 
              } ?>
               </div>

It inserts just fine, it is the select statement that I am having trouble with. Thanks!

Aucun commentaire:

Enregistrer un commentaire