Recently, I've switched to a new website host and now the script doesn't work.
Before, I was using PHP 4.4.1 and MySQL 4.0.25, and now I'm using PHP 5.0.4 and MySQL 4.1.14. The script itself, and the information in the databases are identicle, so I've come to believe that this is a compatability problem with the different versions.
Here's the script, for anyone that follows me so far:
<?php
mysql_connect("localhost","#####","******");
mysql_select_db("DB");
if(!isset($cmd)) {
$result = mysql_query("select * from TABLE order by id desc limit 5");
while($r=mysql_fetch_array($result)) {
$week=$r["week"];
$id=$r["id"];
echo "<br /><center><div style='font-size: 10px;'><a href='TABLE-edit.php?cmd=edit&id=$id'>TABLE #$week</a></div></center><br /><hr />";
} } ?>
<?
if($_GET["cmd"]=="edit" || $_POST["cmd"]=="edit") {
if (!isset($_POST["submit"])) {
$id = $_GET["id"];
$sql = "SELECT * FROM TABLE WHERE id=$id";
$result = mysql_query($sql);
$myrow = mysql_fetch_array($result);
?>
<form action="TABLE-edit.php" method="post">
<input type="hidden" name="id" value="<?php echo $myrow["id"] ?>" />
<input type="hidden" name="cmd" value="edit" />
<table width="98%" cellspacing="4" cellpadding="3" border="0" align="center">
<tr><td width="100%"><div style="font-size: 10px; font-weight: bold; color: #C3AB97;">Winner's Name:</div></td></tr>
<tr><td width="100%"><input name="winner" type="text" style="width: 220px; font-weight: bold;" value="<?php echo $myrow["winner"] ?>" /></td></tr>
<tr><td width="100%"><div style="font-size: 10px; font-weight: bold; color: #C3AB97;">TABLE #:</div></td></tr>
<tr><td width="100%"><input name="week" type="text" style="width: 220px; font-weight: bold;" value="<?php echo $myrow["week"] ?>" /></td></tr>
<tr><td width="100%"><div style="font-size: 10px; font-weight: bold; color: #C3AB97;">Date:</div></td></tr>
<tr><td width="100%"><input name="date" type="text" style="width: 220px; font-weight: bold;" value="<?php echo $myrow["date"] ?>" /></td></tr>
<tr><td width="100%"><div style="font-size: 10px; font-weight: bold; color: #C3AB97;">Cropped (279x92 recommended):</div></td></tr>
<tr><td width="100%"><input name="cropped" type="text" style="width: 220px; font-weight: bold;" value="<?php echo $myrow["cropped"] ?>" /></td></tr>
<tr><td width="100%"><div style="font-size: 10px; font-weight: bold; color: #C3AB97;">Full Sized :</div></td></tr>
<tr><td width="100%"><input name="full" type="text" style="width: 220px; font-weight: bold;" value="<?php echo $myrow["full"] ?>" /></td></tr>
<tr><td width="100%"><div style="font-size: 10px; font-weight: bold; color: #C3AB97;">Be sure to upload the Cropped and Full-Sized Sig. Due to the nature of MySQL databases, images
can't be stored in the same way text can. You'll have to FTP the sigs.</div></td></tr>
<tr>
<td width="100%" align="center"><input type="submit" value="submit" name="submit" style="text-transform: uppercase; font-weight: bold;"/></td>
</tr>
</table>
</form>
<? } ?>
<?
if ($_POST["$submit"]) {
$winner = $_POST['winner'];
$week = $_POST['week'];
$date = $_POST['date'];
$cropped = $_POST['cropped'];
$full = $_POST['full'];
$sql = "UPDATE TABLE SET winner='$winner',week='$week', date='$date', cropped='$cropped', full='$full' WHERE id=$id";
$result = mysql_query($sql);
echo "
<center>TABLE Updated</div><br /><br /><br /><br />
<a href='index.php'>Click Here To Return To The Admin Section</a></center>
";
}
}
?>
In plain english, this script connects to the database, retrieves the last 5 rows, and echos them out in a link. The link is clicked, and an HTML form with all the information is displayed so the row can be edited. The submit button is hit, the row in the database is updated, and a confirmation page is displayed saying that everything worked the way it was supposed to work.
Now here's the problem. On the new server, the links are echoed out just fine, but when one of them is clicked, they don't dissappear. The links stay at the top of the page, and the HTML form comes on the bottom. And when the submit button is hit, the script goes back to the links echoed out instead of updating the database. The confirmation page never displays.
I'm sure there is a very specific problem here, but I'm not sure what it is. Is PHP known to do this from time to time? Would the new versions of PHP and MySQL conflict with the older version's coding?
Any and all help would be greately appreciated. Thank you all for your time.
