Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Check Blob field if null or ok

Posted on 2006-07-05
3
Medium Priority
?
357 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
The viewer will learn how to count occurrences of each item in an array.
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

604 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