I found out some years ago that some woods will actually fluoresce under UV light and that I can photograph that glow. In fact, I estimate over 10$ of the 3,000+ actual wood species samples I have glow under black light.

I have worked on for some time the TAXA Wood Knowledge Base () that reports the existence and information on over 15,000 different wood species. When you pick a certain wood, you are taken to the data page for that wood. On that page (amongst other things) are three pop-up windows. One of them is to display any UV photos I have so far of woods that do glow.

The odd thing about how it is working is that some photos (all JPEG's) show but some do not and I don't know why. All pages with data are dynamically run with PHP and stored in MySQL tables. As a check against corrupt photo files, I have run the ones that do not show in phpAdmin under 'Execute'---- and they showed up fine. If they all didn't show, of course, it would be easy to see that there was a code problem but via the same code, over 2/3 show. Oddly, some critical error is not happening since with the photos that do not show, the page even seems to crash after the first words echos from code.

I will include the full page code. All photos for now are stored under ./uv/uva.
File names and paths are kept in the Taxa database, 'uvphotos' table, 'uvfilename' column.

This one has me stumped. I hope someone has some idea what is causing this.

Bill Mudry
Mississauga,Ontario (near Toronto)

=============================================================================

<?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

error_reporting(-1); // Report every single error going.
ini_set('display_errors', 1); // Show them in-line.
set_time_limit(0); // No time limit.
// The rest of your code is on the next line and onwards.


?>

<!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>

Dani AI

Generated

This looks like a classic “most files work, a few fail” symptom — the PHP/SQL flow is mostly fine, so the root cause is almost always at the filesystem/URL level (filename encoding, path, permissions) or at the HTTP layer (server error, blocking, wrong headers). Agree with that path/HTML attributes matter; below are focused, non-redundant diagnostics and fixes that find the usual culprits quickly.

Start by inspecting the HTTP transaction for a failing image. Capture the status code and response headers (Network tab in DevTools, or a CLI request). For example:

curl -I 'https://example.com/uv/NAME.jpg'

Look for 200 vs 404/403/500, Content-Type, and Content-Length. If the request returns an error, check the webserver error log timestamped to that request.

Check what the database actually stores for the problematic filenames. Hidden bytes (trailing CR/LF, non-breaking spaces, NULs) or case differences will make a valid file path fail on a case-sensitive server. Run a query that shows length and raw hex for suspect rows, e.g.:

SELECT uv_filename, LENGTH(uv_filename), HEX(uv_filename)
FROM uvphotos WHERE species_name = '…';

If HEX shows 0D/0A/00 or unexpected bytes, normalize the column (trim and remove control bytes) or update filenames to a canonical ASCII form.

On the server filesystem verify: file type, ownership and permissions, and exact filename spelling. Example shell checks:

ls -l uv/
file uv/problematic.jpg
stat uv/problematic.jpg

Also try opening the image locally with an image viewer or the file utility to confirm it’s a valid JPEG (not misnamed PNG, GIF, or truncated file).

Other useful checks: ensure URLs are URL-encoded when they contain spaces/special characters; prefer absolute paths ("/uv/…") from pop-ups to avoid relative-path surprises; and check for aggressive server modules (mod_security, .htaccess rules) that might block requests with certain filename patterns. Typical fixes that resolve these failures are: trim/normalize the DB filename, rename files to safe ASCII names (no spaces or punctuation), set files to 644 and parent folders to 755, and reference images with an absolute, encoded URL.

I can't say I found a solution to your problem but I went through your code and saw some things you could try changing.

First: only write echo statements in lower case, now you write it "Echo" and "ECHO".

Secondly: There are some standards you've missed which I've tried to address here:

$uvresult = mysql_query($uvquery) or die(mysql_error());
 
        //Here you've already checked if the query failed or not so I believe this is  
        //unnecessary, correct me if I'm wrong.
	/*if(!$uvresult) 	
		die(mysql_error())
		;*/
 
        // Not needed, you check the number of rows in the following if-statement
	//$numrows = mysql_num_rows($uvresult) or die (mysql_error());
 
        //I Guess what you want is a single row returned, right?
	if(mysql_num_rows($uvresult) == 1){
                //mysql_fetch_assoc()
		$row = mysql_fetch_assoc($uvresult);
	};
       
        //I believe that to go to the previous directory you need two ".."
	$uvpath = "../uv/".$row['uv_filename'];

        //And if it still doesn't work, try using an absolute path

        // "alt" is a required attribute and without "width" and "height" some legacy 
        //browsers are having trouble displaying the image correctly
	echo "<img src='$uvpath' width='' height='' alt=''>";
 
  // Use <p> when you can instead of breaks since otherwise it's considered bad html :/
  echo "<p>END OF PICTURE AREA<p>";

 
echo "</div>";

Also try to write all HTML-tags in lowercase, e.g. "<h2>" and the "align" attribute on <div> is deprecated and css-rules should be used instead, e.g. style="width: 720px; margin: 0 auto;"

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.