This code use to work on a Win2k3 machine running MySQL and PHP but I have since updated my server to Win2k8. I installed the newest version of MySql and PHP and the PHP itself is working. I am able to pull various fields from my database if I hardcode a selecr query. I am also able to run some snippets of code but this piece of code baffles me. Sometimes I can edit it, refresh my page as a check, restore the code, and it will work perfectly, yet if I open a new browser and return to the unedited code it fails. I assume it has something to do with my form and post and that maybe when it works for those moments it is because my $_POST['id'] is not null. Can someone please help me figure out what the problem is here? Thanks!
<?php
$username = "root";
$password = "";
$hostname = "localhost:3306";
$dbh = mysql_connect($hostname, $username, $password)
or die("Unable to connect to MySQL");
$selected = mysql_select_db("operations",$dbh)
or die("Could not select operations");
$query = "LOCK TABLES logins WRITE";
mysql_query($query);
print "<p><b><i>Select Record to View</i></b></p>";
//Begin Drop-Down Menu
$result = mysql_query("SELECT * FROM logins ORDER BY TitleName")
or die(mysql_error());
echo "<form name=\"submitme\" method=\"post\"action=\"".$_SERVER['PHP_SELF']."\">\n";
echo "<select name=\"id\" onchange=\"document.submitme.submit()\">\n";
while ($row = mysql_fetch_array($result,MYSQL_ASSOC)) {
echo "<option value=\"$row[Title]\">$row[TitleName]</option>\n";
}
echo "</select>\n";
echo "</form>";
//End Drop-Down Menu
if ($_POST['id']=="") { $NEW = $_POST['TITLE'];
}else{$NEW = $_POST['id'];}
$result = mysql_query("SELECT * FROM logins WHERE Title='$NEW'");
while ($row = mysql_fetch_array($result,MYSQL_ASSOC)) {
print "\n<b>".$row{'TitleName'}."</b><ol style=\"margin-top: 0in; margin-bottom: 0in\" type=\"circle\">";
print "\n<li>Website: <a href=\"".$row['Website']."\" target=\"_blank\">".$row['Website']."</a></li>";
print "\n<li>Website2: <a href=\"".$row['Website2']."\" target=\"_blank\">".$row['Website2']."</a></li>";
print "\n<li>UserEmail: ".$row['UserEmail']."</li>";
print "\n<li>User: ".$row['User']."</li>";
print "\n<li>Pass: ".$row['Pass']."</li>";
print "\n<li>Notes: ".$row['Notes']."</li>";
print "\n</ol>";
}
mysql_close($dbh);
?>