here's the problem area:
Code: Select all
<a href="javascript:viewLargeImage('<?php echo $image['tourimage01']; ?>')"><img src="../viewImage.php?type=tourthumbnail&name=<?php echo $image['tourimage01thumb']; ?>" border="0" /></a><br />Code: Select all
<?php
include 'config.php';
include 'opendb.php';
?>
<?php
// make sure the image id is present
if (!isset($_GET['tourid'])) {
echo "Image id is not defined";
} else {
// get the image id
$tourid = $_GET['tourid'];
if (isset($_POST[''])) {
$company = $_POST[''];
$description = $_POST['description'];
if ($_FILES['images']['tmp_name'] != '') {
$images = uploadImage('images', TOUR_IMG_DIR);
if ($images['image'] == '' && $images['thumbnail'] == '') {
echo "Error uploading file";
exit;
}
$image = "'" . $images['image'] . "'";
$thumbnail = "'" . $images['thumbnail'] . "'";
$sql = "SELECT tourimage01, tourimage01thumb
FROM tours
WHERE tourid = $tourid";
$result = mysql_query($sql) or die('Error, get image info failed. ' . mysql_error());
$row = mysql_fetch_assoc($result);
unlink(TOUR_IMG_DIR . $row['tourimage01']);
unlink(TOUR_IMG_DIR . $row['tourimage01thumb']);
} else {
// the old image is not replaced
$image = "tourimage01";
$thumbnail = "tourimage01thumb";
}
$sql = "UPDATE tours
SET company = '$company',
description = '$description',
tourimage01 = $image,
tourimage01thumb = $thumbnail,
WHERE tourid = $tourid";
mysql_query($sql) or die('Error, update image failed : ' . mysql_error());
echo "<script>window.location.href='index.php?page=image-detail&tourid=$tourid';</script>";
} else {
$sql = "SELECT tourid, company, description, tourimage01, tourimage01thumb
FROM tours
WHERE tourid = $tourid";
$result = mysql_query($sql) or die('Error, get image info failed. ' . mysql_error());
if (mysql_num_rows($result) == 0) {
// can't find an image with that id
?>
<p align="center">Image not found. Click <a href="index.php?page=list-image">here</a>
to go to the image list</p>
<?php
} else {
$image = mysql_fetch_assoc($result);
?>
<form action="" method="post" enctype="multipart/form-data" name="frmAlbum" id="frmAlbum">
<table width="100%" border="0" cellpadding="2" cellspacing="1" class="table_grey">
<tr>
<th width="150">Image Title</th>
<td width="80"> <input name="company" type="text" id="company" value="<?php echo $image['company']; ?>" size="40" maxlength="64"></td>
</tr>
<tr>
<th width="150">Description</th>
<td> <textarea name="mtxDesc" cols="50" rows="10" id="mtxDesc"><?php echo htmlspecialchars($image['description']); ?></textarea> </td>
</tr>
<tr>
<th width="150">Image</th>
<td><?php if ($image['tourimage01thumb'] != '') { ; ?>
<a href="javascript:viewLargeImage('<?php echo $image['tourimage01']; ?>')"><img src="../viewImage.php?type=tourthumbnail&name=<?php echo $image['tourimage01thumb']; ?>" border="0" /></a><br />
<?php } ?>
<input name="images" type="file" class="box" id="images2"></td>
</tr>
<tr>
<td width="150"> </td>
<td> <input name="btnModify" type="submit" class="box" id="btnModify" value="Modify Image">
<input name="btnCancel" type="button" id="btnCancel" value="Cancel" onClick="window.history.back();"> </td>
</tr>
</table>
</form>
<?php
}
}
}
?>Code: Select all
<?php
// hostname or ip of server
$servername='localhost';
// username and password to log onto db server
$dbusername='username';
$dbpassword='password';
// name of database
$dbname='name';
// all tour images iare stored here
define('TOUR_IMG_DIR', '/home/dtours3/public_html/tours/tourimages/');
// When we upload an image the thumbnail is created on the fly
// here we set the thumbnail width in pixel. The height will
// be adjusted proportionally
define('THUMBNAIL_WIDTH', 100);
?>Please note that I took away the db info in this post, however I have it in the file I'm using and it works.