Solved

Check Blob field if null or ok

Posted on 2006-07-05
3
353 Views
Last Modified: 2008-02-26
Hello experts

I need your help,  When display out (echo) blob data it occurs error if there no data.
How can I check blob field is filled or not with data (actually image)?

Seems Empty() function is not works.
Any good ideas will be appreciated. tnx

My code:

<?php
      require_once('db_connect.php');
      $table = 'fnsonld.emp_emp';
      $fldblob = 'PHOTO';
      $fldid = 'EMPID';
      $valid = '16';
      
      if (isset($_REQUEST['t'])) $table = $_REQUEST['t'];
      if (isset($_REQUEST['f'])) $fldblob = $_REQUEST['f'];
      if (isset($_REQUEST['i'])) $fldid = $_REQUEST['i'];
      if (isset($_REQUEST['v'])) $valid = $_REQUEST['v'];

      $query = 'SELECT '.$fldblob.' FROM '.$table.' WHERE '.$fldid.'='.$valid;
      $stmt = oci_parse ($conn, $query);
      oci_execute($stmt, OCI_DEFAULT);
      $arr = oci_fetch_assoc($stmt);
      $result = $arr[$fldblob]->load();
      if(empty($result))
            header ("Location: ./img/noPic.gif");
      else{
            header("Content-type: image/JPEG");
            echo $result;
      }
      oci_free_statement($stmt);
      oci_close($conn); // log off
?>
0
Comment
Question by:jambuul
  • 2
3 Comments
 
LVL 29

Accepted Solution

by:
TeRReF earned 125 total points
ID: 17048664
$arr = oci_fetch_assoc($stmt);
if (count($arr) && isset($arr[$fldblob])) {
     $result = $arr[$fldblob]->load();
      header("Content-type: image/JPEG");
      echo $result;
} else {
      header ("Location: ./img/noPic.gif");
}
0
 

Author Comment

by:jambuul
ID: 17048689
You are really fast.
tnx a lot
0
 
LVL 29

Expert Comment

by:TeRReF
ID: 17048695
You're welcome... (must be the amount of coffee i've had already :)
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question