PHP Coding
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsPHP RelatedPHP Coding

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old October 10th, 2002, 12:05 PM
cateyes cateyes is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Cyprus
Posts: 68 cateyes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Generating graphics

I need to learn to create graphics on the fly in php4.2.2 so I decided to start by trying to draw a simple line.

I have not had much success.

I have listed the code below. If I include the header, I get an error message that says:

"Cannot add header information - headers already sent by (there is a line reference here for the line that says <?php)"

However, if I don't include the header I get a white page with nothing on it and no errors are generated.

I am a newbie and have no experience with graphics. Can someone please give me a few pointers? I have referred to php.net but I am confused by the advice as it covers so many different versions of php. My end goal is to draw graphs with data on dynamic pages using data from a mySQL Table.

Any advice would be greatly appreciated!

Here is the code:

<?php
Header ("Content-type: image/jpeg");
$image = @imagecreate(200,150) or die ("Cannot Initialize new image stream!");

$gray = ImageColorAllocate($image,204,204,204);
$blue = ImageColorAllocate($image,0,0,255);

ImageLine($image,10,10,15,30,$blue);

ImageJPEG($image);
ImageDestroy($image);
?>

Thank you!

Reply With Quote
  #2  
Old October 10th, 2002, 12:17 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
RE: Generating graphics

Look ok..just make sure there is no whitespace before the first <? ...no spaces, new lines or anything....

Reply With Quote
  #3  
Old October 10th, 2002, 12:43 PM
cateyes cateyes is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Cyprus
Posts: 68 cateyes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: Generating graphics

There is no whitespace, etc. But still no results.

Can you think of anything else that might be causing the problem?
thanks

Reply With Quote
  #4  
Old October 10th, 2002, 12:50 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
RE: Generating graphics

When I run this code here, it runs perfectly. What version of PHP are you using? Can you provide a link to the page that is not working?

Reply With Quote
  #5  
Old October 10th, 2002, 12:55 PM
notepad notepad is offline
Codewalkers Loyal (3000 - 3499 posts)
 
Join Date: Apr 2007
Location: Central, IL USA
Posts: 3,214 notepad User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
Send a message via AIM to notepad
RE: Generating graphics

do you have the GD library installed?

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPHP Coding > Generating graphics


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway