Jump to content

Recommended Posts

Hi, I'm trying to edit some rather complicated code, but essentually I am attempting to load an image into a PHP page, based on a SQL query. My site is working with Oracle and is working fine. I wish to add one function where I load an image into a php page based on the name of a file stored in a relational database, the image is located on a local hard drive. The query part is working fine as the top portion is getting the name and placing it into the table. I am attempting to insert the database result into the field where the image would normally just be entered. When I attempt to pass the variable into the string for the the image portion it will not work. Any ideas, any help would be grateful. Thanks. Clealry I am missing something basic here. The path is displayed in the table but will not get drawn in to the image section.

 

Sample of the code:

 

<!-- This page gets the information to display for a shelf and shows a picture of it. -->

<HTML>

<?php

import_request_variables("gpc");

$bay = $_POST['bay'];

 

 

//query to get picture path information

$qry = "select * from shelf_rec shelf, database.model part, database.nodes node

where node.object_id = '$shelf'

and node.part_id = part.part_id

and shelf.object_id = node.object_id";

$stmt = OCIParse($conn, $qry);

OCIExecute($stmt);

while ($row = oci_fetch_array ($stmt))

{

$s_photo_path = $row['PHOTO_PATH'];

}

 

   

//display shelf information

// GET A TABLE IN HERE............

 

    echo"<TR>";

    echo "<TD><FONT COLOR='PURPLE'><B>Photo Path:</B></FONT></TD>";

    echo "<TD><FONT COLOR='red'><I>&nbsp &nbsp &nbsp &nbsp &nbsp $s_photo_path</FONT></TD>";

    echo"</TR>";

    echo"</table>";

    echo"<br clear='left'>";

 

?>

 

 

<CENTER><H2>

<img border="0" src="$s_photo_path" width="284" height="144">

</CENTER></H2>

<center>

<FONT SIZE="3">$s_photo_path</FONT>

<br>

<br>

</center>

</BODY>

 

 

</HTML>

 

 

Link to comment
https://forums.phpfreaks.com/topic/242161-php-variables-and-image-load/
Share on other sites

You need to wrap in php tags and also echo the variable

 

as one example

 

from this:

<img border="0" src="$s_photo_path" width="284" height="144">

 

to this:

<img border="0" src="<?php echo $s_photo_path;?>" width="284" height="144">

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.