I have followed several posts and made progress, but I still am unable to display a jpeg image using the html img src tags which is located in my webroot folder under www/SnapShots.
I would like to use PHP to search a local mysql db and return the newest image filepath. I would then like to use that filepath to display the image.
I have tried using both a separate getImage.php and showimage.html as well as as a single file containing both php and html which I will share below. Currently I am able to echo the correct filepath, which when copied and pasted manually into an img src works, however it does not work by referencing the variable or .php url.
webcam.php:
<?php
echo '<!DOCTYPE html>';
echo '<html>';
echo '<body>';
echo '<h1>Display Recent WebCam Image</h1><br />';
//$id = $_GET['id'];
//Connect to mysql DB
$link = mysql_connect("localhost", "root", "password");
mysql_select_db("temperature_database");
//Select thew newest image filepath
$sql = "SELECT imgFilePath FROM tempLog WHERE datetime=(SELECT MAX(tempLog.datetime) FROM tempLog);";
$result = mysql_query("$sql");
$row = mysql_fetch_assoc($result);
mysql_close($link);
//header("Content-type: image/jpeg");
header("Content-type: text/plain");
$imgpath = $row['imgFilePath'];
//echo $imgpath;
echo '<img src="{$imgpath}", alt="Most recent WebCam Shot", width="800", height="600"><br />';
?>
</body>
</html>
I have tried numerous ways of inserting the $imgpath variable and or referencing it from a separate html page ie: .
A point in the right direction would be much appreciated.
As of now webcam.php outputs the following, so there also appears to be an issue with interpreting the html tags.
<!DOCTYPE html><html><body><h1>Display Recent WebCam Image</h1><br /><img src="{$imgpath}", alt="Most recent WebCam Shot", width="800", height="600"><br /></body>