Hi All just wondering if anyone knows of a similar PHP message board.
I am trying to use PHP for the first time and keep getting an error and am
not sure of how to get around the problem
Basically I have got 2 PHP programs:
One where I allow a user to select a name:
<?php
# personal.php
# include file
include ("test_holding_inc.php");
$sql="SELECT name,ID FROM personal";
$mysql_result=mysql_query($sql,$connection);
$num_rows=mysql_num_rows($mysql_result);
if ( $num_rows == 0 ) {
echo "Sorry there is no information";
} else {
# we have records
echo "<FORM METHOD=GET ACTION=\"see_rec.php\">";
echo "Please select a person <BR>";
echo "<SELECT NAME=\"rec_ID\">";
while ($row=mysql_fetch_array($mysql_result))
{
$name=$row["name"];
$ID=$row["ID"];
# display results
echo "<OPTION VALUE=\"$ID\" >$name";
}
echo "</SELECT>";
} # end else
echo "<BR><BR>";
echo "<INPUT TYPE=\"SUBMIT\" VALUE=\"View the details !\">";
echo "<INPUT TYPE=\"RESET\" VALUE=\"Clear me!\">";
mysql_close($connection);
?>
And the second one (which should display the result however I keep getting
an error message when I have $rec_ID below. It says :
Sorry there is no information
Back PHP Notice: Undefined variable: rec_ID in
c:\Inetpub\wwwroot\personalphp\see_rec.php on line 8
If I change $rec_ID to a value such as 1 or 2 etc I get a result.
Wondering if anyone might know why this is not working.
<?php
# see_rec.php
# include file
include ("test_holding_inc.php");
$sql="SELECT * FROM personal WHERE ID = '$rec_ID'";
$mysql_result=mysql_query($sql,$connection);
$num_rows=mysql_num_rows($mysql_result);
if ( $num_rows == 0 ) {
echo "Sorry there is no information";
} else {
# we have results
echo "<TABLE ALIGN=\"CENTER\" BORDER=\"3\">";
echo "<TR><TH>Name</TH><TH>Address</TH><TH>Town</TH><TH>Country</TH></TR>";
while ($row=mysql_fetch_array($mysql_result))
{
$name=$row["name"];
$address=$row["address"];
$town=$row["town"];
$country=$row["country"];
$ID=$row["ID"];
# display results
echo
"<TR><TD>$name</TD><TD>$address</TD><TD>$town</TD><TD>$country</TD></TR>";
}
} # end else
mysql_close($connection);
?>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Deploy Web Applications Quickly across the enterprise with ColdFusion MX7 &
Flex 2
Free Trial
http://www.adobe.com/products/coldfusion/flex2/?sdid=RVJU
Archive:
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:273654
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4