Image Error - Image Verification

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mattmcb
Forum Commoner
Posts: 27
Joined: Sun Jan 25, 2004 3:34 pm

Image Error - Image Verification

Post by mattmcb »

I received the following error:

Warning: imagepng(): Unable to open 'verify.jpg' for writing in /home/seekide/public_html/storegroup/sg_forum/venture.php on line 47

Here is the code...

Code: Select all

// Image Verification START
/*header*/ 
//Header("Content-Type: image/png"); 

/* initialize a session. */ 
session_start(); 

/*We'll set this variable later.*/ 
$new_string; 

/*register the session variable. */ 
session_register('new_string'); 

/*You will need these two lines below.*/ 
//echo "<html><head><title>Verification</title></head>"; 
//echo "<body>"; 
/* set up image, the first number is the width and the second is the height*/ 
$im = ImageCreate(200, 40);  

/*creates two variables to store color*/ 
$white = ImageColorAllocate($im, 255, 255, 255); 
$black = ImageColorAllocate($im, 0, 0, 0); 

/*random string generator.*/ 
/*The seed for the random number*/ 
srand((double)microtime()*1000000);  

/*Runs the string through the md5 function*/ 
$string = md5(rand(0,9999));  

/*creates the new string. */ 
$new_string = substr($string, 17, 5); 

 /*fill image with black*/ 
ImageFill($im, 0, 0, $black); 

 /*writes string */ 
ImageString($im, 4, 96, 19, $new_string, $white); 

/* output to browser*/ 
***LINE 47*** ImagePNG($im, "verify.jpg"); 
ImageDestroy($im);  
// Image Verification END
Can someone help?
User avatar
DuFF
Forum Contributor
Posts: 495
Joined: Tue Jun 24, 2003 7:49 pm
Location: USA

Post by DuFF »

Um, I think to output a .PNG the file has to be .PNG :idea:
mattmcb
Forum Commoner
Posts: 27
Joined: Sun Jan 25, 2004 3:34 pm

Post by mattmcb »

I get the same error even with that extension.
Post Reply