Solved

Check Blob field if null or ok

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

758 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

21 Experts available now in Live!

Get 1:1 Help Now