<?php require_once 'DB.php'; define('DB_SERVER', 'localhost'); define('DB_USER', 'php'); define('DB_PASS', ''); define('DB_DATABASE', 'images'); define('DSN', 'mysql://'.DB_USER.':'.DB_PASS.'@'.DB_SERVER.'/'.DB_DATABASE); global $db; $db = DB::connect(DSN); if (PEAR::isError($db)) { die($db->getMessage()); } if (isset($_GET['id'])) { header('Content-Type: image/jpeg'); $id = $_GET['id']; $sql = "select image_data from images where id = ?"; $result =& $db->query($sql, $id); if (PEAR::isError($result)) { die($result->getMessage()); } else { if ($result->fetchInto($row)) { echo $row[0]; } } } else { echo file_get_contents('broken.png'); } ?>
You need to create an account or log in to post comments to this site.