Same code but some photos won't show.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I finally got code going to show off UV fluorescent (wood) photos. All pages are dynamically formed with PHP and MySQL. Most photos show but, strangely --- some do not, even though it is the same code that is forming each page according to what a user picks as the species to view.

In fact, most pages form fine right to the last item at the bottom of the
page ---- but most of the ones that do not form mysteriously hang up
well before the part where the picture should form. For the
fluorescence page for Acacia albida, for instance the output shows no
picture but only:
...................................................................................................

Close this Window


Ultraviolet Fluorescence Photo of Acacia albida

(Only 10 to 15% of all wood species fluoresce under UV)

.....................................................................................................................

All photos are JPEG,s taken with a digital camera, both those that show ok
and those that refuse to. So far I have only fluorescence photos of woods
starting with alphabetical names starting with A. The default folder where all
the php and html files are is /taxa. The photos (considering there is only
those starting with A) are all stored in /taxa/uv/uva. The path and file names
are stored in (MySQL) table 'uvphotos' in column 'uv_filename.

To arrive at one of these pages, users have to:
        - pick a species (under alphaspecies.php) from as much as over
          15,000 wood names. It will take a user to a data page on that
          chosen species. Just below is three pop-up windows, including
          the one for UV photos.
There is a photo icon in the alpha species menu but no icon yet to give an
advance indication of which species have UV photos. I am on the coding
trail to arrange that, hopefully soon. To help illustrate the problem I am
describing, the Acacia aneura UV photo comes up fine, while you can
observe

Acacia acuminata as one that does not show its UV

picture. A shortcut to the alphabetical listings is:
        http://www.prowebcanada.com/taxa/alphaspecies.php

Summary:
So ...... some UV photos show while others do not, even though it is the
SAME code forming both. All photos are valid, not corrupted JPEG files.
This is a total mystery to me.

Has anyone else came across such an error or bug? What is causing it
---- and far more ---- how do I rectify this?.

I will include all the code for the whole page but you should find that the most
relevant code is roughly between lines 120 and 130.

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

[Code}
<?php
////////////////////////////////////////////////////////////////////////////////////////////////////////
//  Program: show_uv_photos.php
// Description: This program displays Uv fluorescence photos of wood found to glow under an ultraviolet
//  light. This is around 10% - 15% of all wood species.
//
// It runs as a pop-up window and is activated by a button titled "U.V. Fluorescence" generated by // displayspecies.php. Future code may be added later to display the buttons only if the program can
//  detect UV photos stored for each species.
//  PARAMETERS:
// {$_SESSION["speciesname"]} - Looks back to find what the current species picked is. // speciesname - The session variable name for the current species. // $speciesname - The standard variable name taken from the session variable. // species_name - the name of the column that stores up to over 15,000 different botanical names of wood. // uvphotos - the name of the table in the TAXA database that holds the partial path and photo file
//                      name
////////////////////////////////////////////////////////////////////////////////////////////////////////
session_start();

//ECHO "Session variable for species name is - {$_SESSION['species_name']}"; //Debug statement
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd";>
<HTML>
<head>
<title>TAXA: Ultraviolet Wood Fluorescence</title>


</head>

<body bgcolor='ivory'>

<table align='center' cellpadding='5', Cellspacing='0' border =0>
<tr>
        <td valign='top'>
                <form name='NewWin'>
<p><A href="javascript: self.close ()">Close this Window</A></p>
                </form>
        </td>
</tr></table>


<?PHP

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



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

$dbname="taxa";
$db = mysql_select_db($dbname, $connection)
        or die("Unable to connect to database");
/*
--------------------------------------------------------------------------------
                                            HOPEFULLY CONNECTED AT THIS POINT
----------------------------------------------------------------------------------
*/

///////////////////////////////////////////////////////////////////////////////////////////////////////
// SECTION TO DISPLAY WOOD SCANS
/////////////////////////////////////////////////////////////////////////////////////////////////////

        Echo "<div align = 'center'>";

        Echo "<H2 align=\'center\'>Ultraviolet Fluorescence Photo of
        {$_SESSION["speciesname"]}</H2>";

Echo "<p align=\'center\'><I>(Only 10 to 15% of all wood species fluoresce under UV)</I></p>";
        //Echo "Line 74<br />";

$speciesname = $_SESSION["speciesname"]; //Successful transfer of ssssion parameter to a variable. //Echo "The species name is - $speciesname<br />"; //Proof that it transferred properly

//$uvquery = "SELECT * FROM uvphotos WHERE 'species_name' = $speciesname";

        $speciesname = mysql_real_escape_string($speciesname);

        //ECHO "\$speciesname, line 73 is - $speciesname<br />";

        $uvquery = "
        SELECT u.uv_filename
        FROM uvphotos u
        JOIN species s
        ON u.species_name=s.species_name
        WHERE u.species_name = '$speciesname'";

        //WHERE u.species_name = 'Acacia aneura'";


        //ECHO "Line 85 -<br /> $uvquery<br />"; //debug statement

        $uvresult = mysql_query($uvquery) or die(mysql_error());

        if(!$uvresult)
                die(mysql_error())
                ;

        //ECHO "<br />\$uv_filename is - $uv_filename<br />";


        $numrows = mysql_num_rows($uvresult) or die (mysql_error());
        //ECHO "Number of rows is - $numrows<br />";

        if(mysql_num_rows($uvresult) >0){
                $row = mysql_fetch_array($uvresult);
                //ECHO "\$row on line 99 is - $row<BR />";
        };

        //$row = mysql_fetch_array($uvresult);
        //ECHO "\$row on line 104 is - $row<BR />";


                EXTRACT($row);
        //ECHO "\$row on line 108 is - $row<BR />";
//ECHO "The path and file name, line 120 is $row('uv_filename')<BR />";

        $uv_filename = $row['uv_filename'];

        //ECHO "the uv photo name is - $row[0]<br />";

        $uvpath = "./uv/$uv_filename";

        ECHO "<img src='$uvpath'><br />";


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

        //ECHO "<HR>";

Echo "</div>";



?>

<!-- <h4 align="center">Webmaster: This function is still Under Construction</h4> -->



<table align='center' cellpadding='5', Cellspacing='5' border =1>
<tr>
        <td valign='top'>
                <form name='NewWin'>
<p><A href="javascript: self.close ()">Close this Window</A></p>
                </form>
        </td>
</tr></table>

</body>
</HTML>

[/code]



--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux