Solved

Check Blob field if null or ok

Posted on 2006-07-05
3
346 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

937 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now