Jump to content

problem with variable <a>


denoteone

Recommended Posts

Can I reference a local server that has images on it with a PHP variable.

I created a database that has the paths to all the images on our image server.

 

the variable $path is equal to Ocds1/data1/

 

and my code looks like this

 

$path = $row['path'];
<a href='$path'>Click here for image</a> $path /n

 

but the URL is not pointing to the server. it is pointing to the url of the website it is on

 

 

Link to comment
https://forums.phpfreaks.com/topic/88204-problem-with-variable/
Share on other sites

the links will only be used by people in my office. so we are accessing the application online to find out were a selected image is located on our image server. the path to the server is always going to be "Ocfds1\Data1"  and on click i want the browser to go to that location on the server so the user can just click and open the image.

my full page of code is

 


<?
include "connect.php";


if (isset($_POST['submit'])) // name of submit button
{
$choice=$_POST['option'];
$query = "SELECT * from strata_links WHERE name='$choice' "; 

$result = mysql_query($query);
if (!($result))
{
echo "<br><B>ERROR</B>query did not happen result is false";
echo "<BR>query= $query";
echo "<BR>result= $result";
echo "<BR>mysql error no= ".mysql_errno().": ".mysql_error()."<BR>";
}; 


while ($row = mysql_fetch_assoc($result))
{
$path = $row['path'];
echo "<a href='$path'>Click here for image</a> $path /n";
$description = $row['description'];
echo "$description";
}

} 
else{
print "<center>";
  print "<table>";
  print "<tr><td><center>please select a File first</center></td></tr>";
  print "<tr><td><center>";   
  print "You have to Selct Image name first..... <META HTTP-EQUIV = 'Refresh' Content = '2; URL =getimage.php'></center>";
  print "</td></tr></table></center>";
  }

?>

Link to comment
https://forums.phpfreaks.com/topic/88204-problem-with-variable/#findComment-451366
Share on other sites

That makes perfect sense, but the path will still have to be a useable UNC path.

 

For example, hop on the server and connect to the folder with the images in it. Whatever path you have to use to connect from there, is the path you need to use in code.

 

I would assume something like \\Ocds1\data1\

 

assuming that the location is a valid network share.

Link to comment
https://forums.phpfreaks.com/topic/88204-problem-with-variable/#findComment-451394
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.