I'm trying to make an image which is a chart of some data. The graphics code
on its own works fine - this is a file which in outline is:
<?php
Header ('Content-Type: image/png');
$img = ImageCreate (100, 100);
..... (draw some stuff) ....
ImagePNG( $img );
?>
which is then included in a web page via an <img> tag.
All OK so far.
The problem comes when I want to pull the data from my database rather than
drawing a chart of hard coded dummy data. Naturally this involves including
some other files with database functions in, like:
<?php
Header ('Content-Type: image/png');
require "some.file" ;
$img = ImageCreate (100, 100);
..... (draw some stuff) ....
ImagePNG( $img );
?>
This stops it all working. Internet Explorer now shows a broken image icon
for the image, whether loading the image file directly or via the web page
with the <img> tag. What's in the required file? All the ones I've tried
have caused this problem; the minimal one has some white space, comments,
and a function declaration. (The required files all work OK on other web
pages that aren't generating images, of course.)
What's going on please?
--
Tim Ward - posting as an individual unless otherwise clear
Brett Ward Ltd - www.brettward.co.uk
Cambridge Accommodation Notice Board - www.brettward.co.uk/canb
Cambridge City Councillor 7 2759
Tim Ward wrote: I'm trying to make an image which is a chart of some data. The graphics code on its own works fine - this is a file which in outline is:
<?php Header ('Content-Type: image/png'); $img = ImageCreate (100, 100); ..... (draw some stuff) .... ImagePNG( $img );
which is then included in a web page via an <img> tag.
All OK so far.
The problem comes when I want to pull the data from my database rather than drawing a chart of hard coded dummy data. Naturally this involves including some other files with database functions in, like:
<?php Header ('Content-Type: image/png'); require "some.file" ; $img = ImageCreate (100, 100); ..... (draw some stuff) .... ImagePNG( $img );
This stops it all working. Internet Explorer now shows a broken image icon for the image, whether loading the image file directly or via the web page with the <img> tag. What's in the required file? All the ones I've tried have caused this problem; the minimal one has some white space, comments, and a function declaration. (The required files all work OK on other web pages that aren't generating images, of course.)
What's going on please?
If I had to guess, I'd say that the files you require() or include() either
output something (which is going to be interpreted as image data, and will
cause the image to be invalid) or have some whitespace somewhere outside of
<?php ... ?> (likely after the ?>) that gets outputted, and causes the same
problem. Make sure that all the included files
a) have *nothing* before the <?php, including whitespace
b) output *nothing*
c) have nothing after the ?>, including whitespace, line-returns etc.
"Agelmar" <if**********@c omcast.net> wrote in message
news:bt******** ****@ID-30799.news.uni-berlin.de... If I had to guess, I'd say that the files you require() or include()
either output something (which is going to be interpreted as image data, and will cause the image to be invalid) or have some whitespace somewhere outside
of <?php ... ?> (likely after the ?>) that gets outputted, and causes the
same problem. Make sure that all the included files a) have *nothing* before the <?php, including whitespace b) output *nothing* c) have nothing after the ?>, including whitespace, line-returns etc.
There are quite likely newlines after the ?> in the included files, I'll
check.
--
Tim Ward - posting as an individual unless otherwise clear
Brett Ward Ltd - www.brettward.co.uk
Cambridge Accommodation Notice Board - www.brettward.co.uk/canb
Cambridge City Councillor
Agelmar wrote: Tim Ward wrote: I'm trying to make an image which is a chart of some data. The graphics code on its own works fine - this is a file which in outline is:
<?php Header ('Content-Type: image/png'); $img = ImageCreate (100, 100); ..... (draw some stuff) .... ImagePNG( $img );
<snip>
Also, one more note...
all predefined function names are lowercase. You really should use lowercase
when you write them. As it is right now, function names are
case-insensitive, but there have been a few votes in the past about making
names case sensitive (as it would speed things up a bit), not to mention its
simply better style to use the proper case.
"Agelmar" <if**********@c omcast.net> wrote in message
news:bt******** ****@ID-30799.news.uni-berlin.de... Also, one more note... all predefined function names are lowercase. You really should use
lowercase when you write them. As it is right now, function names are case-insensitive, but there have been a few votes in the past about making names case sensitive (as it would speed things up a bit), not to mention
its simply better style to use the proper case.
Yeah, that's some code I downloaded from somewhere to give me a kickstart
with images, I probably do read the manual properly for stuff I write myself
....
Removing the newlines from after the ?>s in the included files does seem to
make a difference - thanks. (Not quite clear why I didn't get that for
myself, maybe I should only code when sober.)
--
Tim Ward - posting as an individual unless otherwise clear
Brett Ward Ltd - www.brettward.co.uk
Cambridge Accommodation Notice Board - www.brettward.co.uk/canb
Cambridge City Councillor
"Tim Ward" <ti*@brettward. co.uk> wrote in message
news:bt******** ****@ID-154437.news.uni-berlin.de... I'm trying to make an image which is a chart of some data. The graphics
code on its own works fine - this is a file which in outline is:
<?php Header ('Content-Type: image/png'); $img = ImageCreate (100, 100); ..... (draw some stuff) .... ImagePNG( $img ); ?>
which is then included in a web page via an <img> tag.
All OK so far.
The problem comes when I want to pull the data from my database rather
than drawing a chart of hard coded dummy data. Naturally this involves
including some other files with database functions in, like:
<?php Header ('Content-Type: image/png'); require "some.file" ; $img = ImageCreate (100, 100); ..... (draw some stuff) .... ImagePNG( $img ); ?>
This stops it all working. Internet Explorer now shows a broken image icon for the image, whether loading the image file directly or via the web page with the <img> tag. What's in the required file? All the ones I've tried have caused this problem; the minimal one has some white space, comments, and a function declaration. (The required files all work OK on other web pages that aren't generating images, of course.)
What's going on please?
-- Tim Ward - posting as an individual unless otherwise clear Brett Ward Ltd - www.brettward.co.uk Cambridge Accommodation Notice Board - www.brettward.co.uk/canb Cambridge City Councillor
there may be some data output from you included files
turn on output buffering,
then clear the output buffer before you send the image
also, after you send the image, use an exit(); just in case you may have
some blank lines after the last closing ?> tag
--
Mike Bradley http://gzen.myhq.info -- free online php tools
"CountScubu la" <me@scantek.hot mail.com> wrote in message
news:yy******** ********@newssv r27.news.prodig y.com... there may be some data output from you included files
Yes, it was the newlines after the ?>.
I *hate* languages in which the spelling of white space is significant -
you'd have thought that after the disaster of the original makefile syntax
nobody would have dared do that again!!
--
Tim Ward - posting as an individual unless otherwise clear
Brett Ward Ltd - www.brettward.co.uk
Cambridge Accommodation Notice Board - www.brettward.co.uk/canb
Cambridge City Councillor
On Sat, 3 Jan 2004 09:55:41 -0000, "Tim Ward" <ti*@brettward. co.uk> wrote: "CountScubul a" <me@scantek.hot mail.com> wrote in message news:yy******* *********@newss vr27.news.prodi gy.com... there may be some data output from you included files
Yes, it was the newlines after the ?>.
I *hate* languages in which the spelling of white space is significant - you'd have thought that after the disaster of the original makefile syntax nobody would have dared do that again!!
Actually whitespace is not sigificant to PHP - in your case it wasn't even in
the source code at all, it was outside the <?php ?>, and so was literal data to
send to the browser.
Presumably you're not a fan of the Python language then ;-)
--
Andy Hassall (an**@andyh.co. uk) icq(5747695) ( http://www.andyh.co.uk)
Space: disk usage analysis tool ( http://www.andyhsoftware.co.uk/space) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Eric Stein |
last post by:
Hello all,
I've been wondering - how do I make dynamic images in PHP (example - the
PHP and Zend logos when you do phpinfo().)? I have seen it done on several
websites and I want to do it.
Also, is there a correct way to use PHP to retrieve images? The only
way I've ever got this to work is using require(). Here is what I did
(note: it only works with ASCII encoded images, otherwise PHP errors):
<?php
|
by: ima |
last post by:
http://www.kencoffman.com/templates.htm
I've been experimenting with float:left and I've been able to clear
those floats as far as Opera 8.02 and Firefox 1.0.6 but IE6 is a
problem. I've researched a bit and read about a hack but for some
reason I've been unable to get it to work. Perhaps I've missed some
subtle requirement like placed it in the wrong place in my css file.
If you view the page with Opera or Firefox, you'll notice...
|
by: Dom Hicklin |
last post by:
I have created a form onto which images can be dropped and thus added
to the OLE field of a Table (Access 2000 linked to SQL 2000 server).
I use the Stephen Lebans ExportOLE function to do this and it creates
images on my shared drive beautifully!
Being new at this I wondered if there is an easy way of taking the
image whatever it's size when pasted and always exporting it as 66*75?
|
by: Bob Dydd |
last post by:
Hi Everybody
I have an Access 2000 db with a setup for inserting images in records.
I am using the image path only with the actual images stored elswhere
on the hard disc. This works perfectly well with all of Microsoft
developer installed on the system.
The problem is when I give this to a user who has NOT got Access 2000,
ie I just give him an installation that installs a runtime, my
frontend/backend and images, an error says that...
|
by: Peter Lapic |
last post by:
I have to create a image web service that when it receives an imageid
parameter it will return a gif image from a file that has been stored on the
server.
The client will be an asp.net web page that calls the web service to render
a vertical strip of images.
After doing some research I am unable to find some vb.net code that can
assist in what I want to achieve.
The closest thing I found was
| |
by: giladg22 |
last post by:
Hi All,
I need some help resolving a pretty tricky problem. I have a javascript
application running from a CD. The script preloads between 500 to 1000
jpegs (about 40K each) to the IE. The IE immediatly decompresses the
jpegs, essentially using up too much memory.
I have a few limitations working against me:
A) Since the jpegs reside on a CD, it is crucial that I preload them to
the IE in order to not incur the seek time that is...
|
by: tshad |
last post by:
I am trying to use my IIS web server on my local machine for testing my web
site.
The problem is that periodically it will not use the virtual directory for
the root.
This happens for my logon page, for instance.
If I have the following Virtual Directory: Staff.
|
by: shaielinna |
last post by:
<? ob_start();
session_start();
require('../includes/inc.php');
require('../includes/settings.php');
include("../includes/dbconnect.php");?>
<?php
// requires the class
require "../includes/class.datepicker.php";
|
by: swethak |
last post by:
hi ,
i write the code in .htm file. It is in cgi-bin/searches/one.htm.In that i write a form submitting and validations.But validations are not worked in that .htm file. I used the same code in my local system that validations work.plz tell that whats the problem in that.
Here is my code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |