/    Sign up×
Community /Pin to ProfileBookmark

gd image generation failing on one site working on another both same host same setup

I am having some trouble with gd image creation

I have some code that works

[CODE]$pic = “donationmeter/imagesadv/donation-meter0.png”;
header(“Content-type: image/png”);
$im = imagecreatefrompng($pic); /* Attempt to open */
//$bg = imagecolorallocate($im, 255, 255, 255);
$black = imagecolorallocate($im, 0, 0, 0);
$red = imagecolorallocate($im, 255, 0, 0);
$green = imagecolorallocate($im, 0, 205, 0);
$blue = imagecolorallocate($im, 0, 0, 255);
//$goal = number_format ($goal, 2);
$stringa = “Goal : “;
$stringb = $cursym.$goal;
if($new_value2<$goal) {
$redgreena = imagecolorallocate($im, 0, 205, 0);
} else {
$redgreena = imagecolorallocate($im, 255, 0, 0);
}
$string2a = “Donated : “;
$string2b = $cursym.$new_value2;
$red = imagecolorallocate($im, 255, 0, 0);
$string3a = “PayPal”;
$string3b = “Fees”;
$string3c = “:”;
$string3d = $cursym.$fees;
$left = $goal-$total;
$left = number_format($left, 2);
//$left = number_format($left, 2);
if(eregi(“-“,$left)) {
$redgreenb = imagecolorallocate($im, 0, 205, 0);
} else {
$redgreenb = imagecolorallocate($im, 255, 0, 0);
}
$string4a = “Left : “;
$string4b = $cursym.$left;
$string5a = $res.”%”;
$string5b = ” Of Our Goal”;
if($res<100) {
$redgreenc = imagecolorallocate($im, 255, 0, 0);
} else {
$redgreenc = imagecolorallocate($im, 0, 205, 0);
}

if($res<3) {
$string6 = “Donations Needed!”;
} elseif(($res<35) && ($res>=3)) {
$string6 = ” Getting There!”;
} elseif(($res<50) && ($res>=35)) {
$string6 = “Almost Half Way!”;
} elseif(($res<70) && ($res>=50)) {
$string6 = “Half Way There!”;
} elseif(($res<100) && ($res>=70)) {
$string6 = “Almost There Now!”;
} elseif($res>=100) {
$string6 = “We Did It YAY!”;
}

$px = (imagesx($im) – 21 * strlen($string5b)) / 2;
imagestring($im, 2, 13, 35, $stringa, $black);
imagestring($im, 2, 55, 35, $stringb, $green);
imagestring($im, 2, 13, 55, $string2a, $black);
imagestring($im, 2, 72, 55, $string2b, $redgreena);
imagestring($im, 2, 13, 75, $string3a, $black);
imagestring($im, 2, 13, 88, $string3b, $black);
imagestring($im, 2, 60, 78, $string3c, $black);
imagestring($im, 2, 72, 78, $string3d, $red);
imagestring($im, 2, 13, 108, $string4a, $black);
imagestring($im, 2, 54, 108, $string4b, $redgreenb);
imagestring($im, 2, $px, 128, $string5a, $redgreenc);
imagestring($im, 2, 44, 128, $string5b, $black);
imagestring($im, 2, 16, 148, $string6, $blue);
imagepng($im);
imagedestroy($im);[/CODE]

This successfully displays an image and puts a bit of text in it in places etc

However the script im creating has some more php code above this that includes a settings file and opens a database connection does some calculations based on the database contents etc

It successfully works on my own site but someone else who is using it is having problems and i cannot figure out why

If i use just the bit of code that generates the image it works fine, but if i have the include statement at the top i get the following error

[QUOTE]

Warning: Cannot modify header information – headers already sent by (output started at /home/content/etc/etc/etc/donationmeter/dbsettings.php:1) in /home/content/etc/etc/etc/test2.php on line 10
&#65533;PNG IHDR&#65533;J,&#65533; IDATH&#65533;&#65533;&#65533;}t&#65533;u’x&#65533;{U&#65533;&#65533;&#65533;$&#65533;dD&#65533;&#65533;&#65533?Hdggc&#65533;&#65533;&#65533;b'{b&#65533;&#65533;&#65533;CV<1&#65533;&#65533;d&#65533;xvp&#65533;&#65533;&#65533;dg&#65533;&#65533;&#65533;&#65533;&#65533; &#65533;&#65533;&#65533;$&#65533;&#65533;&#65533;G&#65533;&#65533;&#65533;&#65533;<&#65533;&#65533;&#65533;&#65533;h&#65533;&#1873;&#65533;&#65533;2&#65533;&#65533;lGTb&#65533;&#65533;&#65533;o&#65533;&#65533;@wU&#65533;w&#65533;&#65533;q&#65533; &#1869;&#65533;&#65533;n&#65533;M&#65533;~&#65533;&#65533;&#65533;_U&#65533;WU]&#65533;&#65533;&#65533;&#1903;&#65533;”E&#65533?R&#65533;H&#65533;”E&#65533?R&#65533;H&#65533;i&#65533;[})&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#492;&#65533;&#65533;&#65533;&#65533;zz&#65533;|&#65533;&#65533;}&#65533;&#65533;&#530;1&#65533;Zk&#65533;&#65533;&#65533;&#65533;&#65533;&#1641;&#65533;&#65533;W&#65533;&#65533;&#43774;&#65533;&#65533;&#65533;&#65533; H&#65533;&#65533;9&#65533;&#65533;&#65533;&#65533;&#65533;A&#65533;&#65533;&#65533;&#65533;&#65533;?&#65533;&#65533;A&#65533;&#65533;&#65533;&#1515;W?&#65533;@L<&#65533;&#65533;&#1651;g3&#65533;&#65533;&#65533;&#65533;&#65533;k&#65533;&#65533;&#65533;y&#65533;”EW&#65533;&#65533;&#65533;&#65533;#&#65533;&#529;#G^}&#65533;&#65533;W&#65533;q&#65533;/&#65533;pa&#65533;X2&#65533; &#65533;1606b&#65533;&#65533;&#65533;l&#65533;#&#25656;l&#65533;S&#65533;Tn&#1848;q&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;Go&#65533;m&#65533;i&#65533?&#65533;^_&#65533;&#65533;&#65533;px?&#65533;o&#65533;&#65533;7c&#65533;M&#341;y&#65533;z&#65533;&#65533;Õy&#65533;&#65533;,&#65533;&#65533;:z6&#65533;}&#65533;&#65533;_&#65533;&#65533;?&#65533;?&#65533;~&#65533;`&#65533;/h&#1782;&#65533;&#65533;l&#65533;&#65533;4XK&#780;&#65533;&#65533;&#65533;”7&#65533;&#65533;&#65533;&#65533;&#65533;u/–]&#65533;vm&#65533;?}&#65533;&#21965;1&#65533;z?w.:I&#65533;&#65533;0&#65533;&#65533;O&#65533;&#65533;&#65533;&#65533;q&#65533;Mx&#65533;U&#65533;&#65533;&#65533;$^&#65533;&#65533;/&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;y&#65533;&#1057;&#65533;&#65533;.b&#460;&#65533;Y)&#65533;j/&#65533;&#65533;&#65533;1&#65533;w&#65533;}&#65533;&#65533;&#65533;>&#65533;&#65533;&#65533;|&#65533;&#65533;&#65533?&#65533;3t:&#65533;~&#65533;Ax8&#2001;&#65533;n’&#65533;x &#65533;&#65533;&#65533;_&#65533;&#65533;C|&#65533;&#65533;~m&#65533;w&#65533;&#65533;&#1783;o&#990;&#65533;3&#65533;R&#65533;}= &#65533;@6&#65533;&#65533;&#65533;&#65533;&#2023;@b0&#65533;”&#65533;&#65533?&#65533;&#65533;&#65533;&#65533;^ &#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;_&#65533;&#65533;&#65533;&#65533;5&#65533;&#65533; vC8&#65533;&#65533;&#65533;<&#65533; &#1563;&#65533;&#65533;&#65533;&#65533;f8&#65533;O<w&#65533;&#65533;+&#65533;P&#60708;&#65533;¿&#65533;&#65533;O=&#65533;&#65533;c&#65533;&#65533;&#65533;&#65533;&#65533;&#1566;{&#65533;&#65533;f3&#65533;X “&#65533;y&#65533;@&#65533;L&#65533;&#65533; &#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;C”&#65533;&#65533;R&#65533;&#65533;&#65533;&#65533;s&#1022;&#65533;&#65533;x&#65533;C&#65533;&#65533;v&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;|>?66&#65533;&#65533;&#65533;gff&#65533;&#65533;&#65533;Baxxx“&#2935;&#65533;*&#65533;Jug <&#65533;&#65533;3&#65533;{&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;fff*&#65533;&#65533;k&#65533;&#65533;&#65533;&#65533;&#1031;>4==&#65533;&#65533;&#65533;$&#65533;N}&#65533;&#65533;O&#65533;&#65533;&#65533;&#65533;Å&#65533;w&#65533;w&#65533;&#65533;&#65533;u 1e&*&#65533;qiz&#65533;ÖB&#65533;//&#65533;W^&#65533;&#1592;&#65533;&#44510;y&#43623;&#65533;&#65533;&#65533;&#65533;&#925;;&#65533;&#1693;&#65533;d&#65533;r%@T&#65533;&#65533;#sM&#65533;C&#65533;5&#7402;&#65533;FU%QAD@D&#65533; S&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;_&#65533;q[&#616;3g&#65533; NOO?&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;ò]*&#65533; etc etc etc

[/QUOTE]

The settings file just contains a few lines of $somevariable = “Some content”;

Line 10 which it refers to in the error is the line starting header(

I have no idea why this script works on my site but not on this other persons site

I have checked evrything i can, both sites are hosted with godaddy on linux hosting with identical configurations from what i can tell

Can anyone shed any light on what is happening and why it is not working?

Thanks in advance

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@scragarMar 09.2008 — apparantly you have some content in

/home/content/etc/etc/etc/donationmeter/dbsettings.php on line 1
output started at /home/content/etc/etc/etc/donationmeter/dbsettings.php:1[/quote]

just do a quick check for new lines and/or spaces before you open PHP tags.
Copy linkTweet thisAlerts:
@BWWebDesignsauthorMar 09.2008 — I checked my dbsettings.php file and this is what it contains

<?PHP

$dbhost = "";

$dbusername = "";

$dbpass = "";

$dbname = "";

$cursym = "$";

$dateformat = "jS M Y";

$zone=3600*-5;

$lastxdonations = "10";

$CompanyName = "";

$websiteURL = "";

$CompanyEmail = "";

$goal = "15000";

?>[/QUOTE]


With info filled in for the site and db settings

So i dont see any new lines or any errors that you mentioned

Plus this exact same script with no modification works on one site but ont on the other

Both sites are hsoted through the same company as previously mentioned

Thats what i didnt uderstand i knew what the error message meant but i couldnt see anything in the dbsettings.php file thta would cause that error, no echo statements, no newlines before or after the php tags or anything
×

Success!

Help @BWWebDesigns spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.28,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...