Paldo Posted June 7, 2009 Share Posted June 7, 2009 Hi I have a problem to make captch working. It says Warning: imagettftext(): supplied argument is not a valid Image resource in /3w/euweb.cz/p/parobek/captcha.php on line 38 <html> <body> <?php function rand_str($length = 5, $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890') { // Length of character list $chars_length = (strlen($chars) - 1); // Start our string $string = $chars{rand(0, $chars_length)}; // Generate random string for ($i = 1; $i < $length; $i = strlen($string)) { // Grab a random character from our list $r = $chars{rand(0, $chars_length)}; // Make sure the same two characters don't appear next to each other if ($r != $string{$i - 1}) $string .= $r; } // Return the string return $string; } $retazec = rand_str(); echo $retazec; $captcha = @imagecreatefrompng('captcha.png'); $font = 'arial.ttf'; // THIS IS THE LINE THAT WARNING REFERS TO imagettftext($captcha, 20, 0, 10, 20, $black, $font, $retazec); ?> </body> Quote Link to comment https://forums.phpfreaks.com/topic/161272-imagettftext-problem/ Share on other sites More sharing options...
.josh Posted June 7, 2009 Share Posted June 7, 2009 Your error tells you you are using an invalid image resource. So look at your image resource. Maybe captcha.png doesn't exist. Maybe you spelled it wrong or forgot the path. It doesn't help that you are suppressing any errors that might show up, putting that @ in front of it. Quote Link to comment https://forums.phpfreaks.com/topic/161272-imagettftext-problem/#findComment-851010 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.