Here's my code, I can't see that it's any different from the code in part 6 except that I have a lot more of fields, but they are all working perfectly on the insert entries page...
CODE
<?php include("media/cookiecheck.php");
include($headervar.$skin.$extension); ?>
<?php
mysql_connect ("hostname", "*****", "*******");
mysql_select_db ('databasename');
if (isset($_POST['update'])) {
$month = htmlspecialchars(strip_tags($_POST['month']));
$date = htmlspecialchars(strip_tags($_POST['date']));
$year = htmlspecialchars(strip_tags($_POST['year']));
$time = htmlspecialchars(strip_tags($_POST['time']));
$filesize = $_POST['filesize'];
$fileformat = $_POST['fileformat'];
$description = $_POST['description'];
$filelocation = $_POST['filelocation'];
$thumblocation = $_POST['thumblocation'];
$screencaps = $_POST['screencaps'];
$translation = $_POST['translation'];
$timestamp = strtotime($month . " " . $date . " " . $year . " " . $time);
$category = (int)$_POST['category'];
if (!get_magic_quotes_gpc()) {
$description = addslashes($description);
}
$sql = "UPDATE media_archive SET timestamp='$timestamp', filelocation='$filelocation', thumblocation='$thumblocation', description='$description', category='$category', fileformat='$fileformat', filesize='$filesize', screencaps='$screencaps', translation='$translation' WHERE id='$id' LIMIT 1";
$result = mysql_query($sql) or print("Can't update table media_archive.<br />" . $sql . "<br />" . mysql_error());
if ($result != false) {
print "Your media has successfully been updated.";
}
}
if (!isset($_GET['id']) || empty($_GET['id']) || !is_numeric($_GET['id'])) {
die("Invalid entry ID.");
}
else {
$id = (int)$_GET['id'];
}
$result = mysql_query ("SELECT * FROM media_archive WHERE id='$id'") or print ("Can't select entry.<br />" . $sql . "<br />" . mysql_error());
while ($row = mysql_fetch_array($result)) {
$old_timestamp = $row['timestamp'];
$old_filelocation = stripslashes($row['filelocation']);
$old_description = stripslashes($row['description']);
$old_thumblocation = stripslashes($row['thumblocation']);
$old_filesize = stripslashes($row['filesize']);
$old_fileformat = stripslashes($row['fileformat']);
$old_screencaps = stripslashes($row['screencaps']);
$old_translation = stripslashes($row['translation']);
$old_filelocation = str_replace('"','\'',$old_filelocation);
$old_description = str_replace('<br />', '', $old_description);
$old_thumblocation = str_replace('"','\'',$old_thumblocation);
$old_filesize = str_replace('"','\'',$old_filesize);
$old_fileformat = str_replace('"','\'',$old_fileformat);
$old_screencaps = str_replace('"','\'',$old_screencaps);
$old_month = date("F",$old_timestamp);
$old_date = date("d",$old_timestamp);
$old_year = date("Y",$old_timestamp);
$old_time = date("H:i",$old_timestamp);
$old_cat=$row['category'];
}
?>
<ul style="list-style:none;">
<li>
Use this form to update media in the database. Remember that the file and thumbnails have to be uploaded first, this is not an upload form. If the media file is exclusive or you want to give special credit, state that in the description.</li><br>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<li><strong><label for="month">Date (month, day, year):</label></strong>
<select name="month" id="month">
<option value="<?php echo $old_month; ?>"><?php echo $old_month; ?></option>
<option value="January">January</option>
<option value="February">February</option>
<option value="March">March</option>
<option value="April">April</option>
<option value="May">May</option>
<option value="June">June</option>
<option value="July">July</option>
<option value="August">August</option>
<option value="September">September</option>
<option value="October">October</option>
<option value="November">November</option>
<option value="December">December</option>
</select>
<input type="text" name="date" id="date" size="2" value="<?php echo $old_date; ?>" />
<select name="year" id="year">
<option value="<?php echo $old_year; ?>"><?php echo $old_year; ?></option>
<option value="1997">1997</option>
<option value="1998">1998</option>
<option value="1999">1999</option>
<option value="2000">2000</option>
<option value="2001">2001</option>
<option value="2002">2002</option>
<option value="2003">2003</option>
<option value="2004">2004</option>
<option value="2005">2005</option>
<option value="2006">2006</option>
<option value="2007">2007</option>
<option value="2008">2008</option>
</select></li><br>
<li><strong><label for="time">Time:</label></strong> <input type="text" name="time" id="time" size="5" value="<?php echo $old_time; ?>" /></li><br>
<?php
$result2 = mysql_query("SELECT * FROM media_archive_categories");
echo '<li><strong><label for="category">Category:</label></strong> <select name="category" id="category">';
while($row2 = mysql_fetch_array($result2)) { ?>
<option value="<?php echo $row2['category_id']; ?>" <?php if ($old_cat == $row2['category_id']) echo ' selected'; ?>><?php echo $row2['category_name']; ?></option>
<?php
}
?>
</select></li>
<li><strong><label for="thumblocation">Thumb location:</label></strong> <input type="text" id="thumblocation" value="<?php echo $old_thumblocation; ?>" name="thumblocation" size="40" /></li><br>
<li><strong><label for="filelocation">File location:</label></strong> <input type="text" id="filelocation" value="<?php echo $old_filelocation; ?>" name="filelocation" size="40" /></li><br>
<li><strong><label for="description">Description:</label></strong> <input type="text" id="description" value="<?php echo $old_description; ?>" name="description" size="70" /></li><br>
<li><strong><label for="filesize">File size:</label></strong> <input type="text" id="filesize" value="<?php echo $old_filesize; ?>" name="filesize" size="40" /></li><br>
<li><strong><label for="fileformat">File format:</label></strong> <input type="text" id="fileformat" value="<?php echo $old_fileformat; ?>" name="fileformat" size="40" /></li><br>
<li><strong><label for="screencaps">Screenshots:</label></strong> <input type="text" id="screencaps" value="<?php echo $old_screencaps; ?>" name="screencaps" size="40" /></li><br>
<li><strong><label for="translation">Translation:</label></strong> <input type="text" id="translation" value="<?php echo $old_translation; ?>" name="translation" size="40" /></li><br>
<li><input type="submit" name="update" id="update" value="Update"></li>
</form>
<?php
mysql_close();
?>
</ul>
</div>
</body>
</html>
include($headervar.$skin.$extension); ?>
<?php
mysql_connect ("hostname", "*****", "*******");
mysql_select_db ('databasename');
if (isset($_POST['update'])) {
$month = htmlspecialchars(strip_tags($_POST['month']));
$date = htmlspecialchars(strip_tags($_POST['date']));
$year = htmlspecialchars(strip_tags($_POST['year']));
$time = htmlspecialchars(strip_tags($_POST['time']));
$filesize = $_POST['filesize'];
$fileformat = $_POST['fileformat'];
$description = $_POST['description'];
$filelocation = $_POST['filelocation'];
$thumblocation = $_POST['thumblocation'];
$screencaps = $_POST['screencaps'];
$translation = $_POST['translation'];
$timestamp = strtotime($month . " " . $date . " " . $year . " " . $time);
$category = (int)$_POST['category'];
if (!get_magic_quotes_gpc()) {
$description = addslashes($description);
}
$sql = "UPDATE media_archive SET timestamp='$timestamp', filelocation='$filelocation', thumblocation='$thumblocation', description='$description', category='$category', fileformat='$fileformat', filesize='$filesize', screencaps='$screencaps', translation='$translation' WHERE id='$id' LIMIT 1";
$result = mysql_query($sql) or print("Can't update table media_archive.<br />" . $sql . "<br />" . mysql_error());
if ($result != false) {
print "Your media has successfully been updated.";
}
}
if (!isset($_GET['id']) || empty($_GET['id']) || !is_numeric($_GET['id'])) {
die("Invalid entry ID.");
}
else {
$id = (int)$_GET['id'];
}
$result = mysql_query ("SELECT * FROM media_archive WHERE id='$id'") or print ("Can't select entry.<br />" . $sql . "<br />" . mysql_error());
while ($row = mysql_fetch_array($result)) {
$old_timestamp = $row['timestamp'];
$old_filelocation = stripslashes($row['filelocation']);
$old_description = stripslashes($row['description']);
$old_thumblocation = stripslashes($row['thumblocation']);
$old_filesize = stripslashes($row['filesize']);
$old_fileformat = stripslashes($row['fileformat']);
$old_screencaps = stripslashes($row['screencaps']);
$old_translation = stripslashes($row['translation']);
$old_filelocation = str_replace('"','\'',$old_filelocation);
$old_description = str_replace('<br />', '', $old_description);
$old_thumblocation = str_replace('"','\'',$old_thumblocation);
$old_filesize = str_replace('"','\'',$old_filesize);
$old_fileformat = str_replace('"','\'',$old_fileformat);
$old_screencaps = str_replace('"','\'',$old_screencaps);
$old_month = date("F",$old_timestamp);
$old_date = date("d",$old_timestamp);
$old_year = date("Y",$old_timestamp);
$old_time = date("H:i",$old_timestamp);
$old_cat=$row['category'];
}
?>
<ul style="list-style:none;">
<li>
Use this form to update media in the database. Remember that the file and thumbnails have to be uploaded first, this is not an upload form. If the media file is exclusive or you want to give special credit, state that in the description.</li><br>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<li><strong><label for="month">Date (month, day, year):</label></strong>
<select name="month" id="month">
<option value="<?php echo $old_month; ?>"><?php echo $old_month; ?></option>
<option value="January">January</option>
<option value="February">February</option>
<option value="March">March</option>
<option value="April">April</option>
<option value="May">May</option>
<option value="June">June</option>
<option value="July">July</option>
<option value="August">August</option>
<option value="September">September</option>
<option value="October">October</option>
<option value="November">November</option>
<option value="December">December</option>
</select>
<input type="text" name="date" id="date" size="2" value="<?php echo $old_date; ?>" />
<select name="year" id="year">
<option value="<?php echo $old_year; ?>"><?php echo $old_year; ?></option>
<option value="1997">1997</option>
<option value="1998">1998</option>
<option value="1999">1999</option>
<option value="2000">2000</option>
<option value="2001">2001</option>
<option value="2002">2002</option>
<option value="2003">2003</option>
<option value="2004">2004</option>
<option value="2005">2005</option>
<option value="2006">2006</option>
<option value="2007">2007</option>
<option value="2008">2008</option>
</select></li><br>
<li><strong><label for="time">Time:</label></strong> <input type="text" name="time" id="time" size="5" value="<?php echo $old_time; ?>" /></li><br>
<?php
$result2 = mysql_query("SELECT * FROM media_archive_categories");
echo '<li><strong><label for="category">Category:</label></strong> <select name="category" id="category">';
while($row2 = mysql_fetch_array($result2)) { ?>
<option value="<?php echo $row2['category_id']; ?>" <?php if ($old_cat == $row2['category_id']) echo ' selected'; ?>><?php echo $row2['category_name']; ?></option>
<?php
}
?>
</select></li>
<li><strong><label for="thumblocation">Thumb location:</label></strong> <input type="text" id="thumblocation" value="<?php echo $old_thumblocation; ?>" name="thumblocation" size="40" /></li><br>
<li><strong><label for="filelocation">File location:</label></strong> <input type="text" id="filelocation" value="<?php echo $old_filelocation; ?>" name="filelocation" size="40" /></li><br>
<li><strong><label for="description">Description:</label></strong> <input type="text" id="description" value="<?php echo $old_description; ?>" name="description" size="70" /></li><br>
<li><strong><label for="filesize">File size:</label></strong> <input type="text" id="filesize" value="<?php echo $old_filesize; ?>" name="filesize" size="40" /></li><br>
<li><strong><label for="fileformat">File format:</label></strong> <input type="text" id="fileformat" value="<?php echo $old_fileformat; ?>" name="fileformat" size="40" /></li><br>
<li><strong><label for="screencaps">Screenshots:</label></strong> <input type="text" id="screencaps" value="<?php echo $old_screencaps; ?>" name="screencaps" size="40" /></li><br>
<li><strong><label for="translation">Translation:</label></strong> <input type="text" id="translation" value="<?php echo $old_translation; ?>" name="translation" size="40" /></li><br>
<li><input type="submit" name="update" id="update" value="Update"></li>
</form>
<?php
mysql_close();
?>
</ul>
</div>
</body>
</html>
Thanks in advance,
Sunnefa