473,625 Members | 3,222 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help - PHP Variables Used in HTML <IMG Tag

I'm trying to dynamically load a .jpg image into a html form <Img tag
using a PHP variable that holds the filename of the image but no image
is displaying (the file is there and works because if I manually type
in the filename the <Img tag works) - how can I get PHP's variable to
be seen as the filename?

Thanks...

<?php
print '<IMG SRC="$php_photo 2_file" WIDTH="268" HEIGHT="176" BORDER="0"
ALT="">';
?>

Jul 16 '05 #1
3 79131
On Sat, 02 Aug 2003 15:15:05 GMT, Ralph Freshour <ra***@primemai l.com>
scrawled:
I'm trying to dynamically load a .jpg image into a html form <Img tag
using a PHP variable that holds the filename of the image but no image
is displaying (the file is there and works because if I manually type
in the filename the <Img tag works) - how can I get PHP's variable to
be seen as the filename?

Thanks...

<?php
print '<IMG SRC="$php_photo 2_file" WIDTH="268" HEIGHT="176" BORDER="0"
ALT="">';
?>


RTFM,

You are using "single quotes" which don't get expanded, only "double
quotes" have their content interpolated.

Why not...

<IMG SRC="<?php echo $php_photo2_fil e ?>" WIDTH="268"
HEIGHT="176" BORDER="0" ALT="" />

much simpler and easier to understand..., if not you can could do...

<?php
echo '<IMG SRC="',$php_pho to2_file,
'" WIDTH="268" HEIGHT="176" BORDER="0" ALT="" />;
?>

or

<?php
echo "<IMG SRC=\"$php_phot o2_file\" WIDTH=\"268\" HEIGHT=\"176\"
BORDER=\"0\" ALT=\"\" \/>";
?>

Jul 16 '05 #2
RichardGUSA
2 New Member
I am having a very similar problem to this post and have tried the suggestions given but still cannot do what I need to do. I have a PHP script that dynamically generates an image file (using JPGRAPH) and this works fine. I load this php file and pass data to it to create the image which is a graph using the following:

Print '<img src="barchart.p hp?h1=110&h2=12 0&h3=130">';

This correctly passes the three values to barchart.php and generates a graph image based on the three values. The problem is I want to pass different values to this php file every time I use the image so that it generates a different graph based on the values passed. The values are stored in php variables ($height1, $height2 and $height3) and I have been trying many different combinations of the following non of which work:

Print '<img src="barchart.p hp?h1=$height1& h2=$height2&h3= height3">';

Does anyone know how I can correctly pass values stored in PHP variables to a HTML tag that I also happenning to be gererating within a PHP script. If someone can sugest a better way to pass variable values to barchart.php please let me know.
Apr 30 '06 #3
RichardGUSA
2 New Member
I have found a correct syntax for this to work on php.net I think. See below:

Print '<img src="barchart_a .php?h1=' . $height1 . '&h2=' . $height2 . '&h3=' . $height3 . '">';

I am having a very similar problem to this post and have tried the suggestions given but still cannot do what I need to do. I have a PHP script that dynamically generates an image file (using JPGRAPH) and this works fine. I load this php file and pass data to it to create the image which is a graph using the following:

Print '<img src="barchart.p hp?h1=110&h2=12 0&h3=130">';

This correctly passes the three values to barchart.php and generates a graph image based on the three values. The problem is I want to pass different values to this php file every time I use the image so that it generates a different graph based on the values passed. The values are stored in php variables ($height1, $height2 and $height3) and I have been trying many different combinations of the following non of which work:

Print '<img src="barchart.p hp?h1=$height1& h2=$height2&h3= height3">';

Does anyone know how I can correctly pass values stored in PHP variables to a HTML tag that I also happenning to be gererating within a PHP script. If someone can sugest a better way to pass variable values to barchart.php please let me know.
May 3 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
13067
by: Gregory | last post by:
Hello, I'm trying to do the above in order to process an image and return the result to an html image control. It fails and my key suspects are either the variable that I'm passing in - ImageName - for processing, or the return data which is done (or not as the case may be) by imagejpeg($img) in the script, after header("Content-type: image/jpeg"). Any insights would be most welcome, especially debugging techniques and a pointer to...
5
2592
by: Sorby | last post by:
Hi I've been coding in PHP for a little while now and was starting to feel pretty confident but then realise I need to understand regular expressions to solve a particular problem I've got ... What a horrible can of worms regex is!! (to the uninitiated at least). I realise that if I spend the next few weeks researching regex I'll probably find the answer but I was wondering if anyone here would kindly help speed up the process?
8
3001
by: Eric Bragas | last post by:
What is this? <img src="{$ ImagesDir}/photo.gif"> I KNOW what an HTML image tag looks like. But what do you call that in the file source? Is it like a virtual directory in IIS? It's some type of variable obviously, but can somebody tell me what it's called so I can research how it works? thanks.
15
3090
by: Philipp Lenssen | last post by:
My friend has the following problem (background: we want to transform XML to XHTML via XSLT): "We copy XHTML fragments into an output by using the following template: <xsl:template match="*" mode="xhtml"> <xsl:element name="{local-name()}"> <xsl:copy-of select="@*"/> <xsl:apply-templates mode="xhtml"/> </xsl:element>
15
122119
by: Gérard Talbot | last post by:
Hello all, I'd like to know and understand the difference between, say, <img src="/ImageFilename.png" width="123" height="456" alt=""> and <img src="/ImageFilename.png" style="width: 123px; height: 456px;" alt="">
3
5439
by: Henry Johnson | last post by:
Okay - I'm spinning my wheels on this one... can someone help me figure out how to programmatically populate a table cell as follows (from C# code-behind)? I've tried using a Literal control in the TableCell, a HyperLink control, and an Image, but I'm not getting the results I want. Here's the source of what I'm after (retrieved by viewing the source of a page I'm trying to emulate): <td><a...
7
9858
by: Christian Hackl | last post by:
Hi everyone, I've got a question about what makes the "img" element's width/height attributes valid HTML or XHTML. First of all, this is a rather theoretical question, but digging through the W3C HTML 4.01 standard and this group's archive didn't give me a satisfactory answer, so here we go: Is <img src="img.png" alt="" width="100px" height="100px"really valid?
0
8256
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8189
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8356
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6118
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5570
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4089
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2621
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1803
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1500
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.