Possible Duplicate:
PHP: “Notice: Undefined variable” and “Notice: Undefined index”
So Im back with another php error, that I cant solve. But Im getting better:)
I have created a simple script that stores images in a database, I have no problems to store the file, but when Im reading the file i get an index error. It says
Notice: Undefined index: id in C:\wamp\www\gallery2\show.php on line 13
I cant really get what the problem is since Im thinking that everything is correct !?
the code for showing the images are
<?php
$username = "root";
$password = "";
$host = "localhost";
$database = "guestbook";
@mysql_connect($host, $username, $password) or die("Can not connect to database: ".mysql_error());
@mysql_select_db($database) or die("Can not select the database: ".mysql_error());
$id = $_GET['id'];
if(!isset($id) || empty($id)){
die("Please select your image!");
}else{
$query = mysql_query("SELECT * FROM tbl_images WHERE id='".$id."'");
$row = mysql_fetch_array($query);
$content = $row['image'];
header('Content-type: image/jpg');
echo $content;
}
?>