(I figured out the problem but not the solution, so you can skip this initial post and go straight to the 3rd post.)
I'm a novice looking for some help. I have this php page I got from a webmonkey tutorial which helps me update my mySQL database thru a webpage. It worked fine for years on another site of mine but now I'm trying to use this same code on a different site. I've adjusted the database name, username, password, table name, and all 'field' names. Everything should work fine but it won't actually alter the database. Please glance at my code and see if you see anything that may be causing the problem.
1) My database is fine because I can update thru phpMyAdmin
2) My connection to the database is working because this code autofills the existing database info in to the web form.
3) I get no error messages. After I hit Submit goes to the confirmation text but the database ignored all intended changes.
Thank you very much for your help!!!
<html>
<body>
<?php
$db = mysql_connect("localhost", "XXXXXX", "XXXXXX");
mysql_select_db("XXXXXX",$db);
if ($league_id) {
if ($submit) {
$sql = "UPDATE leagues SET
league_name='$league_name',
league_city='$league_city',
league_county='$league_county',
league_region='$league_region',
league_state='$league_state',
league_blurb='$league_blurb',
league_graphic='$league_graphic',
league_phone_info='$league_phone_info',
league_phone_rain='$league_phone_rain',
league_email='$league_email',
league_website='$league_website',
league_organization='$league_organization',
league_eligibility='$league_eligibility',
league_rules='$league_rules'
WHERE league_id=$league_id";
$result = mysql_query($sql);
echo "Thank you! Information updated.\n";
echo "<p><a href=\"index.php\">click here</a> to update another entry.\n";
echo "<p><a href=\"new.php\">click here</a> to add a new entry.\n";
} else {
// query the DB
$sql = "SELECT * FROM leagues WHERE league_id=$league_id";
$result = mysql_query($sql);
$myrow = mysql_fetch_array($result);
?>
<form method="post" action="<?php echo $PHP_SELF?>">
<input type=hidden name="league_id" value="<?php echo $myrow["league_id"] ?>">
League Name: <input type="Text" size="40" name="league_name" value="<?php echo $myrow["league_name"] ?>"><br />
League City: <input type="Text" name="league_city" value="<?php echo $myrow["league_city"] ?>"><br />
League County: <input type="Text" name="league_county" value="<?php echo $myrow["league_county"] ?>"><br />
League Region: <input type="Text" name="league_region" value="<?php echo $myrow["league_region"] ?>"><br />
League State: <input type="Text" name="league_state" value="<?php echo $myrow["league_state"] ?>"><br />
League Blurb: <textarea name="league_blurb" cols="60" rows="7"><?php echo $myrow["league_blurb"] ?></textarea><br />
League Graphic: <input type="Text" name="league_graphic" value="<?php echo $myrow["league_graphic"] ?>">.gif<br />
League Info Phone: <input type="Text" name="league_phone_info" value="<?php echo $myrow["league_phone_info"] ?>"><br />
League Rain Phone: <input type="Text" name="league_phone_rain" value="<?php echo $myrow["league_phone_rain"] ?>"><br />
League Email: <input type="Text" name="league_email" value="<?php echo $myrow["league_email"] ?>"><br />
League Website: <input type="Text" name="league_website" value="<?php echo $myrow["league_website"] ?>"><br />
League Organization: <select name="league_organization"><option selected><option>Government<option>Private Business<option>Religious</select><br />
League Eligibility: <select name="league_eligibility"><option selected><option>Public<option>Industry Specific<option>Religious</select><br />
League Rules: <select name="league_rules"><option selected><option>ASA<option>ISA<option>NSA<option>USSSA</select><br />
<input type="Submit" name="submit" value="Process Information">
<?php
}
} else {
// display list of leagues
$result = mysql_query("SELECT * FROM leagues ORDER BY league_name",$db);
while ($myrow = mysql_fetch_array($result)) {
printf("<a href=\"%s?league_id=%s\">%s %s</a><br />\n", $PHP_SELF, $myrow["league_id"], $myrow["league_name"], $myrow["league_county"], $myrow["league_state"]);
}
echo "<p>If new entry, <a href=\"new.php\">click here</a>\n";
}
?>
</body>
</html>