07/01/2011, 13:04
|
| | Fecha de Ingreso: enero-2011
Mensajes: 5
Antigüedad: 13 años, 10 meses Puntos: 0 | |
Respuesta: Problema seleccionar tabla mysql desde php Hago echo de la variable y me sale correcto lo que le paso a la url
Código:
<?php
$db_host = '****';
$db_user = '****';
$db_pwd = '****';
$database = 'galeria';
$table = $_GET["album"];
echo "TABLA: $table" ;
if (!mysql_connect($db_host, $db_user, $db_pwd))
die("Can't connect to database");
if (!mysql_select_db($database))
die("Can't select database");
// This function makes usage of
// $_GET, $_POST, etc... variables
// completly safe in SQL queries
function sql_safe($s)
{
if (get_magic_quotes_gpc())
$s = stripslashes($s);
return mysql_real_escape_string($s);
}
if (isset($_GET['show']))
{
$id = intval($_GET['show']);
$result = mysql_query("SELECT ext, UNIX_TIMESTAMP(image_time), data
FROM $table
WHERE id=$id LIMIT 1");
if (mysql_num_rows($result) == 0)
die('no image');
list($ext, $image_time, $data) = mysql_fetch_row($result);
$send_304 = false;
if (php_sapi_name() == 'apache') {
// if our web server is apache
// we get check HTTP
// If-Modified-Since header
// and do not send image
// if there is a cached version
$ar = apache_request_headers();
if (isset($ar['If-Modified-Since']) && // If-Modified-Since should exists
($ar['If-Modified-Since'] != '') && // not empty
(strtotime($ar['If-Modified-Since']) >= $image_time)) // and grater than
$send_304 = true; // image_time
}
// outputing Last-Modified header
header('Last-Modified: '.gmdate('D, d M Y H:i:s', $image_time).' GMT',
true, 200);
// Set expiration time +1 year
// We do not have any photo re-uploading
// so, browser may cache this photo for quite a long time
header('Expires: '.gmdate('D, d M Y H:i:s', $image_time + 86400*365).' GMT',
true, 200);
// outputing HTTP headers
header('Content-Length: '.strlen($data));
header("Content-type: image/{$ext}");
// outputing image
echo $data;
exit();
}
?>
|