Board index   FAQ   Search  
Register  Login
Board index php forum :: Database mySQL & php coding

Variables not passing Correctly

Codes here !

Moderators: macek, egami, gesf

Variables not passing Correctly

Postby run2web » Thu Jan 23, 2003 12:46 pm

I am so discouraged. I hope that someone can help me. I have a file that performs a query and shows the results in a drop down box. That works. The user then chooses which result they want to use and they press the submit button which is then supposed to pass that information on to the next page where it is supposed to display various data in their respective places on a printable page. What is happening is that no matter which choice is made on the selection page, there is only one bit of information passed. I am so confused. I have written like 25 different variations of this same thing and they all work. I have gone through the code for days with no clue. Here is the code (there are two parts, one for each page)
The code for the drop down box:
Code: Select all
 $sql_interred_cert = "SELECT $interred.ID AS InterredID,
                  PlotID, $interred.FirstName, $interred.LastName, $interred.ServiceDate,
                  SectionNumber, LotNumber, LotLocation
                  FROM $interred
                  LEFT JOIN $plots ON $plots.ID = $interred.PlotID
                  WHERE $interred.ID=last_insert_id($interred.ID) ORDER BY last_insert_id($interred.ID) DESC ";
/************* Display Result from Query**********/
/*************************************************/
$result_interred_cert = mysql_query($sql_interred_cert,$connection) or die(mysql_errno() . ": " . mysql_error());

   while ($row = mysql_fetch_array($result_interred_cert)) {
   
      $ID = $row['InterredID'];
      $PlotID = $row['PlotID'];
         $FirstName  = $row['FirstName'];
      $LastName = $row['LastName'];
      $ServiceDate = $row['ServiceDate'];
      $SectionNumber = $row['SectionNumber'];
         $LotNumber  = $row['LotNumber'];
      $LotLocation = $row['LotLocation'];

      $option_block .=  "<option value='$ID'> $ServiceDate, $LastName,  $FirstName,  $SectionNumber $LotNumber $LotLocation</option>";

}
/*  Check results of $result array
echo print_r($result_interred_cert);

 */
 $display_block = "
<FORM METHOD='post' ACTION='intercert.php'>
<select class='blue' name='ID'>
$option_block 
</select><br>
<strong><span class='black'>(Service Date, Last Name, First Name, Section Lot Space)</span></strong>
<br>
<INPUT class='input' TYPE='SUBMIT' NAME='submit' VALUE='Select This Interred Person'></P>
</form>
";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>Print Interment Certificate</title>
<link href="cemetery.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table width="600" height="150" border="1" align="center" cellpadding="0" cellspacing="0" bgcolor="#edecfe">
  <tr>
    <td width="587" height="136" align="center">
      <h2 align="center"><strong>Choose Interred Person to Print Certificate</strong></h2>
      <h4 align="center">Select Interred Person to print certificate from the
        list below.</h4>
     <h4 align="center"><?php echo "$display_block"; ?> </h4>
........blah blah

The code for putting the data into the page:
Code: Select all
$ID= $_POST['ID'];
$thePlotID= $_POST['thePlotID'];
if (!$ID) {
   header("Location: the_page_from_the_code_above.php");
   exit;
}
.....Connection Made here...
$db = @mysql_select_db($db_name, $connection) or die("Could not select database.");

$uf= new UserFriendlyToolKit($connection);

$sql_interred_cert = "SELECT $interred.ID AS InterredID, PlotID, $interred.FirstName, $interred.LastName, ServiceDate, DOB, DOD, SectionNumber, LotNumber, LotLocation, $fundir.StreetAddress
                  FROM $interred
                  LEFT JOIN $plots ON $plots.ID = $interred.PlotID
                  LEFT JOIN $fundir ON $interred.FunDirID=$fundir.ID               
                       WHERE $plots.ID = $interred.PlotID ORDER BY LastName, FirstName"; 
                  
//echo $sql_interred_cert."<BR><BR>\n";

$result_interred_cert = mysql_query($sql_interred_cert,$connection) or die(mysql_errno() . ": " . mysql_error());
   
   while ($row = mysql_fetch_array($result_interred_cert)) {
   
      $ID = $row['InterredID'];
      $PlotID = $row['PlotID'];
         $FirstName  = $row['FirstName'];
      $LastName = $row['LastName'];
      $ServiceDate = $row['ServiceDate'];
      $DOB = $row['DOB'];
      $DOD = $row['DOD'];
      $FunDirID = $row['FunDirID'];
      $StreetAddress = $row['StreetAddress'];      
      $SectionNumber = $row['SectionNumber'];
         $LotNumber  = $row['LotNumber'];
      $LotLocation = $row['LotLocation'];
   }
//echo $result_interred_cert."<br><br>\n";
if(is_array($result_interred_cert)) {

print_r($result_interred_cert);
}else{
echo $result_interred_cert . " Is Not A Valid Array";
}
mysql_free_result($result_interred_cert);
$sql_name= "SELECT * FROM $own WHERE OwnerID = '$OwnerID' ";
    $owner = @mysql_query($sql_name,$connection) or die(mysql_errno() . ": " . mysql_error());
    while ($the_owner = mysql_fetch_array($owner)) {
       $ownID = $row['ID'];   // not the same thing as OwnerID
   if($ownID > 0)   // Exclude "No Owner"
   {
      $LastName = $the_owner['LastName'];
      $FirstName = $the_owner['FirstName'];
     }
   }
//echo $sql_name."<br><br>\n";
?>
.....HTML CODE Follows and there are echo statements to show the results.....


I hope someone can help me. :?
run2web
New php-forum User
New php-forum User
 
Posts: 3
Joined: Thu Jan 23, 2003 11:54 am
Location: USA

Postby Joan Garnet » Sun Jan 26, 2003 12:01 pm

Maybe it has something to do with this:
Code: Select all
$ID= $_POST['ID'];
$thePlotID= $_POST['thePlotID'];

Try using this one:
Code: Select all
$ID= $HTTP_POST_VARS['ID'];
$thePlotID= $HTTP_POST_VARS['thePlotID'];

Maybe your hosting provider is using a php version previous to
Note: Introduced in 4.1.0. In earlier versions, use $HTTP_GET_VARS.

bye!
User avatar
Joan Garnet
Moderator
Moderator
 
Posts: 387
Joined: Sat Aug 03, 2002 2:56 am
Location: Mars

Postby run2web » Mon Jan 27, 2003 6:06 am

Joan Garnet wrote:Maybe it has something to do with this:
Code: Select all
$ID= $_POST['ID'];
$thePlotID= $_POST['thePlotID'];

Try using this one:
Code: Select all
$ID= $HTTP_POST_VARS['ID'];
$thePlotID= $HTTP_POST_VARS['thePlotID'];

Maybe your hosting provider is using a php version previous to
Note: Introduced in 4.1.0. In earlier versions, use $HTTP_GET_VARS.



Thanks, good thought but that isn't it. My provider uses version 4.2.2. I did get parts of it to pass but now it is passing weird information. For example I have two entries that have the same owner, same service date but different plot numbers, (she was buried in the middle of two plots). Anyway, the funeral director is the same for each entry. I have looked at the data in the DB and it is correct. What it is showing in the result is 2 different Funeral Directors and on one it shows the address of the director and on the other it doesn't. It is almost like it is doing random stuff. However it is consistent with the results, just not showing the results properly for that entry. :?
run2web
New php-forum User
New php-forum User
 
Posts: 3
Joined: Thu Jan 23, 2003 11:54 am
Location: USA


Return to mySQL & php coding

Who is online

Users browsing this forum: Exabot [Bot], Google [Bot] and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron