Re: Retrieving Image Location in PHP from MySQL

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



haliphax wrote:
On Mon, Mar 9, 2009 at 10:52 AM, Sashikanth Gurram <sashi34u@xxxxxx> wrote:
haliphax wrote:
On Mon, Mar 9, 2009 at 10:24 AM, Sashikanth Gurram <sashi34u@xxxxxx>
wrote:

Nathan Nobbe wrote:

On Mon, Mar 9, 2009 at 7:32 AM, Sashikanth Gurram <sashi34u@xxxxxx
<mailto:sashi34u@xxxxxx>> wrote:

  Hi,

  Yes, the problem was solved, but It did not work fine when I used
  the same code in my larger file. Now it makes sense.


right, just track down where you started sending the output, and
remember
if youre going to use header() calls in your scripts, that all of them
must
come before sending any of the standard content.

  Let me just repeat what you have said just to make sure that I did
  not misread you.
  So you say that the solution to this problem is to create another
  php file with the image fetching header and just write an img tag
   <img src="myimagescript.php?id=1234" /> in my original php file
  (with the html tags).


what i explained in my first response is that youre mixing 2 different
approaches, and it was unclear what you were going for exactly.  if you
want
to have an image included in a page of html, then theres no need for the
header() call (refer to my first response for the remaining details).
 there
are however legitimate use cases for the use of header() & the
aforementioned image methods, i think between mine and some of the other
posts on this thread, its explained clearly.

  This is what I have understood.
  Regarding the point you have mentioned ( If you set the content
  type using header() to "image/jpeg", do not use HTML tags to
  display your image!),


correct

  I definitely need the HTML tags, because this application works
  based on the user input. So unless there is not input through a
  html form, it wont work.


right, then just configure your webserver such that you can first access
the image directly via an http url, then integrate these links into your
dynamic pages as i explained in my first response.

Thanks a lot for all the patient replies. All the suggestions led me in a
positive direction. Finally, instead of using the header() in my main PHP
file (with HTML tags), I have used it in a secondary file and called it
using  a tag<img src="imgtest.php">. It is working fine. But, the image I
need to display is also dynamic and needs a user input. So, is there any
way
in which I can transfer a particular variable (the user input) from my
main
php file (say A.php) to my secondary file containing the header () (say
B.php)

Yes. Use the Query String of your image-producing PHP script to pass
values. If you had an image tag like this:

<img src="imagescript.php?id=1234" />

Then you could grab the value of $_GET['id'] in your PHP script and
react accordingly.
Thanks a lot everyone, particularly Haliphax, Nathan, Virgilio and Bob.

I will try it and will come back to you.

You're very welcome. This page [1] may help you get started. It's a
bit dated, but the information still holds true today.

1. http://whn.vdhri.net/2005/10/how_to_use_the_query_string_in_php.html


Hello everyone,

Is there any way in which I can assign a variable to a query string?
Like for example, Let us say that there are two php files a.php and b.php. I am currently using a image tag like <img src="imgtest.php?id=Williams Hall" /> in a.php and am passing the value to another variable using $build=$_GET['id']; in b.php. Now for this purpose, I am using the img tag in the html part of my first file which makes it kind of static. Now if I want to assign a variable (say $building) to 'id' in my first file, and retrieve it using the variable $build in the second file what is the best way to do it? Will the command (written inside the PHP tags) echo ' <img src="imgtest.php?id=$building />'; be of any help in performing the task. I have actually tried this out, but it did not work for me (May be my syntax is wrong although I have tried various combinations). So, is there a better way or correct way of doing this (If what I have done is wrong). I have tried to use $_session() command, but it is kind of yielding me a header error.

Thanks,
Sashi

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Sashikanth Gurram
Graduate Research Assistant
Department of Civil and Environmental Engineering
Virginia Tech
Blacksburg, VA 24060, USA


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux