
As I noted before, both of these are files that worked fine on the old Apache installation. But here they are.
It works properly, accesses the database and constructs dropdowns with the proper values:
<?php
$title="Random Monster Tables";
include("header.php");
?>
<table border=1 cellpadding=0 cellspacing=0>
<tr><td>
<form method="post" action="appearing-table.php">
<table border=0 cellpadding=3 cellspacing=3>
<tr><td align="right">CR:</td><td><select name="cr">
<?php
for ($index=1; $index<=20; $index++) {
printf("<option>%s",$index);
}
?>
</select></td></tr>
<tr><td align="right">Habitat:</td><td><select name="habitat">
<?php
$res=mysql_query("SELECT id, Name FROM habitat_names ORDER by id",$db);
while ($row=mysql_fetch_array($res)) {
printf("<option value=\"%s\">%s",$row["id"],$row["Name"]);
}
?>
</select></td></tr>
<tr><td colspan=2 align=center><input type="submit" value="Generate Table">
<input type="reset" value="Reset"></td></tr>
</table>
</form>
</td></tr></table>
<P><a href="appearing-full.php">View Raw Data</a></P>
<?php
$timestamp=gmdate("D, d M Y H:i:s") . " GMT";
include("footer.php");
?>
This is B.php, also known as appearing-table.php, the form target from the above. The failure is in the 'if' test to make sure the form variables are set. If I insert a printf() to show $cr it shows blank.
<?php
$title="Generated Random Monster Table";
include("header.php");
//make sure the form variables are set
if (isset($cr) && isset($habitat)) {
printf("<p>Inside the if statement</p>");
$result=mysql_query("SELECT Name FROM habitat_names WHERE id=$habitat");
$item=mysql_fetch_array($result);
printf("<h3>%s at CR %s</h3>\n",$item["Name"],$cr);
$cr = "cr" . $cr;
?>
<table border=1 cellpadding=3 cellspacing=1>
<tr><th>Monster</th><th>Number Appearing</th></tr>
<?php
$result=mysql_query("SELECT Name, $cr FROM monsters AS m JOIN APPEARING AS a JOIN
habitats AS h WHERE h.monsterid=m.id AND h.existsin = \"X\" AND h.habitatid =
$habitat AND a.$cr != \"NULL\" AND a.monsterid = m.id ORDER BY m.name");
while ($row = mysql_fetch_array($result)) {
printf("<tr><td>%s</td><td>%s</td></tr>\n",$row["Name"],$row[$cr]);
}
}
?>
</table>
<a href="generate-table.php">Generate another table.</a>
<?php
$timestamp=gmdate("D, d M Y H:i:s") . " GMT";
include("footer.php");
?>
I thought it might be an issue of directory permissions (which is what most of the Web pages suggest) but that doesn't seem to be the case because appearing-full.php works if you click the link to navigate to it. The issue seems to be just with the form submit/form variables.