I am trying to display the image from the link in the database. None of my attempts work (remmed out). I can click to view the image by my hyper link but I am not able to display the image..

Can anyone help out and tell me what syntax I should be using? The link will display like this -> file:///m:/Cop100/25836/109402.cpc

<?php
$server_choice = $_GET['word']; 
$username="";
$password="";
$database="CPCImage";


if ( $server_choice == live ) {
	$serverloc="10.10.100.12";
} else {
	$serverloc="localhost";
}

mysql_connect($serverloc,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM axhostdata WHERE locker<>'0' and sex<>'D' GROUP BY Key1 ORDER BY Key2 DESC LIMIT 0,100";
$result=mysql_query($query);

$num=mysql_numrows($result);

mysql_close();

echo "<b><center>Mugshot Database Output</center></b><br>";
echo "<center>Server: $serverloc</center><br><br>";

$i=0;
while ($i < $num) {

$Key1=mysql_result($result,$i,"Key1");
$name=mysql_result($result,$i,"name");
$sex=mysql_result($result,$i,"sex");
$race=mysql_result($result,$i,"race");
$age=mysql_result($result,$i,"age");
$MugDate=mysql_result($result,$i,"mugdate");
$Locker=mysql_result($result,$i,"Locker");
$BookDate=mysql_result($result,$i,"BookDate");
$Link=mysql_result($result,$i,"Link");

echo "<b>$Key1 $name $sex / $race Age: $age <br>MugDate: $MugDate BookDate: $BookDate <a href=$Link>$Link </a> Click Link to view Pic<hr><br>";
//echo "<img src="echo $Link">"; 
//echo "<img src="<$row['Link']>">";

$i++;
}

?>

    I should say the link is stored in the DB ilke this
    m:/Cop100/25836/109402.cpc

    CPC is another type of JPG file that is viewable using Internet Explorer....

      well that path is relative to your file system and wont work on the public internet

      you should store the images' path relative to the root of the website

        This is for INTRANET use only.... Public use is prohibited...

          right but say an employee on another computer is using it... they dont have access to your M:

          by public, i mean not localhost

            Im testing the code now thats why it is localhost. I will change it to the IP. Any ideas why the images dont show though?

            M: drive is shared on our network. All users have access to it.

            Any help would be appreciated.

            scrupul0us;10921508 wrote:

            right but say an employee on another computer is using it... they dont have access to your M:

            by public, i mean not localhost

              what you should ideally do then is map a virtual directory in apache or IIS on the server level to the images directory that way you can have:

              /networkImages/some/folder/image.cpc

              where /networkImages/ is mapped to the network path... in the event a user doesnt have the drive or it isnt mapped properly your intranet functions as expected (since the server would have perms)

              as for why the images don't show:

              can you paste the source of the output where an image should be loading? (the img container rendered by the browser)

                Here is the result. You can see the link at the bottom of the page when you hover the hyperlink.

                Works fine to load the image when you click the link but I would like the image displayed with the record verses having to click on the link to view.

                  Here is a sample of the source from the browser.

                  <b><center>Mugshot Database Output</center></b><br><center>Server: 10.10.100.12</center><br><br><b>
                  000258300 SMITH, JOHN NMN M / W Age: 25 <br>MugDate: 00/00/0000 BookDate: 07/15/09 <a href=m:\Cop100\25854\112473.cpc>m:\Cop100\25854\112473.cpc </a> Click Link to view Pic<hr><br><b>
                  000218380 DOE, JOHN ANTONIO M / B Age: 24 <br>MugDate: 00/00/0000 BookDate: 07/15/09 <a href=m:\Cop100\25854\112472.cpc>m:\Cop100\25854\112472.cpc </a> Click Link to view Pic<hr><br><b>
                  scrupul0us;10921512 wrote:

                  what you should ideally do then is map a virtual directory in apache or IIS on the server level to the images directory that way you can have:

                  /networkImages/some/folder/image.cpc

                  where /networkImages/ is mapped to the network path... in the event a user doesnt have the drive or it isnt mapped properly your intranet functions as expected (since the server would have perms)

                  as for why the images don't show:

                  can you paste the source of the output where an image should be loading? (the img container rendered by the browser)

                    notice in the status bar when you hover over the links, the browser adds file:/// to the M: path, you need to set this manually when you build the SRC attribute of the img tag

                      So should I try this??

                      echo "<img src="echo file///$Link">";

                        Whoops, missed the colon
                        echo "<img src="echo file:///$Link">";

                          This is the error I get when using that method...

                          Parse error: syntax error, unexpected T_ECHO, expecting ',' or ';' in C:\xampp\htdocs\PHPTEST\SearchMugshots.php on line 48

                            quoting/multiple echo issue:

                            echo '<img src="file:///$Link" alt="" title="" />';
                            

                              A wee bit closer. I now see a box with a red X in it. When I clicked the properties of the box the it shows file:///$Link as the property.

                                I tried that and now I see a box where the image should be. I clicked on the image to view the properties and the url shows file:///$Link for every picture.

                                  try:

                                  echo '<img src="file:///'.$Link.'" alt="" title="" />';
                                  

                                    YOUR RIGHT ON TARGET with this reply.... Thank you for sticking with me till I was able to resolve my question.

                                    I appreciate your help. THANKS!!! 🙂

                                    scrupul0us;10921528 wrote:

                                    try:

                                    echo '<img src="file:///'.$Link.'" alt="" title="" />';
                                    

                                      no problem! glad to have helped!

                                      you should test a few browsers to make sure they all interpret the file:/// handler properly

                                      you should also really consider doing the virtual dir mapping to ensure that all users, regardless of permissions or drive mapping, will always have access to the images 🙂

                                      cheers

                                        Write a Reply...