Jump to content

Recommended Posts

I'm using this:

 

<?php

include "header.php";
$Num = mysql_query("SELECT * FROM `users`");
$Num = mysql_num_rows($Num);


// Create a 100*30 image
$im = imagecreate(100, 30);

// White background and blue text
$bg = imagecolorallocate($im, 255, 255, 255);
$textcolor = imagecolorallocate($im, 0, 0, 255);

// Write the string at the top left
imagestring($im, 5, 0, 0, $Num, $textcolor);

// Output the image
header('Content-type: image/png');

imagepng($im);
imagedestroy($im);
?>

 

As an source to make an image with the number of users in my database. Is there any reason why this shouldn't work >.>?

 

btw header.php is connection to MySql.

I tested it without the MySQL and it worked fine, I can only imagine its either that or you don't have the GD library installed on your version of PHP, is it a free host you use?

 

Adam

 

It works when I use a string, or a variable, just not with the MySql variable...

Okay try checking if there's an error with the mysql:

 

$Num = mysql_query("SELECT * FROM `users`") or die(mysql_error());
$Num = mysql_num_rows($Num) or die(mysql_error());

 

Nope, there's no error in the MySql, just checked, and infact I use this same code accept with an echo to show how many users are in the database elsewhere, any other ideas? Dx

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.