Re: [PHP] image problem

2005-03-24 Thread Tom Rogers
Hi,

Friday, March 25, 2005, 3:27:41 AM, you wrote:
WS> Hello,

WS> I really can't figure this out. Can someone help please. I've wasted hours
WS> already with this one.

WS> I'm trying to print image to a web page using fpassthru. Here's the code:

WS> $name = path/to/the/image/folder/img1.jpeg;
WS>  $fp = fopen($name, 'rb');

WS>  // send the right headers
WS>  header("Content-Type: image/jpeg"); //also tested with type pjpeg
WS>  header("Content-Length: " . filesize($name));

WS>  // dump the picture
WS>  fpassthru($fp);

WS> Help Appeciated. Thanks.
WS> -Will

Make sure you don't have any whitespace after the trailing ?> if there
is one, better still get rid of it.
Also I use readfile($name); ... can't remember why


Here is a bit of code I use for passing PDF files which also handles
caching control you can adapt easily for images.


http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Image Problem

2004-06-28 Thread Red Wingate
Read: The best database to store images in is the Filesystem because 
thats what it's for :-)

Raditha Dissanayake wrote:
Monil Chheda wrote:
Hi,
I store images in DB properly... no issues using the
 

Storing an image directly in the database certainly isnt' the proper way 
of doing it :-)
The common practice is just to store the path to the image name in the 
database.

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


Re: [PHP] Image Problem

2004-06-28 Thread Curt Zirzow
* Thus wrote Monil Chheda:
> Hi,
> 
> I store images in DB properly... no issues using the
> following code
> 
> 
> 
> I get an Img with a cross (broken)...
> 
> Whats the error?

its funny, you're error is one click from finding out what it is,
view the source of that image and find it you will...


> 
> Am i missing something?

about 10 or 12 things, but thats far beyond the scope of your
current  problem.


Curt
-- 
First, let me assure you that this is not one of those shady pyramid schemes
you've been hearing about.  No, sir.  Our model is the trapezoid!

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



Re: [PHP] Image Problem

2004-06-28 Thread raditha dissanayake
Monil Chheda wrote:
Hi,
I store images in DB properly... no issues using the
 

Storing an image directly in the database certainly isnt' the proper way 
of doing it :-)
The common practice is just to store the path to the image name in the 
database.

--
Raditha Dissanayake.
-
http://www.raditha.com/megaupload/upload.php
Sneak past the PHP file upload limits.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Image Problem

2004-06-28 Thread Binay
probably the table in which ur storing the images will be having its primary
key set to auto_increment.

If tht is the case then when u delete banner(s) then corresponding id(s)
match won't be found.

i.e say table is having 4 records with ids as follows

id =1
id=2
id=3
id=4

so random number generated would lie between 1 to 4.

now say u delete record with id=2. if this happens then no of  records will
be 3 and hence random number can be 2 for which theres no record in
database. and hence a broken image.




- Original Message -
From: "Monil Chheda" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, June 28, 2004 1:24 AM
Subject: [PHP] Image Problem


> Hi,
>
> I store images in DB properly... no issues using the
> following code
>
> 
> // store.php3 - by Florian Dittmer <[EMAIL PROTECTED]>
> // Example php script to demonstrate the storing of
> binary files into
> // an sql database. More information can be found at
> http://www.phpbuilder.com/
> ?>
>
> 
> Store binary data into SQL
> Database
> 
>
>  // code that will be executed if the form has been
> submitted:
>
> if ($submit) {
>
> // Include constants for database connectivity
> include("constants.php");
>
> // The Database server connection function
> $connection =
> mysql_connect("$host","$db_user","$db_pass") or
> die("Couldn't connect to the MySql Database Server");
>
> // Database selection from the DB server
> $db = mysql_select_db("$db_name",$connection) or
> die("Couldn't select the required Database.");
>
> $data = addslashes(fread(fopen($banner_image,
> "r"), filesize($banner_image)));
>
> $result = MYSQL_QUERY("INSERT INTO banner_details
> (text,banner_image,filename,filesize,filetype) ".
> "VALUES
>
('$banner_description','$data','$form_data_name','$form_data_size','$form_da
ta_type')")
> or die("Couldnt insert banner in the Db");
>
> echo "Banner uploaded";
>
> $id= mysql_insert_id();
> print "This file has the following Database ID:
> $id";
>
> } else {
>
> // else show the form to submit new data:
> ?>
>
> 
> Banner Text:
>  size="40">
>  value="100">
> Image to upload/store in database:
> 
>  value="submit">
> 
>
>
> 
> }
>
> ?>
>
> 
> 
>
> 
>
> I use the foll file to reterieve it...
>
>  /*
> Aim: To fetch random image and its corresponding
> text from the database.
>
> Working: Generate a random number within the range of
> 1 and number of rows present in the DB and then fetch
> the appropriate ROW ID.
>
> Includes: constants.php for DB connectivity
>
> */
> // Include constants for database connectivity
> include("constants.php");
>
> // The Database server connection function
> $connection =
> mysql_connect("$host","$db_user","$db_pass") or
> die("Couldn't connect to the MySql Database Server");
>
> // Database selection from the DB server
> $db = mysql_select_db("$db_name",$connection) or
> die("Couldn't select the required Database.");
>
> /*
> Fetching the number of rows in the DB table
> */
>
> // Reteriving the data from the banners table in the
> DB
> $sql = "SELECT *" .
> "FROM banner_details";
>
> // Executing the Sql select statement
> $result = mysql_query($sql, $connection) or
> die("Couldn't Execute the query.");
>
> // Getting the number of rows affected by the query
> $rows = mysql_num_rows($result);
>
> print("Rows in DB: $rows\n");
>
> /*
> Generating a Random number between 1 and the NUMBER OF
> ROWS returned from the DB Table
> */
>
> // Seeding the random number generator...
> // this thing is usually used to SET an initial value
> for the random number to be generated.
> mt_srand(doubleval(microtime()) * 1);
>
> // The random number is generated...
> $random_number = mt_rand(1, $rows);
>
> print("The random number generated is
> $random_number");
> echo "";
>
> /*
> Fetching the actual data from the DB Table
> */
> $query = "select banner_image, text, filetype from
> banner_details where id=$random_number";
>
> $result = mysql_query($query, $connection) or
> die("Couldn't Execute the query.");
>
> $data = @MYSQL_RESULT($result,0,"banner_image");
> $text = @MYSQL_RESULT($result,0,"text");
> $type = @MYSQL_RESULT($result,0,"filetype");
>
> echo "The banner is ";
>
> Header("Content-type: $type");
>
> echo $data;
>
>
> echo "The assocaited text is : $text";
>
>
> ?>
>
> --
>
> And this for calling it...
>
> 
> echo "";
>
> ?>
>
> I get an Img with a cross (broken)...
>
> Whats the error?
>
> Am i missing something?
>
> Pls help
>
> -Monil
>
> =
> Best Regards,
> Monil Chheda(INDIA)
> http://domains.eliteral.com
> ===
> ===
>
>
>
> __
> Do you Yahoo!?
> Yahoo! Mail - You care about security. So do we.
> http://promotions.yahoo.com/new_mail
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To uns

Re: [PHP] Image problem

2002-10-09 Thread Owen Prime

If the browser still doesn't listen, you can always put a time() arg in you 
img src. ie. ""

David Erickson wrote:

> I had a similar problem and I just put this in front of my php so
> everytime my scripts are called they always tell the browser and any proxy
> servers not to cache anything from me.
> 
> 
> header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");// Date in the past
> header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
>  // always modified
> header("Cache-Control: no-store, no-cache, must-revalidate");  // HTTP/1.1
> header("Cache-Control: post-check=0, pre-check=0", false);
> header("Pragma: no-cache");  // HTTP/1.0
> 
> 
> - Original Message -
> From: "Donahue Ben" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Wednesday, October 09, 2002 1:00 PM
> Subject: [PHP] Image problem
> 
> 
>> I upload an image.  Once I upload this image using the
>> is_uploaded_file function, then writing this image
>> file using the copy function.  Everything seems to
>> work fine.  When i try to update (that is uploading a
>> new file and saving it with the same name as the first
>> file created) it shows the first image instead of the
>> second image.  So what I did was closed my browser,
>> then reopened it, then everything was ok.  So I figure
>> that I have a cache problem.  I then tried using the
>> clearstatcache() function right after I update this
>> image file.  But it did not seem to work.  So am I
>> going to have to close and reopen my browser to see
>> these changes take place or is there something else I
>> can do?
>>
>> Ben
>>
>> __
>> Do you Yahoo!?
>> Faith Hill - Exclusive Performances, Videos & More
>> http://faith.yahoo.com
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>

-- 
Cheers,

Owen Prime
http://www.noggin.com.au

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




Re: [PHP] Image problem

2002-10-09 Thread David Erickson

I had a similar problem and I just put this in front of my php so everytime
my scripts are called they always tell the browser and any proxy servers not
to cache anything from me.


header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");// Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
 // always modified
header("Cache-Control: no-store, no-cache, must-revalidate");  // HTTP/1.1
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");  // HTTP/1.0


- Original Message -
From: "Donahue Ben" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, October 09, 2002 1:00 PM
Subject: [PHP] Image problem


> I upload an image.  Once I upload this image using the
> is_uploaded_file function, then writing this image
> file using the copy function.  Everything seems to
> work fine.  When i try to update (that is uploading a
> new file and saving it with the same name as the first
> file created) it shows the first image instead of the
> second image.  So what I did was closed my browser,
> then reopened it, then everything was ok.  So I figure
> that I have a cache problem.  I then tried using the
> clearstatcache() function right after I update this
> image file.  But it did not seem to work.  So am I
> going to have to close and reopen my browser to see
> these changes take place or is there something else I
> can do?
>
> Ben
>
> __
> Do you Yahoo!?
> Faith Hill - Exclusive Performances, Videos & More
> http://faith.yahoo.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


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




Re: [PHP] Image Problem

2002-10-08 Thread Jason Wong

On Tuesday 08 October 2002 20:08, Mark Colvin wrote:
> I have just upgraded php from 4.0.6 to 4.2.3. Everything works OK apart
> from the line below -
>
> echo '';
>
> The thumbnail.php script uses php functions imagecreate,
> imagecreatefromjpeg, imagecopyresized. The script created a thumbnail OK
> before the upgrade and now I get no image. Is this because php has to be
> configured with the GD Library?

If you had error reporting ON, it would be pretty obvious if that was the 
problem (you would either see the error on screen or it would be in the 
logs).

Use phpinfo() to find out whether PHP was compiled with GD library support.

> If so, can I add this in without having to
> reinstall php? I am running on a Red Hat 7.2 box.

If it wasn't, you would have to reconfigure/recompile PHP (after installing 
the GD library).


-- 
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *

/*
When the blind lead the blind they will both fall over the cliff.
-- Chinese proverb
*/


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




RE: [PHP] Image problem

2001-05-15 Thread Michael O'Neal

On Tue, 15 May 2001 10:23:39 -0700, "Jerry Lake" <[EMAIL PROTECTED]> 
wrote:

>This is how I fixed that same issue
>in the head of my page
>
>if (ereg ("new", $PHP_SELF)) {
>   $header = "   $title = "www.website.com - What's New"; }
>elseif (ereg ("products", $PHP_SELF)) {
>   $header = "   $title = "www.website.com - Products"; }
>else {
>   $header = "   $title = "www.website.com"; }
>
>
>then call the header in in the appropriate place in
>your html 

Thanks Jerry.

This is what I ended up going with, (Thanks to Josh Hoover) and it works 
great!


switch(true)

{
case (stristr($REQUEST_URI, "/about/")):
$headerImage = "/images/hdr_txt_about.gif";
$footerImage = "/images/ftr_txt_about.gif";
break;
case (stristr($REQUEST_URI, "/news/")):
$headerImage = "/images/hdr_txt_news.gif";
$footerImage = "/images/ftr_txt_news.gif";
break;
case (stristr($REQUEST_URI, "/buying/")):
$headerImage = "/images/hdr_txt_buying.gif";
$footerImage = "/images/ftr_txt_buying.gif";
break;
case (stristr($REQUEST_URI, "/selling/")):
$headerImage = "/images/hdr_txt_selling.gif";
$footerImage = "/images/ftr_txt_selling.gif";
break;
case (stristr($REQUEST_URI, "/community/")):
$headerImage = "/images/hdr_txt_community.gif";
$footerImage = "/images/ftr_txt_community.gif";
break;
case (stristr($REQUEST_URI, "/relocation/")):
$headerImage = "/images/hdr_txt_relocation.gif";
$footerImage = "/images/ftr_txt_relocation.gif";
break;


}

Then, just called $headerImage, and $footerImage in the appropriate 
places.

Thanks to all!

mto

Michael O'Neal
Web Producer/ Autocrosser
ST 28 '89 Civic Si
-
 M   A   N   G   O
B  O  U  L  D  E  R 
-
http://www.thinkmango.com
[EMAIL PROTECTED]
p-303.442.1821
f-303.938.8507



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] Image problem

2001-05-15 Thread Jerry Lake

This is how I fixed that same issue
in the head of my page

if (ereg ("new", $PHP_SELF)) {
$header = "

then call the header in in the appropriate place in
your html 

Jerry Lake
Interface Engineering Technician
Europa Communications - http://www.europa.com
Pacifier Online - http://www.pacifier.com


-Original Message-
From: Michael O'Neal [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, May 15, 2001 10:14 AM
To: php
Subject: [PHP] Image problem


Hi,

I'm still pretty new to PHP, and would like help on a solution for a 
problem I have.

I have a website that has 6 different sections.  (about, news, buying, 
selling, community, and relocation)  Each of the sections has it's own 
subfolder in the root directory of the website.  (/about, /news, etc...)  
Each of the sections also has a header image and footer image associated 
with that section.  (hdr_txt_about.gif, ftr_txt_about.gif, 
hdr_txt_news.gif, etc..)

I want to use PHP to "know" what section of the website the user is in, 
and load the appropriate header/footer image.  I know that I need some 
sort of if/then statement, and I know that it has to use the URL to see 
where it is, but I don't know where to implement it, and I'm not quite 
sure how.  The website is setup with an included header that has most of 
the html/javascript, a mostly text file for the content, and an included 
footer that takes care of the rest.  

Any help with this would be greatly appreciated.

Thanks,

mto

Michael O'Neal
Web Producer/ Autocrosser
ST 28 '89 Civic Si
-
 M   A   N   G   O
B  O  U  L  D  E  R 
-
http://www.thinkmango.com
[EMAIL PROTECTED]
p-303.442.1821
f-303.938.8507



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Image problem

2001-01-20 Thread Richard Lynch

> Can anyone tell me how to display both jpg and gif images.  Basically,
> what i've got is:
> 
>
> Now, I know I probably need slashes in there and I played around with it
> but no luck. Where do I put them?

TIP:  Use "View Source" in your browser to see what the IMG tag looks like.

I suspect you've forgotten that you're not in PHP mode, and are just sending
a very oddly-named image tag, literally:
"$filedir/$CUserName"

Since the quotes are going there, I guess HTML is going to ignore the .jpg
part, or treat it as an unkown attribute.

I'm guessing you want:





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]