I've changed that, and turned on error reporting for warnings and notices.
The error is: Notice: Undefined index: photo in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\elimu\admin\gallery.php on line 8
I've also checked my php.ini to check whether file uploads are on or not.
New updated code:
$file=$_POST["photo"];
if (isset($file))
{
echo "1";
$conn=mysql_connect($host,$username,$password) or die(mysql_error());
mysql_select_db("$db_name")or die("cannot select DB");
$uploadDate=date("d/m/y : H:i:s", time());
$target_path = "../gallery/";
$target_path = $target_path . basename( $_FILES['photo']['name']);
$galleryId=$_POST['photoGallery'];
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path))
{
$sql="INSERT INTO tblphotogallery (galleryId,location,uploadDate,show) VALUES ('$galleryId','$target_path','$uploadDate','1')";
echo $sql;
mysql_query($sql) or die(mysql_error());
}
}
else
{
echo "2";
}
?>
<h1>Elimu Website Admininistration - Image Gallery</h1>
<a href="gallery.php">Image Gallery</a>
<table bgcolor="#FFFF99">
<tr bgcolor="#FFFFCC"><td>Select</td><td>Name</td><td>Gallery</td><td>Upload Date</td></tr>
<?php
$conn=mysql_connect($host,$username,$password) or die(mysql.error());
mysql_select_db("$db_name")or die("cannot select DB");
$sql="SELECT * FROM tblphotogallery,tblgallery ORDER BY pictureId";
$result=mysql_query($sql);
$row=mysql_fetch_array($result);
while($row = mysql_fetch_array($result))
{?>
<tr><td><?php echo $row['show']; ?></td><td><?php echo $row['name']; ?></td><td><?php echo $row['uploadDate']; ?></td></tr>
<?php
}
?>
</table>
<h1>Upload Picture</h1>
<form enctype="multipart/form-data" action="gallery.php" method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="10000000" />
<label for="photo">Select file:</label><input type="file" name="photo" />
<label for="photoGallery">Gallery:</label><select name="photoGallery">
<?php
$sql2="SELECT * FROM tblgallery ORDER BY galleryId";
$result2=mysql_query($sql2);
$row2=mysql_fetch_array($result);
while($row2 = mysql_fetch_array($result2))
{
print '<option value="'.$row2['galleryId'].'">'.$row2['name'].'</option>';
}
?>
</select>
<input type="submit" value="Upload photo"/>
</form>