Same code but some photos won"t show.
am 27.02.2011 22:03:13 von Bill MudryI 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}
//////////////////////////////////////////////////////////// ////////////////////////////////////////////
// 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
?>
"http://www.w3.org/TR/html4/loose.dtd">
#
//////////////////////////////////////////////////////////// ////////////////////////
# 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 "
Echo "
Ultraviolet Fluorescence Photo of
{$_SESSION["speciesname"]}
";Echo "
(Only 10 to 15% of all wood
species fluoresce under UV)
//Echo "Line 74
";
$speciesname = $_SESSION["speciesname"]; //Successful
transfer of ssssion parameter to a variable.
//Echo "The species name is - $speciesname
"; //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
";
$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 -
$uvquery
"; //debug statement
$uvresult = mysql_query($uvquery) or die(mysql_error());
if(!$uvresult)
die(mysql_error())
;
//ECHO "
\$uv_filename is - $uv_filename
";
$numrows = mysql_num_rows($uvresult) or die (mysql_error());
//ECHO "Number of rows is - $numrows
";
if(mysql_num_rows($uvresult) >0){
$row = mysql_fetch_array($uvresult);
//ECHO "\$row on line 99 is - $row
";
};
//$row = mysql_fetch_array($uvresult);
//ECHO "\$row on line 104 is - $row
";
EXTRACT($row);
//ECHO "\$row on line 108 is - $row
";
//ECHO "The path and file name, line 120 is
$row('uv_filename')
";
$uv_filename = $row['uv_filename'];
//ECHO "the uv photo name is - $row[0]
";
$uvpath = "./uv/$uv_filename";
ECHO "
";
Echo "
END OF PICTURE AREA
";
//ECHO "
";
Echo "
?>
[/code]
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php