Hi Guys,
Im trying to write a script that takes variables from mysql database and adds them to an image. The easiest way i could think of doing this is modifying a captcha script I made (with help from here, which works perfectly).
I’m having a problem though. I have included the code below. I have assumed we are already connected to the database.
[php]<?php
function getNames()
{
$result=mysql_query(“select screen_name from login”);
while ($row = mysql_fetch_array($result)) {
echo $row[‘screen_name’];
}
}
function printNames()
{
echo getNames();
}
$string= printNames();
/*
Now for the GD stuff, for ease of use lets create
the image from a background image.
*/
$captcha = imagecreatefrompng("./frankie.png");
/*
write content from mysql to image
*/
imagestring($captcha, $string);
/*
Output the image
*/
header(“Content-type: image/png”);
imagepng($captcha);
?>[/php]
The problem is with my functions. if i change my $string to
[php]<?
$string=“word1, word2, word3”;[/php]
It works perfectly, I just can’t seem to get it to work with variables.
Any help would be appreciated!
Regards,
Sam