[PHP-DB] Retrieving Image Location in MySQL

2009-03-01 Thread Sashikanth Gurram

Dear All,

I am trying to retrieve the location of a image (not the image, just the 
location of the image) stored on MySQL database, using PHP to display it 
in my browser. One of the users has been kind enough to provide me with 
an example code as to how to do it. He asked me to use /src="picture.php?&qry=123"> /in the html code. I understood the part of 
/picture.php? /which tells us that the php code used to retrieve the 
image is located in the file picture.php (If what I have understood is 
correct). But I did not quite understand the second part /&qry=123 /. 
What does this mean? Of what use is this second part? Does the variable 
&qry has something assigned to it in the picture.php code? I would 
greatly appreciate it if any one of you can answer my questions.


Thanks,
Sashi

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


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



RE: [PHP-DB] Retrieving Image Location in MySQL

2009-03-02 Thread Fortuno, Adam
Sashi,

This (likely) means you have a some generic page (i.e., picture.php)
that displays some picture. The picture it displays depends on the
parameter passed when the page is called (i.e., 123).



Sashi's Test Page


", $row['firstname']);
}

//Clean up
mysql_free_result($output);

?>



Please note, I haven't tried this. It just seems plausible.

Good luck.

A-

-Original Message-
From: Sashikanth Gurram [mailto:sashi...@vt.edu] 
Sent: Sunday, March 01, 2009 10:27 PM
To: php-db@lists.php.net
Subject: [PHP-DB] Retrieving Image Location in MySQL

Dear All,

I am trying to retrieve the location of a image (not the image, just the

location of the image) stored on MySQL database, using PHP to display it

in my browser. One of the users has been kind enough to provide me with 
an example code as to how to do it. He asked me to use / /in the html code. I understood the part of 
/picture.php? /which tells us that the php code used to retrieve the 
image is located in the file picture.php (If what I have understood is 
correct). But I did not quite understand the second part /&qry=123 /. 
What does this mean? Of what use is this second part? Does the variable 
&qry has something assigned to it in the picture.php code? I would 
greatly appreciate it if any one of you can answer my questions.

Thanks,
Sashi

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


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


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



Re: [PHP-DB] Retrieving Image Location in MySQL

2009-03-02 Thread Mattyasovszky Janos

Fortuno, Adam írta:


//Write a query to pull out the picture's path
$sql = "SELECT path FROM Image WHERE ID = %s";
mysql_real_escape_string($value);


Sorry, but this won't work, since you don't map the value of the escaped 
$value to the %s, lets say with sprintf()...


Regards,
Matya

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



RE: [PHP-DB] Retrieving Image Location in MySQL

2009-03-02 Thread Fortuno, Adam
Matya,

Ha, ha, ha! Thank you good friend. I did say I didn't try the code :-)

AF> Please note, I haven't tried this. It just seems plausible.

I apologize if I confused anyone. I just meant to show how the parameter could 
help retrieve a picture. I wasn't too concerned with the particulars. Hopefully 
the concept is sound. If not, please do flame my note so no one attempts it.

Be Well,
A-

-Original Message-
From: Mattyasovszky Janos [mailto:m...@matya.hu] 
Sent: Monday, March 02, 2009 9:29 AM
To: php-db@lists.php.net
Subject: Re: [PHP-DB] Retrieving Image Location in MySQL

Fortuno, Adam írta:

>   //Write a query to pull out the picture's path
>   $sql = "SELECT path FROM Image WHERE ID = %s";
>   mysql_real_escape_string($value);

Sorry, but this won't work, since you don't map the value of the escaped 
$value to the %s, lets say with sprintf()...

Regards,
Matya

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


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



Re: [PHP-DB] Retrieving Image Location in MySQL

2009-03-02 Thread Sashikanth Gurram

Hello guys,

Thanks to you all for your kind replies. I will try the steps and get 
back to you if I encounter more problems.


Thanks,
Sashi

Fortuno, Adam wrote:

Matya,

Ha, ha, ha! Thank you good friend. I did say I didn't try the code :-)

AF> Please note, I haven't tried this. It just seems plausible.

I apologize if I confused anyone. I just meant to show how the parameter could 
help retrieve a picture. I wasn't too concerned with the particulars. Hopefully 
the concept is sound. If not, please do flame my note so no one attempts it.

Be Well,
A-

-Original Message-
From: Mattyasovszky Janos [mailto:m...@matya.hu] 
Sent: Monday, March 02, 2009 9:29 AM

To: php-db@lists.php.net
Subject: Re: [PHP-DB] Retrieving Image Location in MySQL

Fortuno, Adam írta:

  

//Write a query to pull out the picture's path
$sql = "SELECT path FROM Image WHERE ID = %s";
mysql_real_escape_string($value);



Sorry, but this won't work, since you don't map the value of the escaped 
$value to the %s, lets say with sprintf()...


Regards,
Matya

  



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


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



Re: [PHP-DB] Retrieving Image Location in MySQL

2009-03-06 Thread Sashikanth Gurram

Dear all,

I have been trying to retrieve the location of a image from database and 
display the image in the browser using PHP. I have written a sort of 
code for the purpose. All I am getting in my browser after using the 
code is a long set of ASCII characters with the following 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 *237

*
I am herewith attaching my code. If anyone can  point out the error or 
give some kind of advice that would be really great. The location of the 
image is stored in a table by the name IMAGE under the column name 
Location and here in the code, the location is retrieved under the 
varibale name $Location.


thanks,
Sashi

/




Building Name:
 Select a Building
Agnew Hall
 Rector Field House
 Richard B. Talbot Educational Resources Center

 Robeson Hall
 Sandy Hall
 Saunders hall
 Seitz Hall
 Shanks Hall
 Shultz Hall
 Skelton Conference 
Center

 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);
 imagedestroy($img);
}
?>

/

Sashikanth Gurram wrote:

Hello guys,

Thanks to you all for your kind replies. I will try the steps and get 
back to you if I encounter more problems.


Thanks,
Sashi

Fortuno, Adam wrote:

Matya,

Ha, ha, ha! Thank you good friend. I did say I didn't try the code :-)

AF> Please note, I haven't tried this. It just seems plausible.

I apologize if I confused anyone. I just meant to show how the 
parameter could help retrieve a picture. I wasn't too concerned with 
the particulars. Hopefully the concept is sound. If not, please do 
flame my note so no one attempts it.


Be Well,
A-

-Original Message-
From: Mattyasovszky Janos [mailto:m...@matya.hu] Sent: Monday, March 
02, 2009 9:29 AM

To: php-db@lists.php.net
Subject: Re: [PHP-DB] Retrieving Image Location in MySQL

Fortuno, Adam írta:

 

//Write a query to pull out the picture's path
$sql = "SELECT path FROM Image WHERE ID = %s";
mysql_real_escape_string($value);



Sorry, but this won't work, since you don't map the value of the 
escaped $value to the %s, lets say with sprintf()...


Regards,
Matya

  






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


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



Re: [PHP-DB] Retrieving Image Location in MySQL

2009-03-06 Thread Joao Gomes Madeira
Hi Sashi:

You're incurring in this error because the headers for the page have
already been issued in the head section of your page.
When you issue the php header() function, it will generate an error.

Anyway, you are storing a path to a file in the database. My question
is: do you want to put your images on a subfolder of your site, where
they will become acessible through regular URLS, or you want to keep
them private and only accessible by scripting?

Cheers.
JP

-Original Message-
From: Sashikanth Gurram 
To: php-db@lists.php.net
Subject: Re: [PHP-DB] Retrieving Image Location in MySQL
Date: Fri, 06 Mar 2009 12:23:31 -0500

Dear all,

I have been trying to retrieve the location of a image from database and 
display the image in the browser using PHP. I have written a sort of 
code for the purpose. All I am getting in my browser after using the 
code is a long set of ASCII characters with the following 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 *237
*
I am herewith attaching my code. If anyone can  point out the error or 
give some kind of advice that would be really great. The location of the 
image is stored in a table by the name IMAGE under the column name 
Location and here in the code, the location is retrieved under the 
varibale name $Location.

thanks,
Sashi

/




Building Name:
 Select a Building
Agnew Hall
  Rector Field House
  Richard B. Talbot Educational Resources Center
  Robeson Hall
  Sandy Hall
  Saunders hall
  Seitz Hall
  Shanks Hall
  Shultz Hall
  Skelton Conference 
Center
  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);
  imagedestroy($img);
}
?>

/

Sashikanth Gurram wrote:
> Hello guys,
>
> Thanks to you all for your kind replies. I will try the steps and get 
> back to you if I encounter more problems.
>
> Thanks,
> Sashi
>
> Fortuno, Adam wrote:
>> Matya,
>>
>> Ha, ha, ha! Thank you good friend. I did say I didn't try the code :-)
>>
>> AF> Please note, I haven't tried this. It just seems plausible.
>>
>> I apologize if I confused anyone. I just meant to show how the 
>> parameter could help retrieve a picture. I wasn't too concerned with 
>> the particulars. Hopefully the concept is sound. If not, please do 
>> flame my note so no one attempts it.
>>
>> Be Well,
>> A-
>>
>> -Original Message-
>> From: Mattyasovszky Janos [mailto:m...@matya.hu] Sent: Monday, March 
>&

Re: [PHP-DB] Retrieving Image Location in MySQL

2009-03-06 Thread Bastien Koert
On Fri, Mar 6, 2009 at 1:06 PM, Joao Gomes Madeira wrote:

> Hi Sashi:
>
> You're incurring in this error because the headers for the page have
> already been issued in the head section of your page.
> When you issue the php header() function, it will generate an error.
>
> Anyway, you are storing a path to a file in the database. My question
> is: do you want to put your images on a subfolder of your site, where
> they will become acessible through regular URLS, or you want to keep
> them private and only accessible by scripting?
>
> Cheers.
> JP
>
> -Original Message-
> From: Sashikanth Gurram 
> To: php-db@lists.php.net
> Subject: Re: [PHP-DB] Retrieving Image Location in MySQL
> Date: Fri, 06 Mar 2009 12:23:31 -0500
>
> Dear all,
>
> I have been trying to retrieve the location of a image from database and
> display the image in the browser using PHP. I have written a sort of
> code for the purpose. All I am getting in my browser after using the
> code is a long set of ASCII characters with the following 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 *237
> *
> I am herewith attaching my code. If anyone can  point out the error or
> give some kind of advice that would be really great. The location of the
> image is stored in a table by the name IMAGE under the column name
> Location and here in the code, the location is retrieved under the
> varibale name $Location.
>
> thanks,
> Sashi
>
> /
> 
> 
> 
> 
> Building Name:
>  Select a Building
> Agnew Hall
>  Rector Field House
>  Richard B. Talbot Educational Resources Center
>  Robeson Hall
>  Sandy Hall
>  Saunders hall
>  Seitz Hall
>  Shanks Hall
>  Shultz Hall
>  Skelton Conference
> Center
>  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\

Re: [PHP-DB] Retrieving Image Location in MySQL

2009-03-06 Thread Sashikanth Gurram

Hi JP,

I am just storing the location of the image on the database. I want to 
keep them private and retrieve them through scripting. The images are 
stored in a folder on my PC. Just to give you an example, this is the 
location of a particular image as stored in the database.


C:\Users\Sashikanth\Desktop\Bldgs_lots\Burruss.jpg

Thanks,
Sashi

Joao Gomes Madeira wrote:

Hi Sashi:

You're incurring in this error because the headers for the page have
already been issued in the head section of your page.
When you issue the php header() function, it will generate an error.

Anyway, you are storing a path to a file in the database. My question
is: do you want to put your images on a subfolder of your site, where
they will become acessible through regular URLS, or you want to keep
them private and only accessible by scripting?

Cheers.
JP

-Original Message-
From: Sashikanth Gurram 
To: php-db@lists.php.net
Subject: Re: [PHP-DB] Retrieving Image Location in MySQL
Date: Fri, 06 Mar 2009 12:23:31 -0500

Dear all,

I have been trying to retrieve the location of a image from database and 
display the image in the browser using PHP. I have written a sort of 
code for the purpose. All I am getting in my browser after using the 
code is a long set of ASCII characters with the following 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 *237

*
I am herewith attaching my code. If anyone can  point out the error or 
give some kind of advice that would be really great. The location of the 
image is stored in a table by the name IMAGE under the column name 
Location and here in the code, the location is retrieved under the 
varibale name $Location.


thanks,
Sashi

/




Building Name:
 Select a Building
Agnew Hall
  Rector Field House
  Richard B. Talbot Educational Resources Center

  Robeson Hall
  Sandy Hall
  Saunders hall
  Seitz Hall
  Shanks Hall
  Shultz Hall
  Skelton Conference 
Center

  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);
  imagedestroy($img);
}
?>

/

Sashikanth Gurram wrote:
  

Hello guys,

Thanks to you all for your kind replies. I will try the steps and get 
back to you if I encounter more problems.


Thanks,
Sashi

Fortuno, Adam wrote:


Matya,

Ha, ha, ha! Thank you good friend. I did say I didn't try the code :-)

AF> Please note, I haven't tried this. It just seems plausible.

I apologize if I confused anyone. I just meant to show how the 
parameter could help retrieve a picture. I wasn't too concerned w

Re: [PHP-DB] Retrieving Image Location in MySQL

2009-03-06 Thread mrfroasty
echo 'Error getting
> image...';
> }
> else
> {
>  header('Content-Type: image/jpeg');
>  imagejpeg($img);
>  imagedestroy($img);
> }
> ?>
> 
> /
>
> Sashikanth Gurram wrote:
>> Hello guys,
>>
>> Thanks to you all for your kind replies. I will try the steps and get
>> back to you if I encounter more problems.
>>
>> Thanks,
>> Sashi
>>
>> Fortuno, Adam wrote:
>>> Matya,
>>>
>>> Ha, ha, ha! Thank you good friend. I did say I didn't try the code :-)
>>>
>>> AF> Please note, I haven't tried this. It just seems plausible.
>>>
>>> I apologize if I confused anyone. I just meant to show how the
>>> parameter could help retrieve a picture. I wasn't too concerned with
>>> the particulars. Hopefully the concept is sound. If not, please do
>>> flame my note so no one attempts it.
>>>
>>> Be Well,
>>> A-
>>>
>>> -Original Message-
>>> From: Mattyasovszky Janos [mailto:m...@matya.hu] Sent: Monday, March
>>> 02, 2009 9:29 AM
>>> To: php-db@lists.php.net
>>> Subject: Re: [PHP-DB] Retrieving Image Location in MySQL
>>>
>>> Fortuno, Adam írta:
>>>
>>>  
>>>> //Write a query to pull out the picture's path
>>>> $sql = "SELECT path FROM Image WHERE ID = %s";
>>>> mysql_real_escape_string($value);
>>>> 
>>>
>>> Sorry, but this won't work, since you don't map the value of the
>>> escaped $value to the %s, lets say with sprintf()...
>>>
>>> Regards,
>>> Matya
>>>
>>>   
>>
>>
>
>


-- 
Extra details:
OSS:Gentoo Linux-2.6.25-r8
profile:x86
Hardware:msi geforce 8600GT asus p5k-se
location:/home/muhsin
language(s):C/C++,VB,VHDL,bash
Typo:40WPM
url:http://mambo-tech.net


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



Re: [PHP-DB] Retrieving Image Location in MySQL

2009-03-06 Thread Sashikanth Gurram

Hi,
Thanks a lot for the suggestion. It is working fine but there is some 
problem. When I introduced the piece of code you have suggested into my 
code, I am getting a space for the picture but nothing is there in that 
space. It is just blank. I do not know the reason for this. Further, 
this is the piece of code I have written to display the pic.


echo "alt='$build' >";


Any help would be greatly appreciated.
Thanks,
Sashi

mrfroasty wrote:

Hello,

Storing only location of the image in dB wouldnt be any different than
other string/data retrieved from the dB.That means if you have something
like this in html documents whereby $image_location comes from the dB
It should work without header stuffs

Example

P:S
Replace $image_location with image location from your dB.


GR
Muhsin



Sashikanth Gurram wrote:
  

Dear all,

I have been trying to retrieve the location of a image from database
and display the image in the browser using PHP. I have written a sort
of code for the purpose. All I am getting in my browser after using
the code is a long set of ASCII characters with the following 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 *237
*
I am herewith attaching my code. If anyone can  point out the error or
give some kind of advice that would be really great. The location of
the image is stored in a table by the name IMAGE under the column name
Location and here in the code, the location is retrieved under the
varibale name $Location.

thanks,
Sashi

/




Building Name:
 Select a Building
Agnew Hall
 Rector Field House
 Richard B. Talbot Educational Resources Center
 Robeson Hall
 Sandy Hall
 Saunders hall
 Seitz Hall
 Shanks Hall
 Shultz Hall
 Skelton Conference
Center
 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);
 imagedestroy($img);
}
?>

/

Sashikanth Gurram wrote:


Hello guys,

Thanks to you all for your kind replies. I will try the steps and get
back to you if I encounter more problems.

Thanks,
Sashi

Fortuno, Adam wrote:
  

Matya,

Ha, ha, ha! Thank you good friend. I did say I didn't try the code :-)

AF> Please note, I haven't tried this. It just seems plausible.

I apologize if I confused anyone. I just meant to show how the
parameter could help retrieve a picture. I wasn't too concerned with
the particulars. Hopefully the concept is sound. If not, please do
flame my note so no one attempts it.

Be Well,
A-

-Original Message-
From: Mattyasovszky Janos [mailto:m...@matya.hu] Sent: Monday, March
02, 2009 9:29 AM
To: php-db@lists.php.net
Subject: Re: 

Re: [PHP-DB] Retrieving Image Location in MySQL

2009-03-07 Thread Sashikanth Gurram
ks,
Sashi

/




Building Name:
 Select a Building
Agnew Hall
 Rector Field House
 Richard B. Talbot Educational Resources Center
 Robeson Hall
 Sandy Hall
 Saunders hall
 Seitz Hall
 Shanks Hall
 Shultz Hall
 Skelton Conference
Center
 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);
 imagedestroy($img);
}
?>

/

Sashikanth Gurram wrote:
   


Hello guys,

Thanks to you all for your kind replies. I will try the steps and get
back to you if I encounter more problems.

Thanks,
Sashi

Fortuno, Adam wrote:
 
  

Matya,

Ha, ha, ha! Thank you good friend. I did say I didn't try the code
:-)

AF> Please note, I haven't tried this. It just seems plausible.

I apologize if I confused anyone. I just meant to show how the
parameter could help retrieve a picture. I wasn't too concerned with
the particulars. Hopefully the concept is sound. If not, please do
flame my note so no one attempts it.

Be Well,
A-

-Original Message-
From: Mattyasovszky Janos [mailto:m...@matya.hu] Sent: Monday, March
02, 2009 9:29 AM
To: php-db@lists.php.net
Subject: Re: [PHP-DB] Retrieving Image Location in MySQL

Fortuno, Adam írta:

 
   


//Write a query to pull out the picture's path
$sql = "SELECT path FROM Image WHERE ID = %s";
mysql_real_escape_string($value);
  
  

Sorry, but this won't work, since you don't map the value of the
escaped $value to the %s, lets say with sprintf()...

Regards,
Matya

  

  
  


  
  








  



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


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



Re: [PHP-DB] Retrieving Image Location in MySQL

2009-03-07 Thread mrfroasty
gt;>>>>{
>>>>>$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);
>>>>>  imagedestroy($img);
>>>>> }
>>>>> ?>
>>>>> 
>>>>> /
>>>>>
>>>>> Sashikanth Gurram wrote:
>>>>>   
>>>>>> Hello guys,
>>>>>>
>>>>>> Thanks to you all for your kind replies. I will try the steps and
>>>>>> get
>>>>>> back to you if I encounter more problems.
>>>>>>
>>>>>> Thanks,
>>>>>> Sashi
>>>>>>
>>>>>> Fortuno, Adam wrote:
>>>>>>   
>>>>>>> Matya,
>>>>>>>
>>>>>>> Ha, ha, ha! Thank you good friend. I did say I didn't try the code
>>>>>>> :-)
>>>>>>>
>>>>>>> AF> Please note, I haven't tried this. It just seems plausible.
>>>>>>>
>>>>>>> I apologize if I confused anyone. I just meant to show how the
>>>>>>> parameter could help retrieve a picture. I wasn't too concerned
>>>>>>> with
>>>>>>> the particulars. Hopefully the concept is sound. If not, please do
>>>>>>> flame my note so no one attempts it.
>>>>>>>
>>>>>>> Be Well,
>>>>>>> A-
>>>>>>>
>>>>>>> -Original Message-
>>>>>>> From: Mattyasovszky Janos [mailto:m...@matya.hu] Sent: Monday,
>>>>>>> March
>>>>>>> 02, 2009 9:29 AM
>>>>>>> To: php-db@lists.php.net
>>>>>>> Subject: Re: [PHP-DB] Retrieving Image Location in MySQL
>>>>>>>
>>>>>>> Fortuno, Adam írta:
>>>>>>>
>>>>>>>  
>>>>>>>   
>>>>>>>> //Write a query to pull out the picture's path
>>>>>>>> $sql = "SELECT path FROM Image WHERE ID = %s";
>>>>>>>> mysql_real_escape_string($value);
>>>>>>>> 
>>>>>>> Sorry, but this won't work, since you don't map the value of the
>>>>>>> escaped $value to the %s, lets say with sprintf()...
>>>>>>>
>>>>>>> Regards,
>>>>>>> Matya
>>>>>>>
>>>>>>>   
>>>>>> 
>>>>> 
>>>> 
>>>
>>> 
>>>
>>>
>>> 
>>
>>
>>   
>
>


-- 
Extra details:
OSS:Gentoo Linux-2.6.25-r8
profile:x86
Hardware:msi geforce 8600GT asus p5k-se
location:/home/muhsin
language(s):C/C++,VB,VHDL,bash
Typo:40WPM
url:http://mambo-tech.net


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



Re: [PHP-DB] Retrieving Image Location in MySQL

2009-03-07 Thread Sashikanth Gurram
ocation from your dB.


GR
Muhsin



Sashikanth Gurram wrote:
 
 
  

Dear all,

I have been trying to retrieve the location of a image from database
and display the image in the browser using PHP. I have written a sort
of code for the purpose. All I am getting in my browser after using
the code is a long set of ASCII characters with the following 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 *237
*
I am herewith attaching my code. If anyone can  point out the
error or
give some kind of advice that would be really great. The location of
the image is stored in a table by the name IMAGE under the column
name
Location and here in the code, the location is retrieved under the
varibale name $Location.

thanks,
Sashi

/




Building Name:
 Select a Building
Agnew Hall
 Rector Field House
 Richard B. Talbot Educational Resources Center
 Robeson Hall
 Sandy Hall
 Saunders hall
 Seitz Hall
 Shanks Hall
 Shultz Hall
 Skelton Conference
Center
 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);
 imagedestroy($img);
}
?>

/

Sashikanth Gurram wrote:
  


Hello guys,

Thanks to you all for your kind replies. I will try the steps and
get
back to you if I encounter more problems.

Thanks,
Sashi

Fortuno, Adam wrote:
  
  

Matya,

Ha, ha, ha! Thank you good friend. I did say I didn't try the code
:-)

AF> Please note, I haven't tried this. It just seems plausible.

I apologize if I confused anyone. I just meant to show how the
parameter could help retrieve a picture. I wasn't too concerned
with
the particulars. Hopefully the concept is sound. If not, please do
flame my note so no one attempts it.

Be Well,
A-

-Original Message-
From: Mattyasovszky Janos [mailto:m...@matya.hu] Sent: Monday,
March
02, 2009 9:29 AM
To: php-db@lists.php.net
Subject: Re: [PHP-DB] Retrieving Image Location in MySQL

Fortuno, Adam írta:

 
  


//Write a query to pull out the picture's path
$sql = "SELECT path FROM Image WHERE ID = %s";
mysql_real_escape_string($value);

  

Sorry, but this won't work, since you don't map the value of the
escaped $value to the %s, lets say with sprintf()...

Regards,
Matya

  


  



  






  
  




  



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


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



Re: [PHP-DB] Retrieving Image Location in MySQL

2009-03-07 Thread Joao Gomes Madeira
Hello again Sashi

The answer provided by Mushin won't work because images are not
acessible from the outside. You can't have



because that's not a valid URL...

You can have something like



which when interpreted by the browser will become something like

http://yoursite/Bldgs_lots/Burruss.jpg

Now, for this to happen you need to have Bldgs_lots as a subfolder or
alias for your site.

Otherwise, there is the way I mentioned in the first place, involving a
php script just to get the image, which has to be called from within
your script, passing it the info from the database

echo '';

Now, I don't recommend passing local paths like this to scripts ...

Hope this helps
C ya
JP


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



Re: [PHP-DB] Retrieving Image Location in MySQL

2009-03-07 Thread Sashikanth Gurram

Hi JP,
Thanks for chipping in again. I have been using the following code 
(after retrieving the local location of my image to the variable 
$location. I am not really looking to host the pictures onto a site as 
of now), which u have earlier provided me with

/
$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);
 imagedestroy($img);
}
/
I am just using this and nothing more, and I have been getting a warning 
of sort "CANNOT MODIFY HEADER INFORMATION-HEADERS ALREADY SENT ..ON 
LINE 234". I have looked about this warning online and i found that this 
occurs when the output is sent to the browser before the headers. From 
the look of the above code, I dont think I am sending the info to the 
browser before the headers. Also, when I use the above code, I see a lot 
of ASCII characters in my browser. May be, the image is encrypted into 
some form and the encrypted form is being displayed instead of the 
picture. Further, you have always mentioned about using


img src="picture.php?&img=1234. I did not clearly understand where to put it in 
the code. Is it a part of HTML code or is it a part of PHP code?


Thanks,
Sashi



Joao Gomes Madeira wrote:

Hello again Sashi

The answer provided by Mushin won't work because images are not
acessible from the outside. You can't have



because that's not a valid URL...

You can have something like



which when interpreted by the browser will become something like

http://yoursite/Bldgs_lots/Burruss.jpg

Now, for this to happen you need to have Bldgs_lots as a subfolder or
alias for your site.

Otherwise, there is the way I mentioned in the first place, involving a
php script just to get the image, which has to be called from within
your script, passing it the info from the database

echo 'alt="' . $build . '">';


Now, I don't recommend passing local paths like this to scripts ...

Hope this helps
C ya
JP


  



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


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



Re: [PHP-DB] Retrieving Image Location in MySQL

2009-03-07 Thread Phpster
 comes from  
the dB

It should work without header stuffs

Example

P:S
Replace $image_location with image location from your dB.


GR
Muhsin



Sashikanth Gurram wrote:


Dear all,

I have been trying to retrieve the location of a image from  
database
and display the image in the browser using PHP. I have written  
a sort
of code for the purpose. All I am getting in my browser after  
using
the code is a long set of ASCII characters with the following  
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 *237
*
I am herewith attaching my code. If anyone can  point out the
error or
give some kind of advice that would be really great. The  
location of
the image is stored in a table by the name IMAGE under the  
column

name
Location and here in the code, the location is retrieved under  
the

varibale name $Location.

thanks,
Sashi

/




Building Name:
 Select a Building
Agnew Hall
Rector Field Houseoption>

Richard B. Talbot Educational Resources Center
Robeson Hall
Sandy Hall
Saunders hall
Seitz Hall
Shanks Hall
Shultz Hall
Skelton Conference
Center
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);
imagedestroy($img);
}
?>

/

Sashikanth Gurram wrote:


Hello guys,

Thanks to you all for your kind replies. I will try the steps  
and

get
back to you if I encounter more problems.

Thanks,
Sashi

Fortuno, Adam wrote:


Matya,

Ha, ha, ha! Thank you good friend. I did say I didn't try  
the code

:-)

AF> Please note, I haven't tried this. It just seems  
plausible.


I apologize if I confused anyone. I just meant to show how the
parameter could help retrieve a picture. I wasn't too  
concerned

with
the particulars. Hopefully the concept is sound. If not,  
please do

flame my note so no one attempts it.

Be Well,
A-

-Original Message-
From: Mattyasovszky Janos [mailto:m...@matya.hu] Sent: Monday,
March
02, 2009 9:29 AM
To: php-db@lists.php.net
Subject: Re: [PHP-DB] Retrieving Image Location in MySQL

Fortuno, Adam írta:



   //Write a query to pull out the picture's path
   $sql = "SELECT path FROM Image WHERE ID = %s";
   mysql_real_escape_string($value);

Sorry, but this won't work, since you don't map the value of  
the

escaped $value to the %s, lets say with sprintf()...

Regards,
Matya








--- 
--- 
--















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


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



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



Re: [PHP-DB] Retrieving Image Location in MySQL

2009-03-07 Thread Sashikanth Gurram
ieved from the dB.That means if you have
something
like this in html documents whereby $image_location comes from 
the dB

It should work without header stuffs

Example

P:S
Replace $image_location with image location from your dB.


GR
Muhsin



Sashikanth Gurram wrote:


Dear all,

I have been trying to retrieve the location of a image from 
database
and display the image in the browser using PHP. I have written 
a sort
of code for the purpose. All I am getting in my browser after 
using
the code is a long set of ASCII characters with the following 
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 *237
*
I am herewith attaching my code. If anyone can  point out the
error or
give some kind of advice that would be really great. The 
location of

the image is stored in a table by the name IMAGE under the column
name
Location and here in the code, the location is retrieved under the
varibale name $Location.

thanks,
Sashi

/




Building Name:
 Select a Building
Agnew Hall
Rector Field House
Richard B. Talbot Educational Resources Center
Robeson Hall
Sandy Hall
Saunders hall
Seitz Hall
Shanks Hall
Shultz Hall
Skelton Conference
Center
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);
imagedestroy($img);
}
?>

/

Sashikanth Gurram wrote:


Hello guys,

Thanks to you all for your kind replies. I will try the steps and
get
back to you if I encounter more problems.

Thanks,
Sashi

Fortuno, Adam wrote:


Matya,

Ha, ha, ha! Thank you good friend. I did say I didn't try the 
code

:-)

AF> Please note, I haven't tried this. It just seems plausible.

I apologize if I confused anyone. I just meant to show how the
parameter could help retrieve a picture. I wasn't too concerned
with
the particulars. Hopefully the concept is sound. If not, 
please do

flame my note so no one attempts it.

Be Well,
A-

-Original Message-
From: Mattyasovszky Janos [mailto:m...@matya.hu] Sent: Monday,
March
02, 2009 9:29 AM
To: php-db@lists.php.net
Subject: Re: [PHP-DB] Retrieving Image Location in MySQL

Fortuno, Adam írta:



   //Write a query to pull out the picture's path
   $sql = "SELECT path FROM Image WHERE ID = %s";
   mysql_real_escape_string($value);


Sorry, but this won't work, since you don't map the value of the
escaped $value to the %s, lets say with sprintf()...

Regards,
Matya








 
















--
~
~
Sashikanth Gurram
Graduate Research Assistant
Dep

Re: [PHP-DB] Retrieving Image Location in MySQL

2009-03-07 Thread kesavan trichy rengarajan
t;>>>>> ../ One step back from the script location
>>>>>>>
>>>>>>>
>>>>>>> GR
>>>>>>> Muhsin
>>>>>>>
>>>>>>>
>>>>>>> Sashikanth Gurram wrote:
>>>>>>>
>>>>>>>> Hi,
>>>>>>>> Thanks a lot for the suggestion. It is working fine but there is some
>>>>>>>> problem. When I introduced the piece of code you have suggested into
>>>>>>>> my code, I am getting a space for the picture but nothing is there in
>>>>>>>> that space. It is just blank. I do not know the reason for this. I am
>>>>>>>> just attaching a picture just in case it might give you a better idea.
>>>>>>>> Further, this is the piece of code I have written to display the pic.
>>>>>>>>
>>>>>>>> /echo ">>>>>>> alt='$build' >";/
>>>>>>>>
>>>>>>>> Any help would be greatly appreciated.
>>>>>>>> Thanks,
>>>>>>>> Sashi
>>>>>>>>
>>>>>>>> mrfroasty wrote:
>>>>>>>>
>>>>>>>>> Hello,
>>>>>>>>>
>>>>>>>>> Storing only location of the image in dB wouldnt be any different than
>>>>>>>>> other string/data retrieved from the dB.That means if you have
>>>>>>>>> something
>>>>>>>>> like this in html documents whereby $image_location comes from the dB
>>>>>>>>> It should work without header stuffs
>>>>>>>>>
>>>>>>>>> Example
>>>>>>>>> >>>>>>>> alt="Image" ISMAP>
>>>>>>>>> P:S
>>>>>>>>> Replace $image_location with image location from your dB.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> GR
>>>>>>>>> Muhsin
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> Sashikanth Gurram wrote:
>>>>>>>>>
>>>>>>>>>> Dear all,
>>>>>>>>>>
>>>>>>>>>> I have been trying to retrieve the location of a image from database
>>>>>>>>>> and display the image in the browser using PHP. I have written a sort
>>>>>>>>>> of code for the purpose. All I am getting in my browser after using
>>>>>>>>>> the code is a long set of ASCII characters with the following 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 *237
>>>>>>>>>> *
>>>>>>>>>> I am herewith attaching my code. If anyone can  point out the
>>>>>>>>>> error or
>>>>>>>>>> give some kind of advice that would be really great. The location of
>>>>>>>>>> the image is stored in a table by the name IMAGE under the column
>>>>>>>>>> name
>>>>>>>>>> Location and here in the code, the location is retrieved under the
>>>>>>>>>> varibale name $Location.
>>>>>>>>>>
>>>>>>>>>> thanks,
>>>>>>>>>> Sashi
>>>>>>>>>>
>>>>>>>>>> /
>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>>> Building Name:
>>>>>>>>>>  Select a Building
>>>>>>>>>> Agnew Hall
>>>>>>>>>>Rector Field House
>>>>>>>>>>Richard B. Talbot Educational Resources Center
>>>>>>>>>>Robeson Hall
>>>>>>>>>>Sandy Hall
>>>>>>>>>>Saunders hall
>>>>>>>&g