Hvad f... er problemet ud over jeg ikke har nogle point tilbage...
Jeg kan ikke få vist billeder fra min database.
Det er ikke helt sandt hvis jeg har en "blank side" er det ikke noget problem:
http://fluekrogen.dk/gallery.phpMen det samme når det include();
http://fluekrogen.dk/test.php(se et af billederne)
Hvis I selv vil prøve lidt så er passworde: 123
Koden kommer fra:
http://www.anyexample.com/programming/php/php_mysql_example__image_gallery_(blob_storage).xml
<?php
include ("class/forbind.php");
$table = 'ae_gallery';
$password = '123';
function sql_safe($s){
if (get_magic_quotes_gpc())
$s = stripslashes($s);
return mysql_real_escape_string($s);
}
if ($_SERVER['REQUEST_METHOD'] == 'POST'){
$title = trim(sql_safe($_POST['title']));
if ($title == ''){
$title = '(empty title)';
}
if ($_POST['password'] != $password){
$msg = 'Error: wrong upload password';
} else {
if (isset($_FILES['photo'])){
@list(, , $imtype, ) = getimagesize($_FILES['photo']['tmp_name']);
if ($imtype == 3){
$ext="png";
} elseif ($imtype == 2){
$ext="jpeg";
} elseif ($imtype == 1){
$ext="gif";
} else{
$msg = 'Error: unknown file format';
}
if (!isset($msg)){
$data = file_get_contents($_FILES['photo']['tmp_name']);
$data = mysql_real_escape_string($data);
mysql_query("INSERT INTO {$table} SET ext='$ext', title='$title', data='$data'");
$msg = 'Success: image uploaded';
}
} elseif (isset($_GET['title'])){
$msg = 'Error: file not loaded';
}
if (isset($_POST['del'])){
$id = intval($_POST['del']);
mysql_query("DELETE FROM {$table} WHERE id=$id");
$msg = 'Photo deleted';
}
}
} elseif (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') {
$ar = apache_request_headers();
if (isset($ar['If-Modified-Since']) &&
($ar['If-Modified-Since'] != '') &&
(strtotime($ar['If-Modified-Since']) >= $image_time))
$send_304 = true;
}
if ($send_304){
header('Last-Modified: '.gmdate('D, d M Y H:i:s', $ts).' GMT', true, 304);
exit();
}
header('Last-Modified: '.gmdate('D, d M Y H:i:s', $image_time).' GMT', true, 200);
header('Expires: '.gmdate('D, d M Y H:i:s', $image_time + 86400*365).' GMT', true, 200);
header('Content-Length: '.strlen($data));
header("Content-type: image/{$ext}");
echo $data;
exit();
}
?>
<html>
<head>
<title>MySQL Blob Image Gallery Example</title>
</head>
<body>
<?php
if (isset($msg)){
?>
<p>
<?=$msg?><br>
<a href="<?=$PHP_SELF?>">reload page</a>
</p>
<?php
}
?>
<h2>Blob gallery</h2>
<h3>Uploaded images:</h3>
<form action="<?=$PHP_SELF?>" method="post">
<?php
$result = mysql_query("SELECT id, image_time, title FROM {$table} ORDER BY id DESC");
if (mysql_num_rows($result) == 0){
echo '<ul><li>No images loaded</li></ul>';
} else{
echo '<ul>';
while(list($id, $image_time, $title) = mysql_fetch_row($result)){
echo "<li><input type='radio' name='del' value='{$id}'>";
echo "<a href='{$PHP_SELF}?show={$id}'>{$title}</a> – ";
echo "<small>{$image_time}</small></li>";
}
echo '</ul>';
echo '<label for="password">Password:</label><br>';
echo '<input type="password" name="password" id="password"><br><br>';
echo '<input type="submit" value="Delete selected">';
}
?>
</form>
<h3>Upload new image:</h3>
<form action="<?=$PHP_SELF?>" method="POST" enctype="multipart/form-data">
<label for="title">Title:</label><br>
<input type="text" name="title" id="title" size="64"><br><br>
<label for="photo">Photo:</label><br>
<input type="file" name="photo" id="photo"><br><br>
<label for="password">Password:</label><br>
<input type="password" name="password" id="password"><br><br>
<input type="submit" value="upload">
</form>
</body>
</html>