
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.
no subject
Date: 2008-12-05 04:53 am (UTC)Also:
http://www.tizag.com/phpT/examples/formvar.php
Have you tried to see the value of
$_POST["cr"]
Have you tried with something more simple first? Because I don't see where you're giving the options in your web form an actual value. So it's possible you *are* actually getting the value of "cr", but because you haven't actually assigned a value to it, the value is NULL.
You do assign a value for habitat. Do you get a value for that?
Try with this first:
[INPUT TYPE=TEXT NAME="cr"] (I tried using angle brackets and my code was eated! pretend [ = < and ] = > and you'll be set.)
and see what you get when you type something into the checkbox, submit the form, and see if you get the variable assigned to the value of what you typed.
First determine if it's actually whether or not the variables are being passed, and then you can deal with the fact that "cr" doesn't even have any values *to* assign, even if you do select an option from the list.
no subject
Date: 2008-12-05 05:08 am (UTC)http://us2.php.net/variables.predefined
A simple fix is to use $_POST['cr'] instead of $cr.
Grr, argh
Date: 2008-12-05 05:40 am (UTC)Specifically:
Register_globals is off in the INI file.
Changing the target PHP page to use $_POST[cr] and $_POST[habitat] still gives blank values.
I also tried a simple text input of the form
and when I examine $_POST[testtext] in the target file it is likewise empty.
As caulay noted, I should be able to circumvent the post procedure by stuffing the URL. But that also fails.
Re: Grr, argh
Date: 2008-12-05 06:05 am (UTC)Re: Grr, argh
Date: 2008-12-05 07:21 am (UTC)Re: Grr, argh
Date: 2008-12-05 02:23 pm (UTC)that said, what IM should I use for you? I've got Trillian but most of my IMing these days is via gchat.
Re: Grr, argh
Date: 2008-12-05 11:08 pm (UTC)no subject
Date: 2008-12-05 05:42 am (UTC)Should you ever want to post a bit of code to your LJ that contains angle brackets you can type < for the left angle bracket and > for the right angle bracket.
no subject
Date: 2008-12-05 07:19 am (UTC)no subject
Date: 2008-12-05 04:58 am (UTC)no subject
Date: 2008-12-05 05:01 am (UTC)no subject
Date: 2008-12-05 05:32 am (UTC)no subject
Date: 2008-12-05 06:06 am (UTC)no subject
Date: 2008-12-05 05:00 am (UTC)For example:
http://localhost:80/b.php?cr=Some_Value&habitat=Some_Other_Value
If that works then your problem is passing the values from the first page. If it doesn't work the PHP is not picking up the passed in values for the second page.
Good luck.
no subject
Date: 2008-12-05 05:31 am (UTC)