Getting rid of bugs I never thought I would have

Bill Mudry <[email protected]>
Newsgroups gmane.comp.php.windows
Message-ID <[email protected]>
Overall, I am happy with the progress on my pet TAXA project but the 
journey is proving to be like riding over a rocky road. The most 
recent effort at a functional addition has been a form to let users 
decide whether 2 of three types of data will show (general, 
woodworking & numeric). The general
data for each wood should always so and the users should be able to 
choose if either or both of hte other two should show (using include files).

At first in the form's simplest unformatted form, I got it working 
fine (and I rejoiced ....). Then when I tried to put it into a table 
to pretty it up again --- I would no longer work (... almost). I 
tried all kinds of things. If you temporarily hardcode the choices, 
the two tables show or do not as desired. Somehow
the user choices are not latching to the control lines. Every time 
you click on the submit button
(named ''Choose Data to View"), it cycles back to the same page like it should.

Now the weird things start. Yesterday, in reviewing everything before 
submitting to this forum, I
decided I should try it again ---- and to my astonishment for a while 
--- it worked! I could choose
the working data checkbox, the woodworking checkbox or both and they 
would show. Don't
check either and they didn't show just like should be. That was short 
lived, though(!). It hasn't
worked since. Ahem..... talk about flaky.....

But then I noticed another problem. To activate the user choice you 
have to click on the submit button of course. When I cycled through 
is when I noticed that now on species detail sheets that
are set up to show a scan of the wood being reported on the scan that 
first showed disappears,
leaving only the 'missing' graphic' symbol only.

So now I have two consternating problems:

         1 - How do I get the form to let users choose what data 
tables to show to work consistently
              well all the time? If it works mysteriously some of the 
time, my code should be fairly
              close to what it needs to be <fingers-crossed>.

         2 - How do I keep the scan showing always? I realize that 
each time the submit button is
              hit, the location for what scan file (all .jpg) should 
show gets lost. All scans are kept in
              and alphabetical list of folders according to the first 
letter of the (botanical) name of the           wood being showed:
                 /taxa/wood_scans/gallery_a/<filename>
                 /taxa/wood_scans/gallery_b/<filename> 
/taxa/wood_scans/gallery_c/<filename> 
/taxa/wood_scans/gallery_d/<filename>   and so on, but have been loaded into
                 the 'species' MySQL file (species.sql) also in 
column 'picture_filename'.

              I looked at various examples on the Net but could not 
see why it won't consistently work.
Probably the best way to understand what is happening is to try out 
the site. You can find it at (as before) www.prowebcanada.com/taxa. 
On the left side menu under 'Woods by Alphabet", use the
menu choice 'Woody Species'. Pick a name with a camera icon in front 
of it in the range of A,B or C
where there is more data for now). It doesn't matter whether or not 
you use the alphabetical menu first.

As long as you picked a species with a camera beside it, you should 
see a scan of what that wood
looks like --- as long as you have not yet used the user choice form 
below the Genera Data table. Now try picking if you want either the 
woodworking data and/or Numeric Data tables to show. Click
the submit button and notice it does recycle ok ---- but it is a 
minor miracle if the tables really do
show. Meanwhile, the graphic scan has disappeared <frustrating sigh....>

This time I think I had better show the code for the entire file :-( 
. All this is happening in file
'displayspecies.php'. There are many debugging commented lines you 
can ignore ;-) .

Glad for the help,

Bill Mudry


======================= Code follows =======================================

<?php

//////////////////////////////////////////////////////////////////////////////////////
//  File: displayspecies.php
//  Date last revision: May 26, 2010
//  Description: Displays all details of a chosen species.
//      Called by: displaygenera2.php
//
//
//////////////////////////////////////////////////////////////////////////////////////

parse_str($_SERVER['QUERY_STRING'], $qs);
$species_name=$qs['species_name'];

//$picture_filename1=$qs['picture_filename1'];


# 
////////////////////////////////////////////////////////////////////////////////////
#                                           CONNECT TO DATABASE
# 
////////////////////////////////////////////////////////////////////////////////////

include ("connecttotaxa.php");
$connection = mysql_connect($hostname, $username, $password)
         or die("Unable to connect to database server");

$db = mysql_select_db($dbname, $connection)
         or die("Unable to connect to database");

/* 
--------------------------------------------------------------------------------
                                             HOPEFULLY CONNECTED AT THIS POINT
---------------------------------------------------------------------------------- 

*/


$query6 = "SELECT * FROM species WHERE species_name='$species_name'";
//var_dump($query6);
$result6 = mysql_query($query6)
         or die(mysql_error());

If ($result6)
         {
         $row6=mysql_fetch_array($result6, MYSQL_ASSOC);
         // Echo "\$row6 is - $row6<br>\n";
         Echo MYSQL_ERROR();

         if ($row6){
         $z=extract($row6); //Echo MYSQL_ERROR();
         };

         Echo "<html>";
         Echo "<head>";

         Echo "<title>Data on a specific chosen botanical species 
$species_name" ;
         Echo "</title>";
         //Echo "        <!---
         //      <style type='text/css'>webmessage.p {font-size: 7px; 
font-family:Verdana, Geneva,
         //              sans-serif;}</style>
         //    -->       ";

///////////////////////////////////////////////////////////////////////////////////////////
//
//                                                 START OF BODY
//
///////////////////////////////////////////////////////////////////////////////////////////

?>

         <BODY bgcolor='antiquewhite' border='1'>


         <TABLE align='CENTER' cellpadding='10' 
bgcolor='antiquewhite' border='5' bordercolor='navy' width='800'>
         <TR>
                 <TD>

         <P align='left' class = 'webmessage.p'>
         The programming works well now but there is a lot of data to 
be stored.
                 It is a huge job that will take a long time to get 
most of it in. Till then, there may seem
                 to be a lot of data missing --- because there is!
         </P>
         <P align='left' class='webmessage.p'>
         This species area is still under development. It is the 
bottom of the botanical tree.
                   No further elements are under species. There are 
three categories for species data;
                   GENERAL DATA, WOODWORKING DATA AND NUMERIC TEST 
DATA. General Data will always be
                   shown while future programming will let the reader 
choose if woodworking or numeric test data shows.
         </P>
                 </TD>
     </TR>
         <TR>
                 <TD>
         <P align='left' class='webmessage.p'>
         Some species will have a lot of information for them, a few 
even for all three data areas. The species that TAXA
     reports ranges from massive wood from the largest trees in the 
world weighing tons to ssmall shrubs that are
     "woody" but without enough wood to be used for anything other 
than academic interest. Some woods have been
     researched and tested thoroughly while others are amongst the 
thousands that are only known by some basic facts.
     This shows why some data areas are rich with text and pictures 
while others have very little known about them.
     For such rare, obscure or small sized species, listing 
woodworking or numeric test data is neither practical or
     useful.
     </P>
                 <DL class='webmessage.p'>
                 <DT><B>General Information</B></DT>
             <DD>Basic information on wood any reader would want. 
Always present.
             </DD>
                 <DT><B>Woodworking Information</B></DT>
             <DD>Optional information on what a wood is like to use 
and work with.<BR />
                 Of interest for anyone who will work with a wood.
             </DD>
                 <DT><B>Numeric Test Information</B></DT>
             <DD>Optional information on lab test results.<BR />
                 Largely of interest to architects, engineers and 
researchers. Data is less common.
             </DD>
                 </DL>

         </P>

                 </TD>
     </TR>
     </TABLE>

<!-- 
-------------------------------------------------------------------------------------
                       END OF WEBMASTERS MESSAGE
------------------------------------------------------------------------------------------>
     <BR><BR>

<?php

         echo "<h2 align='center'>Woody Species $species_name</h2>";

         echo "<H4 align='center'><strong>Data on a chosen woody 
species known under a chosen genus</strong></h4>";


//////////////////////////////////////////////////////////////////////////////////////////////////////
// 
Section to show scans
//////////////////////////////////////////////////////////////////////////////////////////////////////
Echo "<div align = 'center'>";

         //$picture_filename1 = $_GET[picture_filename1];

          //Echo "START OF PICTURE AREA<br><br>";

         // Echo "On line 141 \$picture_filename1 is - 
$picture_filename1<br><br>";
         $picture_path = "./wood_scans/$picture_filename1";
          //Echo "\$picture_path is - $picture_path<br><br>";

         //echo "<img src = $picture_path><br />";

         //Echo " Before if, \$picture_path is - $picture_path<br /><br /";

         If ($picture_path)
                 {echo "<img src = $picture_path><br /><br />";}
         else echo "No picture<br /><br />";

         //(Echo "\$picture_path is - $picture_path<br /><br /;


  // Echo "<br />END OF PICTURE AREA<br /><br />";

Echo "</div";

//////////////////////////////////////////////////////////////////////////////////////////////////////
//                                                              Start 
of reporting general data.
//////////////////////////////////////////////////////////////////////////////////////////////////////

         Echo "<table align='CENTER' cellpadding='10' bgcolor='white' 
border='2' bordercolor='saddlebrown' width='800'>";
         Echo "<tr>";
         Echo    "<td colspan=2><h2 align='center'>General Data for 
Species $species_name</h2></td>";
         Echo "</tr>";
         Echo "<tr>";
         Echo    "<td>Authority - $authorities_species</td>";
         Echo    "<td>Varieties, cultivars, Hybrids, Subspecies - 
<br>\n $varieties</td>";
         Echo "</tr>";
         Echo "<tr>";
         Echo    "<td>Common Names - $species_commonname</td>";
         Echo    "<td>Synonyms - $syn_species</td>";
         Echo "</tr>";
         Echo "<tr>";
         Echo    "<td>Gymnosperm or Angiosperm? $gymno_angio</td>";
         Echo    "<td>Commercial wood? - $commercial_wood </td>";
         Echo "</tr>";
         Echo "<tr>";
         Echo    "<td>Uses - $species_uses</td>";
         Echo    "<td>Durability -  $durability</td>";
         Echo "</tr>";
         Echo "<tr>";
         Echo    "<td>Plant forms - $species_life_form</td>";
         Echo    "<td>Typical sizes of plant - $species_lifeform_size</td>";
         Echo "</tr>";
         Echo "<tr>";
         Echo    "<td>Seasoning - $seasoning</td>";
         Echo    "<td>Stability - . $stability</td>";
         Echo "</tr>";
         Echo "<tr>";
         Echo    "<td colspan=2>General Description - 
$species_description</td>";
         Echo "</tr>";
         Echo "<tr>";
         Echo    "<td colspan=2>Typical Defects - $defects</td>";
         Echo "</tr>";
         Echo "<tr>";
         Echo    "<td colspan=2>Toxicity - $toxicity</td>";
         Echo "</tr>";
         Echo "<tr>";
         Echo    "<td colspan=2>World Distribution - $location</td>";
         Echo "</tr>";
         Echo "<tr>";
         Echo    "<td colspan=2>Comments - $comments</td>";
         Echo "</tr>";



         Echo  "</td></tr></table><br><br>\n"; //Close off data table;

    Echo "<hr width='400'><br />";
         }


//////////////////////////////////////////////////////////////////////////////////////////////////////
//
//              Let users decide if they wish to view woodworking 
and/or numeric test data.
//
//////////////////////////////////////////////////////////////////////////////////////////////////////

//$show_woodworking = "off";
//$show_numeric = "off";
?>
<div align="center">
<H3 align="center">Choose if you wish to also view Woodworking or 
Numeric Data</H3>

  <FORM name="choose_data"  method="GET" action="<?php echo 
$_SERVER['PHP_SELF']; ?>" >

<TABLE align="center" border=0 bgcolor='ivory' cellpadding=10>
<TR>
         <TD >
                 <B>Show Woodworking Data  </B>
                 <Input type='checkbox' name='show_woodworking' value="OFF">
         </TD>
         <TD >
                 <B>Show Numeric Test Data  </B>
                 <Input type='checkbox' name='show_numeric' value="OFF">
         </TD>
</TR>
<TR>
         <TD colspan=2 align="center">
                 <Input type='submit' value='Choose Data to View'>
         </TD>
         </TR>
         </TABLE>
</FORM>

<?PHP
////////////////////////////////////////////////////////
//    END OF FORM, START OF PROCESSING USER INPUT
////////////////////////////////////////////////////////

//$display_working_data =""; // initialize responses to empty before 
retrieving them
//$display_numeric_data ="";

//Echo "line 254 \$display_working_data is - $display_working_data ";
//Echo "<br />";
//Echo "line 256 \$display_numeric_data is - $display_numeric_data ";
//Echo "<br />";

//bring in user's answers from form:
//$display_working_data = $_GET['show_woodworking'];
//$display_numeric_data = $_GET['show_numeric'];

//check what user responses are:
//echo "Line 262 - \$display_working_data is - $display_working_data<br />";
//Echo "line 263 - \$display_numeric_data is - $display_numeric_data<br />";

if ($display_working_data) {
     Echo "line 269 - \$display_working_data is - $display_working_data ";
         Echo "<br />";
         include "./woodworking_data.php";
         }
else {
                 Echo "Working data chosen not to show<br /><br />";
//              echo "Line 274 - \$display_working_data is - 
$display_working_data<br />";

                 };

//  echo "working_data is - $display_working_data";

//Echo "line 282 - \$display_numeric_data is - $display_numeric_data ";


if ($display_numeric_data) {
Echo "line 284 - \$display_numeric_data is - $display_numeric_data ";
Echo "<br />";
         include "./numeric_data.php";
         }
         else {Echo "Numeric data chosen not to show<br /><br />";
};

//echo "numeric_data is - $display_numeric_data";

echo "<br />";

//include "./wood_data.php";

?>

<H3 align="center" >END OF WOOD DATA REPORT</H3>


</BODY>
</HTML>

(I haven't added in the two include files since I have seen them work 
ok when the form does work.).
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.