?
Solved

Check Blob field if null or ok

Posted on 2006-07-05
3
Medium Priority
?
356 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 29

Accepted Solution

by:
TeRReF earned 500 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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 …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to dynamically set the form action using jQuery.
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 …
Suggested Courses

771 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