al3x8730 Posted September 14, 2008 Share Posted September 14, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/124243-mysql-variables-as-source-for-dynamic-image/ Share on other sites More sharing options...
Adam Posted September 14, 2008 Share Posted September 14, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/124243-mysql-variables-as-source-for-dynamic-image/#findComment-641568 Share on other sites More sharing options...
genericnumber1 Posted September 14, 2008 Share Posted September 14, 2008 It would be better to use select COUNT(*) and you forgot to use imagefill() to make the background white. What is it doing that you think it wouldn't work? Quote Link to comment https://forums.phpfreaks.com/topic/124243-mysql-variables-as-source-for-dynamic-image/#findComment-641569 Share on other sites More sharing options...
al3x8730 Posted September 14, 2008 Author Share Posted September 14, 2008 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... Quote Link to comment https://forums.phpfreaks.com/topic/124243-mysql-variables-as-source-for-dynamic-image/#findComment-641571 Share on other sites More sharing options...
Adam Posted September 14, 2008 Share Posted September 14, 2008 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()); Quote Link to comment https://forums.phpfreaks.com/topic/124243-mysql-variables-as-source-for-dynamic-image/#findComment-641572 Share on other sites More sharing options...
al3x8730 Posted September 14, 2008 Author Share Posted September 14, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/124243-mysql-variables-as-source-for-dynamic-image/#findComment-641591 Share on other sites More sharing options...
Garethp Posted September 15, 2008 Share Posted September 15, 2008 Try imagestring($im, 5, 0, 0, '$Num', $textcolor); Also, try echoing $Num, what is it? Side Note: Check your messages, I sent you one Quote Link to comment https://forums.phpfreaks.com/topic/124243-mysql-variables-as-source-for-dynamic-image/#findComment-641691 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.