Re: [PHP] Retrieving Image Location in PHP from MySQL

2009-03-10 Thread Sashikanth Gurram

haliphax wrote:

On Mon, Mar 9, 2009 at 8:43 PM, Sashikanth Gurram  wrote:
  

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  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 ' 

I'm not sure if this has been addressed in any of the other replies,
but I felt it was worth mentioning: Be careful and pay attention to
whether you are using single quotes ( ' ) or double quotes ( " ) in
your echo statements!

$var = 'asdf';
echo 'hey, $var'; // "hey, $var"
echo "hey, $var"; // "hey, asdf"

...and if you're using single or double quotes elsewhere (i.e.,
assignment operations)...

$var = 'asdf';
$othervar = 'blah$var'; // "blah$var"
$anothervar = "blah$var"; // "blahasdf"
$yetanothervar = "blah{$var}blah"; // "blahasdfblah"

Double quotes, when not using "echo", can still parse variables for you.


  

Thanks, Haliphax. I knew this stuff from janet valede's PHP for dummies.
-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



Re: [PHP] Retrieving Image Location in PHP from MySQL

2009-03-10 Thread haliphax
On Mon, Mar 9, 2009 at 8:43 PM, Sashikanth Gurram  wrote:
>>> 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 >> 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 ' >> 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.

I'm not sure if this has been addressed in any of the other replies,
but I felt it was worth mentioning: Be careful and pay attention to
whether you are using single quotes ( ' ) or double quotes ( " ) in
your echo statements!

$var = 'asdf';
echo 'hey, $var'; // "hey, $var"
echo "hey, $var"; // "hey, asdf"

...and if you're using single or double quotes elsewhere (i.e.,
assignment operations)...

$var = 'asdf';
$othervar = 'blah$var'; // "blah$var"
$anothervar = "blah$var"; // "blahasdf"
$yetanothervar = "blah{$var}blah"; // "blahasdfblah"

Double quotes, when not using "echo", can still parse variables for you.


-- 
// Todd

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



Re: [PHP] Retrieving Image Location in PHP from MySQL

2009-03-09 Thread Sashikanth Gurram

Thanks Shawn and Dollah

-Sashi
Shawn McKenzie wrote:

Sashikanth Gurram wrote:
  

haliphax wrote:


On Mon, Mar 9, 2009 at 10:52 AM, Sashikanth Gurram 
wrote:
 
  

haliphax wrote:
   


On Mon, Mar 9, 2009 at 10:24 AM, Sashikanth Gurram 
wrote:

 
  

Nathan Nobbe wrote:

   


On Mon, Mar 9, 2009 at 7:32 AM, Sashikanth Gurram mailto:sashi...@vt.edu>> 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
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. 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:



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  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 ' 


Either:

1. a.php



--or--

2. a.php

echo '';

Then, whicher you choose above: b.php:

$build = $_GET['id'];

  



--
~
~
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



Re: [PHP] Retrieving Image Location in PHP from MySQL

2009-03-09 Thread Sashikanth Gurram

Hi,

Worked perfectly. Thank you very much.

-Sashi

Dollah Ihsan wrote:

Hi,

you are using single quotes like this?
echo ' ';

single quotes will ignore that "$building" variable.

Just concatenate it:
echo '";


It should work I think, sorry if it does not.

On Tue, Mar 10, 2009 at 8:14 AM, Sashikanth Gurram  wrote:

  

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  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 ' http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





  



--
~
~
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



Re: [PHP] Retrieving Image Location in PHP from MySQL

2009-03-09 Thread Shawn McKenzie
Sashikanth Gurram wrote:
> haliphax wrote:
>> On Mon, Mar 9, 2009 at 10:52 AM, Sashikanth Gurram 
>> wrote:
>>  
>>> haliphax wrote:
>>>
 On Mon, Mar 9, 2009 at 10:24 AM, Sashikanth Gurram 
 wrote:

  
> Nathan Nobbe wrote:
>
>
>> On Mon, Mar 9, 2009 at 7:32 AM, Sashikanth Gurram > > 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
>> 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. 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:

 

 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  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 '  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
> 


Either:

1. a.php



--or--

2. a.php

echo '';

Then, whicher you choose above: b.php:

$build = $_GET['id'];

-- 
Thanks!
-Shawn
http://www.spidean.com

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



Re: [PHP] Retrieving Image Location in PHP from MySQL

2009-03-09 Thread Sashikanth Gurram

haliphax wrote:

On Mon, Mar 9, 2009 at 10:52 AM, Sashikanth Gurram  wrote:
  

haliphax wrote:


On Mon, Mar 9, 2009 at 10:24 AM, Sashikanth Gurram 
wrote:

  

Nathan Nobbe wrote:



On Mon, Mar 9, 2009 at 7:32 AM, Sashikanth Gurram mailto:sashi...@vt.edu>> 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
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. 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:



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 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 ' 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



Re: [PHP] Retrieving Image Location in PHP from MySQL

2009-03-09 Thread haliphax
On Mon, Mar 9, 2009 at 10:52 AM, Sashikanth Gurram  wrote:
> haliphax wrote:
>>
>> On Mon, Mar 9, 2009 at 10:24 AM, Sashikanth Gurram 
>> wrote:
>>
>>>
>>> Nathan Nobbe wrote:
>>>

 On Mon, Mar 9, 2009 at 7:32 AM, Sashikanth Gurram >>> > 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
     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. 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:
>>
>> 
>>
>> 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


-- 
// Todd

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



Re: [PHP] Retrieving Image Location in PHP from MySQL

2009-03-09 Thread Sashikanth Gurram

Thanks a lot everyone, particularly Haliphax, Nathan, Virgilio and Bob.

I will try it and will come back to you.

Thanks,
Sashi

haliphax wrote:

On Mon, Mar 9, 2009 at 10:24 AM, Sashikanth Gurram  wrote:
  

Nathan Nobbe wrote:


On Mon, Mar 9, 2009 at 7:32 AM, Sashikanth Gurram mailto:sashi...@vt.edu>> 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
 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. 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:



Then you could grab the value of $_GET['id'] in your PHP script and
react accordingly.

HTH,


  



--
~
~
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



Re: [PHP] Retrieving Image Location in PHP from MySQL

2009-03-09 Thread haliphax
On Mon, Mar 9, 2009 at 10:24 AM, Sashikanth Gurram  wrote:
> Nathan Nobbe wrote:
>>
>>
>> On Mon, Mar 9, 2009 at 7:32 AM, Sashikanth Gurram > > 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
>>      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. 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:



Then you could grab the value of $_GET['id'] in your PHP script and
react accordingly.

HTH,


-- 
// Todd

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



RE: [PHP] Retrieving Image Location in PHP from MySQL

2009-03-09 Thread Bob McConnell
From: Sashikanth Gurram
> 
> Hi,
> 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. 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)

Well, you are really trying to use one page to do two different tasks.
First to display the input form, then to show an image selected by that
input. So, either you need two code paths, or two pages. You can start
off by checking the input fields and if they are empty, simply display
the form. Then the next time through, when the fields are populated,
insert the selected image.

Bob McConnell

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



Re: [PHP] Retrieving Image Location in PHP from MySQL

2009-03-09 Thread Sashikanth Gurram

Hi,
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. 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)


Thanks,
Sashi

Nathan Nobbe wrote:



On Mon, Mar 9, 2009 at 7:32 AM, Sashikanth Gurram > 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
  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.


good luck,

-nathan




--
~
~
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



Re: [PHP] Retrieving Image Location in PHP from MySQL

2009-03-09 Thread Nathan Nobbe
On Mon, Mar 9, 2009 at 7:32 AM, Sashikanth Gurram  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   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.

good luck,

-nathan


Re: [PHP] Retrieving Image Location in PHP from MySQL

2009-03-09 Thread haliphax
On Mon, Mar 9, 2009 at 9:32 AM, Sashikanth Gurram  wrote:
>> On Mon, Mar 9, 2009 at 1:29 AM, Sashikanth Gurram  wrote:
>>
>>>
>>> Hi Nathan,
>>>
>>> Thanks a lot for the suggestion. It is working fine for an example code I
>>> have used to test it. The code I have written after your suggestion is as
>>> follows.
>>> >> $location="C:\wamp\bin\apache\apache2.2.8\htdocs\Bldgs_lots\SQUIRES.jpg";
>>> header('Content-Type: image/jpeg');
>>> imagejpeg(imagecreatefromjpeg($location));
>>> ?>
>>> The above code is yielding me a picture. Now, When I tried to use it in
>>> my
>>> original code it is not giving me the image. Instead it is giving me this
>>> warning *Warning*: Cannot modify header information - headers already
>>> sent
>>> by (output started at C:\wamp\www\mysqli.php:65) in
>>> *C:\wamp\www\mysqli.php*
>>> on line *221*
>>> and a lot binary characters again instead of the image. I know something
>>> about this warning that we should not output anything to the browser
>>> before
>>> the header. But I cannot do that, since I need the user input using a
>>> html
>>> form and I use the input to fetch the data and dispaly it in a table
>>> along
>>> with the image. I am posting the whole code below. Please do let me know
>>> about any changes, corrections or modifications that are needed. The
>>> image
>>> display code is towards the last.
>>>
>>> 
>>> 
>>> 
>>> 
>>> 
>>> Building Name:
>>>  Select a Building
>>>    Williams Hall
>>>    Women's Softball Field
>>>    Wright House
>>> 
>>> 
>>>                  
>>> 
>>> >> // Connects to your Database
>>> $host="*";
>>> $user="*";
>>> $password="*";
>>> $dbname="*";
>>> $cxn=mysqli_connect($host, $user, $password, $dbname) ;
>>> if (!$cxn=mysqli_connect($host, $user, $password, $dbname))
>>>  {
>>>      $error=mysqli_error($cxn);
>>>      echo "$error";
>>>      die();
>>>  }
>>> else
>>>  {
>>>      echo "Connection established successfully";
>>>  }
>>> //Define the variables for Day and Month
>>> $Today=date("l");
>>> $Month=date("F");
>>> $build=$_POST["name"];
>>> $low_speed=2.5;
>>> $high_speed=4;
>>> $hour=date("G");
>>> $minute=date("i");
>>> if ($minute>=00 && $minute<=14)
>>>  {
>>>      $minute=00;
>>>  }
>>> elseif ($minute>=15 && $minute<=29)
>>>  {
>>>      $minute=15;
>>>  }
>>> elseif ($minute>=30 && $minute<=44)
>>>  {
>>>      $minute=30;
>>>  }
>>> else
>>>  {
>>>      $minute=45;
>>>  }
>>> $times="10:$minute";
>>> $sql="SELECT buildingname, parking_lot_name, empty_spaces, distance,
>>> round(distance/($low_speed*60),1) AS low_time,
>>> round(distance/($high_speed*60),1) AS high_time, Location FROM buildings,
>>> buildings_lots, parkinglots, occupancy2, Image where
>>> (buildings.buildingcode=occupancy2.building AND
>>>  buildings.buildingcode=buildings_lots.building_code AND
>>> parkinglots.parking_lot_code=buildings_lots.parking_lot_code AND
>>> parkinglots.parking_lot_code=occupancy2.parking_lot AND
>>> Buildings.BuildingCode=Image.BuildingCode) AND buildingname='$build' AND
>>> month='$Month' AND day='Monday' AND Time='$times'";
>>> $data = mysqli_query($cxn,$sql);
>>> if (!$data=mysqli_query($cxn,$sql))
>>>  {
>>>      $error=mysqli_error($cxn);
>>>      echo "$error";
>>>      die();
>>>  }
>>> else
>>>  {
>>>      echo "";
>>>      echo "Query sent successfully";
>>>  }
>>> echo "";
>>> echo " PARKING LOT INFORMATION ";
>>> echo "";
>>> echo "\n
>>>      Building\n
>>>      Parking Lot\n
>>>      Estimated Number of Empty Spaces\n
>>>      Distance (Feet)\n
>>>      Estimated walking time to the building\n
>>>  \n";
>>> while ($row=mysqli_fetch_array($data))
>>>  {
>>>      extract($row);
>>> $building = $row[0];
>>>    $parking_lot = $row[1];
>>>    $Number_of_Empty_Spaces = $row[2];
>>>    $Distance = $row[3];
>>>    $time_l = $row[4];
>>>    $time_h=$row[5];
>>>    $location=$row[6];   echo "\n
>>>            $building\n
>>>            $parking_lot\n
>>> $Number_of_Empty_Spaces\n
>>>            $Distance\n
>>>            $time_h - $time_l mins\n
>>> $location\n
>>>            \n";
>>>  }
>>>  echo "\n";
>>> header('Content-Type: image/jpeg');
>>> imagejpeg(imagecreatefromjpeg("$location"));
>>> ?>
>>> 
>>> 
>>> Nathan Nobbe wrote:
>>>

 On Sat, Mar 7, 2009 at 9:36 PM, Sashikanth Gurram 
 wrote:

> The thing is, I do not have a website or a place where I am storing my
> images. I am storing the images on my local PC in folder as mentioned
> in
> my
> earlier post. I have tried using only the
>
> else {
> header('Content-Type: image/jpeg');
> imagejpeg($img);
> imagedestroy($img);
> }
>
> Which you have suggested. This is the piece of code which is returning
> all
> the binary character stuff. The code is definitely fetching the image.
> But
> it is not able to deliver to the browser in the form of an image. I am
> trying to read the image file as binary, evident from the FILE_BINARY
> command. So may be, that

Re: [PHP] Retrieving Image Location in PHP from MySQL

2009-03-09 Thread Virgilio Quilario
> I am using a WAMP server for my coding purposes. My MySQL Version is
> 5.0.51b, PHP version is 5.2.6 and Apache version is 2.2.8
>
> I have created a database with one of the tables containing a location of
> the image. Using PHP I am trying to retrieve the location of the image (from
> the mysql db) and display it in a browser. I have, with help from php-db
> mailing list user's help, created a code to do the same. Now, the problem
> is, the code is extracting the location details of the image exactly and it
> is even getting the image details. But it is simply not dispalying the
> image. Instead of displaying the image, it is printing a hell lot of binary
> characters (For example: 2!
> !22ÿÀ   ^    "      ÿÄ
>            ÿĵ             }       !1A  Qa "q 2 ‘¡ #B±Á RÑð$3br‚
>  %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyzƒ„…†‡ˆ‰Š’“”•–—˜™š¢£¤¥¦§¨©ª²³´µ¶·¸¹ºÂÃÄÅÆÇÈÉÊÒÓÔÕÖ×ØÙÚáâãäåæçèéêñòóôõö÷øùúÿÄ
>                     ÿĵ              w      !1  AQ aq "2   B‘¡±Á #3Rð brÑ
> $4á%ñ    &'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz‚ƒ„…†‡ˆ‰Š’“”•–—˜™š¢£¤)
>
> I have tried in two forums and mailing lists but none of them have
> completely answered my question. How do I get rid of these signs and display
> the original image in its place? And to display the image successfully, is
> it really necessary to create the image retrieval and displaying code in a
> seperate PHP file? Any PHP gurus, enthusiasts, newbies out there, Please
> help me out.
>
> I am posting the code below so that you can directly see what I have done
> till now. The name of the php file is mysqli.php. The location of the image
> is stored to the variable $location. The image retrieval code is present
> towards end of the file.
>
> Thanks,
> Sashi
>
> 
> 
> 
> 
> 
> Building Name:
>  Select a Building
> Williams Hall
> Women's Softball Field
> Wright House
> 
> 
> 
> 
>  // Connects to your Database
> $host="***";
> $user="***";
> $password="***";
> $dbname="***";
> $cxn=mysqli_connect($host, $user, $password, $dbname) ;
> if (!$cxn=mysqli_connect($host, $user, $password, $dbname))
> {
> $error=mysqli_error($cxn);
> echo "$error";
> die();
> }
> else
> {
> echo "Connection established successfully";
> }
> //Define the variables for Day and Month
> $Today=date("l");
> $Month=date("F");
> $build=$_POST["name"];
> $low_speed=2.5;
> $high_speed=4;
> $hour=date("G");
> $minute=date("i");
> if ($minute>=00 && $minute<=14)
> {
> $minute=00;
> }
> elseif ($minute>=15 && $minute<=29)
> {
> $minute=15;
> }
> elseif ($minute>=30 && $minute<=44)
> {
> $minute=30;
> }
> else
> {
> $minute=45;
> }
> $times="$hour:$minute";
> $sql="SELECT buildingname, parking_lot_name, empty_spaces, distance,
> round(distance/($low_speed*60),1) AS low_time,
> round(distance/($high_speed*60),1) AS high_time, Location FROM buildings,
> buildings_lots, parkinglots, occupancy2, Image where
> (buildings.buildingcode=occupancy2.building AND
> buildings.buildingcode=buildings_lots.building_code AND
> parkinglots.parking_lot_code=buildings_lots.parking_lot_code AND
> parkinglots.parking_lot_code=occupancy2.parking_lot AND
> Buildings.BuildingCode=Image.BuildingCode) AND buildingname='$build' AND
> month='$Month' AND day='$Today' AND Time='$times'";
> $data = mysqli_query($cxn,$sql);
> if (!$data=mysqli_query($cxn,$sql))
> {
> $error=mysqli_error($cxn);
> echo "$error";
> die();
> }
> else
> {
> echo "";
> echo "Query sent successfully";
> }
> echo "";
> echo " PARKING LOT INFORMATION ";
> echo "";
> echo "\n
> Building\n
> Parking Lot\n
> Estimated Number of Empty Spaces\n
> Distance (Feet)\n
> Estimated walking time to the building\n
> \n";
> while ($row=mysqli_fetch_array($data))
> {
> extract($row);
> $building = $row[0];
> $parking_lot = $row[1];
> $Number_of_Empty_Spaces = $row[2];
> $Distance = $row[3];
> $time_l = $row[4];
> $time_h=$row[5];
> $location=$row[6];
> echo "\n
> $building\n
> $parking_lot\n
> $Number_of_Empty_Spaces\n
> $Distance\n
> $time_h - $time_l mins\n
> $location\n
> \n";
> }
> echo "\n";
> $err=1;
> if ($img = file_get_contents("$location", FILE_BINARY))
> {
> if ($img = imagecreatefromstring($img)) $err = 0;
> }
> if ($err)
> {
> header('Content-Type: text/html');
> echo 'Error getting
> image...';
> }
> else
> {
> header('Content-Type: image/jpeg');
> imagejpeg($img);
> echo ' width="200" alt="' . $build . '">';
> imagedestroy($img);
> }
> ?>
> 
> 
>

Hi Sashikanth,

here is how to do it.
change
$location\n
into
\n

then // to comment the useless php code.

see the changes below:


while ($row=mysqli_fetch_array($data))
{
extract($row);
$building = $row[0];
$parking_lot = $row[1];
$Number_of_Empty_Spaces = $row[2];
$Distance = $row[3];
$time_l = $row[4];
$time_h=$row[5];
$location=$row[6];
echo "\n
$building\n
$parking_lot\n
$Number_of_Empty_Spaces\n
$Distance\n
$time_h - $time_l mins\n
\n
\n";
}
echo "\n";
// $err=1;
//if ($img = file_get_contents("$location", FILE_BINARY))
//{
//if ($img 

Re: [PHP] Retrieving Image Location in PHP from MySQL

2009-03-09 Thread Sashikanth Gurram

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. 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  src="myimagescript.php?id=1234" /> in my original php file (with the 
html tags). 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!), 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.


Thanks,
Sashi

On Mon, Mar 9, 2009 at 1:29 AM, Sashikanth Gurram  wrote:
  

Hi Nathan,

Thanks a lot for the suggestion. It is working fine for an example code I
have used to test it. The code I have written after your suggestion is as
follows.

The above code is yielding me a picture. Now, When I tried to use it in my
original code it is not giving me the image. Instead it is giving me this
warning *Warning*: Cannot modify header information - headers already sent
by (output started at C:\wamp\www\mysqli.php:65) in *C:\wamp\www\mysqli.php*
on line *221*
and a lot binary characters again instead of the image. I know something
about this warning that we should not output anything to the browser before
the header. But I cannot do that, since I need the user input using a html
form and I use the input to fetch the data and dispaly it in a table along
with the image. I am posting the whole code below. Please do let me know
about any changes, corrections or modifications that are needed. The image
display code is towards the last.

Thanks,
Sashi






Building Name:
 Select a Building
Williams Hall
Women's Softball Field
Wright House


  

=00 && $minute<=14)
  {
  $minute=00;
  }
elseif ($minute>=15 && $minute<=29)
  {
  $minute=15;
  }
elseif ($minute>=30 && $minute<=44)
  {
  $minute=30;
  }
else
  {
  $minute=45;
  }
$times="10:$minute";
$sql="SELECT buildingname, parking_lot_name, empty_spaces, distance,
round(distance/($low_speed*60),1) AS low_time,
round(distance/($high_speed*60),1) AS high_time, Location FROM buildings,
buildings_lots, parkinglots, occupancy2, Image where
(buildings.buildingcode=occupancy2.building AND
 buildings.buildingcode=buildings_lots.building_code AND
parkinglots.parking_lot_code=buildings_lots.parking_lot_code AND
parkinglots.parking_lot_code=occupancy2.parking_lot AND
Buildings.BuildingCode=Image.BuildingCode) AND buildingname='$build' AND
month='$Month' AND day='Monday' AND Time='$times'";
$data = mysqli_query($cxn,$sql);
if (!$data=mysqli_query($cxn,$sql))
  {
  $error=mysqli_error($cxn);
  echo "$error";
  die();
  }
else
  {
  echo "";
  echo "Query sent successfully";
  }
echo "";
echo " PARKING LOT INFORMATION ";
echo "";
echo "\n
  Building\n
  Parking Lot\n
  Estimated Number of Empty Spaces\n
  Distance (Feet)\n
  Estimated walking time to the building\n
  \n";
while ($row=mysqli_fetch_array($data))
  {
  extract($row);
$building = $row[0];
$parking_lot = $row[1];
$Number_of_Empty_Spaces = $row[2];
$Distance = $row[3];
$time_l = $row[4];
$time_h=$row[5];
$location=$row[6];   echo "\n
$building\n
$parking_lot\n
$Number_of_Empty_Spaces\n
$Distance\n
$time_h - $time_l mins\n
$location\n
\n";
  }
  echo "\n";
header('Content-Type: image/jpeg');
imagejpeg(imagecreatefromjpeg("$location"));
?>


Nathan Nobbe wrote:


On Sat, Mar 7, 2009 at 9:36 PM, Sashikanth Gurram  wrote:


  

The thing is, I do not have a website or a place where I am storing my
images. I am storing the images on my local PC in folder as mentioned in
my
earlier post. I have tried using only the

else {
header('Content-Type: image/jpeg');
imagejpeg($img);
imagedestroy($img);
}

Which you have suggested. This is the piece of code which is returning
all
the binary character stuff. The code is definitely fetching the image.
But
it is not able to deliver to the browser in the form of an image. I am
trying to read the image file as binary, evident from the FILE_BINARY
command. So may be, that is causing the image to be displayed as binary.
Is
there any way we can convert the binary content to jpeg/jpg content
again.
This is my guess after having gone through the code again.



i spent 2 minutes working on it and read this in the manual,

the first param of imagejpeg(),

An image resource, returned by one of the image creation functions, such
as

imagecreatetruecolor()
.

so, then i tossed this together,

http://nathan.moxune.com/echoImage.php

  


I see this one has already been solved, but I felt like I nee

Re: [PHP] Retrieving Image Location in PHP from MySQL

2009-03-09 Thread Nathan Nobbe
On Sun, Mar 8, 2009 at 11:29 PM, Sashikanth Gurram  wrote:

> Hi Nathan,
>
> Thanks a lot for the suggestion. It is working fine for an example code I
> have used to test it. The code I have written after your suggestion is as
> follows.
>  $location="C:\wamp\bin\apache\apache2.2.8\htdocs\Bldgs_lots\SQUIRES.jpg";
> header('Content-Type: image/jpeg');
> imagejpeg(imagecreatefromjpeg($location));
> ?>
> The above code is yielding me a picture. Now, When I tried to use it in my
> original code it is not giving me the image. Instead it is giving me this
> warning *Warning*: Cannot modify header information - headers already sent
> by (output started at C:\wamp\www\mysqli.php:65) in *C:\wamp\www\mysqli.php*
> on line *221*


read the manual on header(),

http://us.php.net/header

youve probly echo'd some output to the browser prior to calling header().

-nathan


Re: [PHP] Retrieving Image Location in PHP from MySQL

2009-03-09 Thread haliphax
On Mon, Mar 9, 2009 at 1:29 AM, Sashikanth Gurram  wrote:
> Hi Nathan,
>
> Thanks a lot for the suggestion. It is working fine for an example code I
> have used to test it. The code I have written after your suggestion is as
> follows.
>  $location="C:\wamp\bin\apache\apache2.2.8\htdocs\Bldgs_lots\SQUIRES.jpg";
> header('Content-Type: image/jpeg');
> imagejpeg(imagecreatefromjpeg($location));
> ?>
> The above code is yielding me a picture. Now, When I tried to use it in my
> original code it is not giving me the image. Instead it is giving me this
> warning *Warning*: Cannot modify header information - headers already sent
> by (output started at C:\wamp\www\mysqli.php:65) in *C:\wamp\www\mysqli.php*
> on line *221*
> and a lot binary characters again instead of the image. I know something
> about this warning that we should not output anything to the browser before
> the header. But I cannot do that, since I need the user input using a html
> form and I use the input to fetch the data and dispaly it in a table along
> with the image. I am posting the whole code below. Please do let me know
> about any changes, corrections or modifications that are needed. The image
> display code is towards the last.
>
> Thanks,
> Sashi
>
> 
> 
> 
> 
> 
> Building Name:
>  Select a Building
>     Williams Hall
>     Women's Softball Field
>     Wright House
> 
> 
>                   
> 
>  // Connects to your Database
> $host="*";
> $user="*";
> $password="*";
> $dbname="*";
> $cxn=mysqli_connect($host, $user, $password, $dbname) ;
> if (!$cxn=mysqli_connect($host, $user, $password, $dbname))
>   {
>       $error=mysqli_error($cxn);
>       echo "$error";
>       die();
>   }
> else
>   {
>       echo "Connection established successfully";
>   }
> //Define the variables for Day and Month
> $Today=date("l");
> $Month=date("F");
> $build=$_POST["name"];
> $low_speed=2.5;
> $high_speed=4;
> $hour=date("G");
> $minute=date("i");
> if ($minute>=00 && $minute<=14)
>   {
>       $minute=00;
>   }
> elseif ($minute>=15 && $minute<=29)
>   {
>       $minute=15;
>   }
> elseif ($minute>=30 && $minute<=44)
>   {
>       $minute=30;
>   }
> else
>   {
>       $minute=45;
>   }
> $times="10:$minute";
> $sql="SELECT buildingname, parking_lot_name, empty_spaces, distance,
> round(distance/($low_speed*60),1) AS low_time,
> round(distance/($high_speed*60),1) AS high_time, Location FROM buildings,
> buildings_lots, parkinglots, occupancy2, Image where
> (buildings.buildingcode=occupancy2.building AND
>  buildings.buildingcode=buildings_lots.building_code AND
> parkinglots.parking_lot_code=buildings_lots.parking_lot_code AND
> parkinglots.parking_lot_code=occupancy2.parking_lot AND
> Buildings.BuildingCode=Image.BuildingCode) AND buildingname='$build' AND
> month='$Month' AND day='Monday' AND Time='$times'";
> $data = mysqli_query($cxn,$sql);
> if (!$data=mysqli_query($cxn,$sql))
>   {
>       $error=mysqli_error($cxn);
>       echo "$error";
>       die();
>   }
> else
>   {
>       echo "";
>       echo "Query sent successfully";
>   }
> echo "";
> echo " PARKING LOT INFORMATION ";
> echo "";
> echo "\n
>       Building\n
>       Parking Lot\n
>       Estimated Number of Empty Spaces\n
>       Distance (Feet)\n
>       Estimated walking time to the building\n
>   \n";
> while ($row=mysqli_fetch_array($data))
>   {
>       extract($row);
> $building = $row[0];
>     $parking_lot = $row[1];
>     $Number_of_Empty_Spaces = $row[2];
>     $Distance = $row[3];
>     $time_l = $row[4];
>     $time_h=$row[5];
>     $location=$row[6];   echo "\n
>             $building\n
>             $parking_lot\n
> $Number_of_Empty_Spaces\n
>             $Distance\n
>             $time_h - $time_l mins\n
> $location\n
>             \n";
>   }
>   echo "\n";
> header('Content-Type: image/jpeg');
> imagejpeg(imagecreatefromjpeg("$location"));
> ?>
> 
> 
> Nathan Nobbe wrote:
>>
>> On Sat, Mar 7, 2009 at 9:36 PM, Sashikanth Gurram  wrote:
>>
>>
>>>
>>> The thing is, I do not have a website or a place where I am storing my
>>> images. I am storing the images on my local PC in folder as mentioned in
>>> my
>>> earlier post. I have tried using only the
>>>
>>> else {
>>> header('Content-Type: image/jpeg');
>>> imagejpeg($img);
>>> imagedestroy($img);
>>> }
>>>
>>> Which you have suggested. This is the piece of code which is returning
>>> all
>>> the binary character stuff. The code is definitely fetching the image.
>>> But
>>> it is not able to deliver to the browser in the form of an image. I am
>>> trying to read the image file as binary, evident from the FILE_BINARY
>>> command. So may be, that is causing the image to be displayed as binary.
>>> Is
>>> there any way we can convert the binary content to jpeg/jpg content
>>> again.
>>> This is my guess after having gone through the code again.
>>>
>>
>>
>> i spent 2 minutes working on it and read this in the manual,
>>
>> the first param of imagejpeg(),
>>
>> An image resource, retur

Re: [PHP] Retrieving Image Location in PHP from MySQL

2009-03-09 Thread Sashikanth Gurram

Hi Nathan,

Thanks a lot for the suggestion. It is working fine for an example code 
I have used to test it. The code I have written after your suggestion is 
as follows.


The above code is yielding me a picture. Now, When I tried to use it in 
my original code it is not giving me the image. Instead it is giving me 
this warning *Warning*: Cannot modify header information - headers 
already sent by (output started at C:\wamp\www\mysqli.php:65) 
in *C:\wamp\www\mysqli.php* on line *221*
and a lot binary characters again instead of the image. I know something 
about this warning that we should not output anything to the browser 
before the header. But I cannot do that, since I need the user input 
using a html form and I use the input to fetch the data and dispaly it 
in a table along with the image. I am posting the whole code below. 
Please do let me know about any changes, corrections or modifications 
that are needed. The image display code is towards the last.


Thanks,
Sashi






Building Name:
 Select a Building
 Williams Hall
 Women's Softball Field
 Wright House


   

=00 && $minute<=14)
   {
   $minute=00;
   }
elseif ($minute>=15 && $minute<=29)
   {
   $minute=15;
   }
elseif ($minute>=30 && $minute<=44)
   {
   $minute=30;
   }
else
   {
   $minute=45;
   }
$times="10:$minute";
$sql="SELECT buildingname, parking_lot_name, empty_spaces, distance, 
round(distance/($low_speed*60),1) AS low_time, 
round(distance/($high_speed*60),1) AS high_time, Location FROM 
buildings, buildings_lots, parkinglots, occupancy2, Image where 
(buildings.buildingcode=occupancy2.building AND  
buildings.buildingcode=buildings_lots.building_code AND 
parkinglots.parking_lot_code=buildings_lots.parking_lot_code AND 
parkinglots.parking_lot_code=occupancy2.parking_lot AND 
Buildings.BuildingCode=Image.BuildingCode) AND buildingname='$build' AND 
month='$Month' AND day='Monday' AND Time='$times'";

$data = mysqli_query($cxn,$sql);
if (!$data=mysqli_query($cxn,$sql))
   {
   $error=mysqli_error($cxn);
   echo "$error";
   die();
   }
else
   {
   echo "";
   echo "Query sent successfully";
   }
echo "";
echo " PARKING LOT INFORMATION ";
echo "";
echo "\n
   Building\n
   Parking Lot\n
   Estimated Number of Empty Spaces\n
   Distance (Feet)\n
   Estimated walking time to the building\n
   \n";
while ($row=mysqli_fetch_array($data))
   {
   extract($row);
$building = $row[0];
 $parking_lot = $row[1];
 $Number_of_Empty_Spaces = $row[2];
 $Distance = $row[3];
 $time_l = $row[4];
 $time_h=$row[5];
 $location=$row[6];   
echo "\n

 $building\n
 $parking_lot\n  
 $Number_of_Empty_Spaces\n

 $Distance\n
 $time_h - $time_l mins\n
$location\n
 \n";
   }
   echo "\n";
header('Content-Type: image/jpeg');
imagejpeg(imagecreatefromjpeg("$location"));
?>


Nathan Nobbe wrote:

On Sat, Mar 7, 2009 at 9:36 PM, Sashikanth Gurram  wrote:

  

The thing is, I do not have a website or a place where I am storing my
images. I am storing the images on my local PC in folder as mentioned in my
earlier post. I have tried using only the

else {
header('Content-Type: image/jpeg');
imagejpeg($img);
imagedestroy($img);
}

Which you have suggested. This is the piece of code which is returning all
the binary character stuff. The code is definitely fetching the image. But
it is not able to deliver to the browser in the form of an image. I am
trying to read the image file as binary, evident from the FILE_BINARY
command. So may be, that is causing the image to be displayed as binary. Is
there any way we can convert the binary content to jpeg/jpg content again.
This is my guess after having gone through the code again.




i spent 2 minutes working on it and read this in the manual,

the first param of imagejpeg(),

An image resource, returned by one of the image creation functions, such as
imagecreatetruecolor()
.

so, then i tossed this together,

http://nathan.moxune.com/echoImage.php

  



--
~
~
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



Re: [PHP] Retrieving Image Location in PHP from MySQL

2009-03-09 Thread Sashikanth Gurram

Hi Nathan,

Thanks a lot for the suggestion. It is working fine for an example code 
I have used to test it. The code I have written after your suggestion is 
as follows.


The above code is yielding me a picture. Now, When I tried to use it in 
my original code it is not giving me the image. Instead it is giving me 
this warning *Warning*: Cannot modify header information - headers 
already sent by (output started at C:\wamp\www\mysqli.php:65) in 
*C:\wamp\www\mysqli.php* on line *221*
and a lot binary characters again instead of the image. I know something 
about this warning that we should not output anything to the browser 
before the header. But I cannot do that, since I need the user input 
using a html form and I use the input to fetch the data and dispaly it 
in a table along with the image. I am posting the whole code below. 
Please do let me know about any changes, corrections or modifications 
that are needed. The image display code is towards the last.


Thanks,
Sashi






Building Name:
 Select a Building
Williams Hall
Women's Softball Field
Wright House


  

=00 && $minute<=14)
  {
  $minute=00;
  }
elseif ($minute>=15 && $minute<=29)
  {
  $minute=15;
  }
elseif ($minute>=30 && $minute<=44)
  {
  $minute=30;
  }
else
  {
  $minute=45;
  }
$times="10:$minute";
$sql="SELECT buildingname, parking_lot_name, empty_spaces, distance, 
round(distance/($low_speed*60),1) AS low_time, 
round(distance/($high_speed*60),1) AS high_time, Location FROM 
buildings, buildings_lots, parkinglots, occupancy2, Image where 
(buildings.buildingcode=occupancy2.building AND  
buildings.buildingcode=buildings_lots.building_code AND 
parkinglots.parking_lot_code=buildings_lots.parking_lot_code AND 
parkinglots.parking_lot_code=occupancy2.parking_lot AND 
Buildings.BuildingCode=Image.BuildingCode) AND buildingname='$build' AND 
month='$Month' AND day='Monday' AND Time='$times'";

$data = mysqli_query($cxn,$sql);
if (!$data=mysqli_query($cxn,$sql))
  {
  $error=mysqli_error($cxn);
  echo "$error";
  die();
  }
else
  {
  echo "";
  echo "Query sent successfully";
  }
echo "";
echo " PARKING LOT INFORMATION ";
echo "";
echo "\n
  Building\n
  Parking Lot\n
  Estimated Number of Empty Spaces\n
  Distance (Feet)\n
  Estimated walking time to the building\n
  \n";
while ($row=mysqli_fetch_array($data))
  {
  extract($row);
$building = $row[0];
$parking_lot = $row[1];
$Number_of_Empty_Spaces = $row[2];
$Distance = $row[3];
$time_l = $row[4];
$time_h=$row[5];
$location=$row[6];   echo "\n
$building\n
$parking_lot\n   
$Number_of_Empty_Spaces\n

$Distance\n
$time_h - $time_l mins\n
$location\n
\n";
  }
  echo "\n";
header('Content-Type: image/jpeg');
imagejpeg(imagecreatefromjpeg("$location"));
?>



Nathan Nobbe wrote:

On Sat, Mar 7, 2009 at 9:36 PM, Sashikanth Gurram  wrote:

  

The thing is, I do not have a website or a place where I am storing my
images. I am storing the images on my local PC in folder as mentioned in my
earlier post. I have tried using only the

else {
header('Content-Type: image/jpeg');
imagejpeg($img);
imagedestroy($img);
}

Which you have suggested. This is the piece of code which is returning all
the binary character stuff. The code is definitely fetching the image. But
it is not able to deliver to the browser in the form of an image. I am
trying to read the image file as binary, evident from the FILE_BINARY
command. So may be, that is causing the image to be displayed as binary. Is
there any way we can convert the binary content to jpeg/jpg content again.
This is my guess after having gone through the code again.




i spent 2 minutes working on it and read this in the manual,

the first param of imagejpeg(),

An image resource, returned by one of the image creation functions, such as
imagecreatetruecolor()
.

so, then i tossed this together,

http://nathan.moxune.com/echoImage.php

  



--
~
~
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



Re: [PHP] Retrieving Image Location in PHP from MySQL

2009-03-07 Thread Nathan Nobbe
On Sat, Mar 7, 2009 at 9:36 PM, Sashikanth Gurram  wrote:

> The thing is, I do not have a website or a place where I am storing my
> images. I am storing the images on my local PC in folder as mentioned in my
> earlier post. I have tried using only the
>
> else {
> header('Content-Type: image/jpeg');
> imagejpeg($img);
> imagedestroy($img);
> }
>
> Which you have suggested. This is the piece of code which is returning all
> the binary character stuff. The code is definitely fetching the image. But
> it is not able to deliver to the browser in the form of an image. I am
> trying to read the image file as binary, evident from the FILE_BINARY
> command. So may be, that is causing the image to be displayed as binary. Is
> there any way we can convert the binary content to jpeg/jpg content again.
> This is my guess after having gone through the code again.


i spent 2 minutes working on it and read this in the manual,

the first param of imagejpeg(),

An image resource, returned by one of the image creation functions, such as
imagecreatetruecolor()
.

so, then i tossed this together,

http://nathan.moxune.com/echoImage.php



Re: [PHP] Retrieving Image Location in PHP from MySQL

2009-03-07 Thread Sashikanth Gurram
The thing is, I do not have a website or a place where I am storing my 
images. I am storing the images on my local PC in folder as mentioned in 
my earlier post. I have tried using only the


else {
header('Content-Type: image/jpeg');
imagejpeg($img);
imagedestroy($img);
}

Which you have suggested. This is the piece of code which is returning 
all the binary character stuff. The code is definitely fetching the 
image. But it is not able to deliver to the browser in the form of an 
image. I am trying to read the image file as binary, evident from the 
FILE_BINARY command. So may be, that is causing the image to be 
displayed as binary. Is there any way we can convert the binary content 
to jpeg/jpg content again. This is my guess after having gone through 
the code again.\


Thanks,
Sashi

Nathan Nobbe wrote:

On Sat, Mar 7, 2009 at 8:12 PM, Sashikanth Gurram  wrote:

  

I am just storing the location of the image(as a varchar type), not the
image itself. For example for a particular image, the location is stored as
C:\wamp\bin\apache\apache2.2.8\htdocs\Bldgs_lots\Burruss.jpg




echo "\n";
$err=1;
if ($img = file_get_contents("$location", FILE_BINARY))
{
if ($img = imagecreatefromstring($img)) $err = 0;
}
if ($err)
{
header('Content-Type: text/html');
echo 'Error getting
image...';
}
else
{
header('Content-Type: image/jpeg');
imagejpeg($img);
echo '';
imagedestroy($img);
}
?>

im really not sure why youre doing it this way, maybe you can elaborate..?
the more-or-less straightforward way to do this, if you want the url in an
image tag, is to expose access to these images through the webserver, so
that you might have a url like (assume youre site is mysite.com),

http://mysite.com/Bldgs_lots/Burruss.jpg

and at that point, including it in a page becomes trivial.

say you have the location, $location, from the db already, as above, then

$url = 'http://mysite.com/' . $location;
echo '';

also, if i were to guess why youre getting junk is b/c youre using the
header() function to tell the browser youre sending out an image.  i believe
it will then try to treat w/e you send it as the binary of a jpeg.  which
 tag.  iirc, all you need to
do is call imagejpeg().  from the manual on imagejpeg(),

The path to save the file to. If not set or *NULL*, the raw image stream
will be outputted directly.

so basically, just,

else {
header('Content-Type: image/jpeg');
imagejpeg($img);
imagedestroy($img);
}

-nathan

  



--
~
~
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



Re: [PHP] Retrieving Image Location in PHP from MySQL

2009-03-07 Thread Nathan Nobbe
On Sat, Mar 7, 2009 at 8:12 PM, Sashikanth Gurram  wrote:

> I am just storing the location of the image(as a varchar type), not the
> image itself. For example for a particular image, the location is stored as
> C:\wamp\bin\apache\apache2.2.8\htdocs\Bldgs_lots\Burruss.jpg
>

echo "\n";
$err=1;
if ($img = file_get_contents("$location", FILE_BINARY))
{
if ($img = imagecreatefromstring($img)) $err = 0;
}
if ($err)
{
header('Content-Type: text/html');
echo 'Error getting
image...';
}
else
{
header('Content-Type: image/jpeg');
imagejpeg($img);
echo '';
imagedestroy($img);
}
?>

im really not sure why youre doing it this way, maybe you can elaborate..?
the more-or-less straightforward way to do this, if you want the url in an
image tag, is to expose access to these images through the webserver, so
that you might have a url like (assume youre site is mysite.com),

http://mysite.com/Bldgs_lots/Burruss.jpg

and at that point, including it in a page becomes trivial.

say you have the location, $location, from the db already, as above, then

$url = 'http://mysite.com/' . $location;
echo '';

also, if i were to guess why youre getting junk is b/c youre using the
header() function to tell the browser youre sending out an image.  i believe
it will then try to treat w/e you send it as the binary of a jpeg.  which
 tag.  iirc, all you need to
do is call imagejpeg().  from the manual on imagejpeg(),

The path to save the file to. If not set or *NULL*, the raw image stream
will be outputted directly.

so basically, just,

else {
header('Content-Type: image/jpeg');
imagejpeg($img);
imagedestroy($img);
}

-nathan


Re: [PHP] Retrieving Image Location in PHP from MySQL

2009-03-07 Thread Sashikanth Gurram
I am just storing the location of the image(as a varchar type), not the 
image itself. For example for a particular image, the location is stored 
as C:\wamp\bin\apache\apache2.2.8\htdocs\Bldgs_lots\Burruss.jpg


-sashi

Nathan Nobbe wrote:



On Sat, Mar 7, 2009 at 7:10 PM, Sashikanth Gurram > wrote:


Hello everyone,

I am using a WAMP server for my coding purposes. My MySQL Version
is 5.0.51b, PHP version is 5.2.6 and Apache version is 2.2.8

I have created a database with one of the tables containing a
location of the image. Using PHP I am trying to retrieve the
location of the image (from the mysql db) and display it in a
browser. I have, with help from php-db mailing list user's help,
created a code to do the same. Now, the problem is, the code is
extracting the location details of the image exactly and it is
even getting the image details. But it is simply not dispalying
the image. Instead of displaying the image, it is printing a hell
lot of binary characters (For example: 2!
!22ÿÀ   ^"
 ÿÄ  ÿĵ }   !1A  Qa "q 2 ‘¡ #B±Á
RÑð$3br‚
 %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyzƒ„…†‡ˆ‰Š’“”•–—˜™š¢£¤¥¦§¨©ª²³´µ¶·¸¹ºÂÃÄÅÆÇÈÉÊÒÓÔÕÖ×ØÙÚáâãäåæçèéêñòóôõö÷øùúÿÄ

ÿĵ  w  !1  AQ aq "2   B‘¡±Á
#3Rð brÑ $4á%ñ  
 &'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz‚ƒ„…†‡ˆ‰Š’“”•–—˜™š¢£¤)


I have tried in two forums and mailing lists but none of them have
completely answered my question. How do I get rid of these signs
and display the original image in its place? And to display the
image successfully, is it really necessary to create the image
retrieval and displaying code in a seperate PHP file? Any PHP
gurus, enthusiasts, newbies out there, Please help me out.

I am posting the code below so that you can directly see what I
have done till now. The name of the php file is mysqli.php. The
location of the image is stored to the variable $location. The
image retrieval code is present towards end of the file.

Thanks,
Sashi






Building Name:
 Select a Building
Williams Hall
Women's Softball Field
Wright House




=00 && $minute<=14)
{
$minute=00;
}
elseif ($minute>=15 && $minute<=29)
{
$minute=15;
}
elseif ($minute>=30 && $minute<=44)
{
$minute=30;
}
else
{
$minute=45;
}
$times="$hour:$minute";
$sql="SELECT buildingname, parking_lot_name, empty_spaces,
distance, round(distance/($low_speed*60),1) AS low_time,
round(distance/($high_speed*60),1) AS high_time, Location FROM
buildings, buildings_lots, parkinglots, occupancy2, Image where
(buildings.buildingcode=occupancy2.building AND
buildings.buildingcode=buildings_lots.building_code AND
parkinglots.parking_lot_code=buildings_lots.parking_lot_code AND
parkinglots.parking_lot_code=occupancy2.parking_lot AND
Buildings.BuildingCode=Image.BuildingCode) AND
buildingname='$build' AND month='$Month' AND day='$Today' AND
Time='$times'";
$data = mysqli_query($cxn,$sql);
if (!$data=mysqli_query($cxn,$sql))
{
$error=mysqli_error($cxn);
echo "$error";
die();
}
else
{
echo "";
echo "Query sent successfully";
}
echo "";
echo " PARKING LOT INFORMATION ";
echo "";
echo "\n
Building\n
Parking Lot\n
Estimated Number of Empty Spaces\n
Distance (Feet)\n
Estimated walking time to the building\n
\n";
while ($row=mysqli_fetch_array($data))
{
extract($row);
$building = $row[0];
$parking_lot = $row[1];
$Number_of_Empty_Spaces = $row[2];
$Distance = $row[3];
$time_l = $row[4];
$time_h=$row[5];
$location=$row[6];
echo "\n
$building\n
$parking_lot\n
$Number_of_Empty_Spaces\n
$Distance\n
$time_h - $time_l mins\n
$location\n
\n";
}
echo "\n";
$err=1;
if ($img = file_get_contents("$location", FILE_BINARY))
{
if ($img = imagecreatefromstring($img)) $err = 0;
}
if ($err)
{
header('Content-Type: text/html');
echo 'Error getting
image...';
}
else
{
header('Content-Type: image/jpeg');
imagejpeg($img);
echo '';
imagedestroy($img);
}
?>




how are you storing the image in the database?  i believe youll want 
to make it a BLOB of some type.  also, depending on the application, 
many folks prefer to just place images directly on the filesystem, 
then reference their location on the filesystem in the database.


-nathan




--
~
~
Sashikanth Gurram
Graduate Research Assistant
Department of Civil and Environmental Engineering
Virginia Tech
Bl

Re: [PHP] Retrieving Image Location in PHP from MySQL

2009-03-07 Thread Nathan Nobbe
On Sat, Mar 7, 2009 at 7:10 PM, Sashikanth Gurram  wrote:

> Hello everyone,
>
> I am using a WAMP server for my coding purposes. My MySQL Version is
> 5.0.51b, PHP version is 5.2.6 and Apache version is 2.2.8
>
> I have created a database with one of the tables containing a location of
> the image. Using PHP I am trying to retrieve the location of the image (from
> the mysql db) and display it in a browser. I have, with help from php-db
> mailing list user's help, created a code to do the same. Now, the problem
> is, the code is extracting the location details of the image exactly and it
> is even getting the image details. But it is simply not dispalying the
> image. Instead of displaying the image, it is printing a hell lot of binary
> characters (For example: 2!
> !22ÿÀ   ^"  ÿÄ
>ÿĵ }   !1A  Qa "q 2 ‘¡ #B±Á RÑð$3br‚
>  
> %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyzƒ„…†‡ˆ‰Š’“”•–—˜™š¢£¤¥¦§¨©ª²³´µ¶·¸¹ºÂÃÄÅÆÇÈÉÊÒÓÔÕÖ×ØÙÚáâãäåæçèéêñòóôõö÷øùúÿÄ
> ÿĵ  w  !1  AQ aq "2   B‘¡±Á #3Rð brÑ
> $4á%ñ&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz‚ƒ„…†‡ˆ‰Š’“”•–—˜™š¢£¤)
>
> I have tried in two forums and mailing lists but none of them have
> completely answered my question. How do I get rid of these signs and display
> the original image in its place? And to display the image successfully, is
> it really necessary to create the image retrieval and displaying code in a
> seperate PHP file? Any PHP gurus, enthusiasts, newbies out there, Please
> help me out.
>
> I am posting the code below so that you can directly see what I have done
> till now. The name of the php file is mysqli.php. The location of the image
> is stored to the variable $location. The image retrieval code is present
> towards end of the file.
>
> Thanks,
> Sashi
>
> 
> 
> 
> 
> 
> Building Name:
>  Select a Building
> Williams Hall
> Women's Softball Field
> Wright House
> 
> 
> 
> 
>  // Connects to your Database
> $host="***";
> $user="***";
> $password="***";
> $dbname="***";
> $cxn=mysqli_connect($host, $user, $password, $dbname) ;
> if (!$cxn=mysqli_connect($host, $user, $password, $dbname))
> {
> $error=mysqli_error($cxn);
> echo "$error";
> die();
> }
> else
> {
> echo "Connection established successfully";
> }
> //Define the variables for Day and Month
> $Today=date("l");
> $Month=date("F");
> $build=$_POST["name"];
> $low_speed=2.5;
> $high_speed=4;
> $hour=date("G");
> $minute=date("i");
> if ($minute>=00 && $minute<=14)
> {
> $minute=00;
> }
> elseif ($minute>=15 && $minute<=29)
> {
> $minute=15;
> }
> elseif ($minute>=30 && $minute<=44)
> {
> $minute=30;
> }
> else
> {
> $minute=45;
> }
> $times="$hour:$minute";
> $sql="SELECT buildingname, parking_lot_name, empty_spaces, distance,
> round(distance/($low_speed*60),1) AS low_time,
> round(distance/($high_speed*60),1) AS high_time, Location FROM buildings,
> buildings_lots, parkinglots, occupancy2, Image where
> (buildings.buildingcode=occupancy2.building AND
> buildings.buildingcode=buildings_lots.building_code AND
> parkinglots.parking_lot_code=buildings_lots.parking_lot_code AND
> parkinglots.parking_lot_code=occupancy2.parking_lot AND
> Buildings.BuildingCode=Image.BuildingCode) AND buildingname='$build' AND
> month='$Month' AND day='$Today' AND Time='$times'";
> $data = mysqli_query($cxn,$sql);
> if (!$data=mysqli_query($cxn,$sql))
> {
> $error=mysqli_error($cxn);
> echo "$error";
> die();
> }
> else
> {
> echo "";
> echo "Query sent successfully";
> }
> echo "";
> echo " PARKING LOT INFORMATION ";
> echo "";
> echo "\n
> Building\n
> Parking Lot\n
> Estimated Number of Empty Spaces\n
> Distance (Feet)\n
> Estimated walking time to the building\n
> \n";
> while ($row=mysqli_fetch_array($data))
> {
> extract($row);
> $building = $row[0];
> $parking_lot = $row[1];
> $Number_of_Empty_Spaces = $row[2];
> $Distance = $row[3];
> $time_l = $row[4];
> $time_h=$row[5];
> $location=$row[6];
> echo "\n
> $building\n
> $parking_lot\n
> $Number_of_Empty_Spaces\n
> $Distance\n
> $time_h - $time_l mins\n
> $location\n
> \n";
> }
> echo "\n";
> $err=1;
> if ($img = file_get_contents("$location", FILE_BINARY))
> {
> if ($img = imagecreatefromstring($img)) $err = 0;
> }
> if ($err)
> {
> header('Content-Type: text/html');
> echo 'Error getting
> image...';
> }
> else
> {
> header('Content-Type: image/jpeg');
> imagejpeg($img);
> echo ' width="200" alt="' . $build . '">';
> imagedestroy($img);
> }
> ?>
> 
> 


how are you storing the image in the database?  i believe youll want to make
it a BLOB of some type.  also, depending on the application, many folks
prefer to just place images directly on the filesystem, then reference their
location on the filesystem in the database.

-nathan