Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
getting spurious character in captcha...
Old 05-25-2010, 03:18 PM getting spurious character in captcha...
Sleeping Troll's Avatar
Ultra Talker

Posts: 351
Name: Butch Begy
Trades: 0
I have the following script for generating a captcha code and image, for the most part it works fine, but occasionally it generates a spurious character which appears as a square in image, can anybody figure out why, I can't...

Code:
<?php
$length = 8;
$characters = ‘0123456789abcdefghijklmnopqrstuvwxyz’;
$string = ""; 
$file = "../Images/Captcha/Captcha.png";   
$font = "../Fonts/ariblk.ttf";
for ($i = 0; $i < $length; $i++) 
{
    $count = mt_rand(1, strlen($characters));
    $string = $string.$characters[$count];
}
$im = imagecreatetruecolor(148, 60);
$white = imagecolorallocate($im, 255, 255, 255);
$grey = imagecolorallocate($im, 128, 128, 128);
$black = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 148, 60, $grey);
imagettftext($im, 12, 0, 18, 32, $grey, $font, $string);
imagettftext($im, 12, 0, 16, 30, $black, $font, $string);
$emboss = array(array(2, 0, 0), array(0, -1, 0), array(0, 0, -1));
imageconvolution($im, $emboss, 1, 127);
imagepng($im,$file);
imagedestroy($im);
echo (
$string
);
?>
__________________
Sleeping Troll, EMUSE, Mind Expansion...Truly serendipity!
Sleeping Troll is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 05-25-2010, 03:22 PM Re: getting spurious character in captcha...
Plexihost's Avatar
Extreme Talker

Posts: 241
Trades: 0
Have you tried a different font?
__________________
HostMantis
Please login or register to view this content. Registration is FREE

Shared • Reseller • 24/7/365 Support • Instant Activation
CloudLinux • Softaculous • Fantastico • FFMpeg • PHP 5.3
Plexihost is offline
Reply With Quote
View Public Profile Visit Plexihost's homepage!
 
Old 05-25-2010, 03:25 PM Re: getting spurious character in captcha...
Sleeping Troll's Avatar
Ultra Talker

Posts: 351
Name: Butch Begy
Trades: 0
No, but that is a pretty basic font, will try though.
__________________
Sleeping Troll, EMUSE, Mind Expansion...Truly serendipity!
Sleeping Troll is offline
Reply With Quote
View Public Profile
 
Old 05-25-2010, 03:27 PM Re: getting spurious character in captcha...
Plexihost's Avatar
Extreme Talker

Posts: 241
Trades: 0
Yeah, your current font is pretty standard, but I figured it was worth a try.
__________________
HostMantis
Please login or register to view this content. Registration is FREE

Shared • Reseller • 24/7/365 Support • Instant Activation
CloudLinux • Softaculous • Fantastico • FFMpeg • PHP 5.3
Plexihost is offline
Reply With Quote
View Public Profile Visit Plexihost's homepage!
 
Old 05-25-2010, 03:40 PM Re: getting spurious character in captcha...
Sleeping Troll's Avatar
Ultra Talker

Posts: 351
Name: Butch Begy
Trades: 0
h3g1�ovs Hey! you can see it! this is what I get, what is that fffd stuff? btw I did try different fonts, same result, this one is arial.ttf
__________________
Sleeping Troll, EMUSE, Mind Expansion...Truly serendipity!
Sleeping Troll is offline
Reply With Quote
View Public Profile
 
Old 05-25-2010, 03:43 PM Re: getting spurious character in captcha...
Plexihost's Avatar
Extreme Talker

Posts: 241
Trades: 0
Can you provide a link to the page with the captcha?
__________________
HostMantis
Please login or register to view this content. Registration is FREE

Shared • Reseller • 24/7/365 Support • Instant Activation
CloudLinux • Softaculous • Fantastico • FFMpeg • PHP 5.3
Plexihost is offline
Reply With Quote
View Public Profile Visit Plexihost's homepage!
 
Old 05-25-2010, 03:55 PM Re: getting spurious character in captcha...
Sleeping Troll's Avatar
Ultra Talker

Posts: 351
Name: Butch Begy
Trades: 0
No, it is on localhost, I can send a zip...
__________________
Sleeping Troll, EMUSE, Mind Expansion...Truly serendipity!
Sleeping Troll is offline
Reply With Quote
View Public Profile
 
Old 05-26-2010, 03:29 AM Re: getting spurious character in captcha...
Phunk Rabbit's Avatar
Ultra Talker

Posts: 255
Name: John Nerush
Location: Milton Keynes, UK
Trades: 0
That question mark is related to char encoding.
Phunk Rabbit is offline
Reply With Quote
View Public Profile Visit Phunk Rabbit's homepage!
 
Old 05-27-2010, 08:15 AM Re: getting spurious character in captcha...
Extreme Talker

Posts: 181
Name: David Jackson
Trades: 0
just after your for loop add this

PHP Code:
$string utf8_encode($string); 
__________________

Please login or register to view this content. Registration is FREE
davidj is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to getting spurious character in captcha...
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.26704 seconds with 12 queries