Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8706257
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T03:34:18+00:00 2026-06-13T03:34:18+00:00

I am trying to make this .php file act as a .png, so I

  • 0

I am trying to make this .php file act as a .png, so I can do e.g. <img src='test.php'> [example]

I added a header as an image and did this:

<?php

/* Start Connection */
[Ignore This]
/* End Connection */

/* Add to counter */
mysql_query("UPDATE counter SET counter = counter + 1");
/* End Add */

/* For Echo */
$count = mysql_fetch_row(mysql_query("SELECT counter FROM counter"));
$hits = $count[0];
/* Create Echo as Null 
* @echo
echo "$hits";
*/

/* End Echo */

//Img Area
$font = "font.ttf";
$image = imagecreatefrompng("hits.png");
$color = imagecolorallocate($image, 255, 255, 255);
imagettftext($image, 15, 0, 10, 24, $color, $font, $hits);
imagepng($image, "test.png");
imagedestroy($image);
header('Content-Type: image/png')
?>

But it just displays a broken image.

This file is img.php

The broken image is img.php

How can I fix this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T03:34:20+00:00Added an answer on June 13, 2026 at 3:34 am

    imagepng($image, "test.png"); if you’re saving the image to a file, why are you expecting it to be output to the browser? If you want it to be output directly, just use imagepng($image);

    Also, the header call needs to be before anything is output.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

image.html - <img src=showImage.php?id=44/> <-- this is the code I'm trying to make work.
I'm trying to make this: 174,myfilename.jpg Into this on the php post process page:
Trying to make this jQuery filter that uses .find case-insensitive. For example, when the
I'm trying to make a request to a website this way : file_get_contents('http://www.yahoo.com/index.php?var=value'); in
I am trying to create a single php file I can use to display
i'm trying to make this address: http://www.mysite.co.uk/Listing/London/34 really look for: http://www.mysite.co.uk/Listing/listed.php?area=London&list=34 behind the scenes.
I'm trying to make custom pages using the new vBulletin 4. My PHP file
I am trying to make this sample program work (defn foo ([x] (foo x
I'm trying to make this regex ^(?!\-\-\sRoaming) to match with -- Roaming but it
I'm trying to make this request to the RunKeeper API : GET /user HTTP/1.1

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.