bandit8 Posted September 9, 2006 Share Posted September 9, 2006 Hi Everyone,I am trying to get an image verification system working...I have been going through the tutorial at:http://www.php-mysql-tutorial.com/user-authentication/image-verification.phpBut I keep getting the error: Parse error: parse error, unexpected T_STRING in /homepages/41/d171489552/htdocs/image_verification/test.php on line 8This is the code I have:-----<?php session_start(); // generate 5 digit random number $rand = rand(10000, 99999); // create the hash for the random number and put it in the session $_SESSION['image_random_value'] = md5($rand); // create the image $image = imagecreate(60, 30); // use white as the background image $bgColor = imagecolorallocate ($image, 255, 255, 255); // the text color is black $textColor = imagecolorallocate ($image, 0, 0, 0); // write the random number imagestring ($image, 5, 5, 8, $rand, $textColor); // send several headers to make sure the image is not cached // taken directly from the PHP Manual // Date in the past header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // always modified header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // HTTP/1.1 header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: post-check=0, pre-check=0", false); // HTTP/1.0 header("Pragma: no-cache"); // send the content type header so the image is displayed properly header('Content-type: image/jpeg'); // send the image to the browser imagejpeg($image); // destroy the image to free up the memory imagedestroy($image); ?>----It's copied right from the tutorial, so I don't get why it would be giving me an error!Any thoughts/suggestions would be greatly appreciated.Thanksb. Quote Link to comment Share on other sites More sharing options...
ahmed17 Posted September 9, 2006 Share Posted September 9, 2006 change the following code and it will work well[code]header('Content-type: image/gif');[/code]and [code]imagegif($image);[/code] Quote Link to comment Share on other sites More sharing options...
bandit8 Posted September 9, 2006 Author Share Posted September 9, 2006 [quote author=ahmed17 link=topic=107488.msg431346#msg431346 date=1157836059]change the following code and it will work well[code]header('Content-type: image/gif');[/code]and [code]imagegif($image);[/code][/quote]Hi Ahmed, That still gives me the exact same error... its pointing to line 8... I can't see what would be wrong with it..?b. Quote Link to comment Share on other sites More sharing options...
ahmed17 Posted September 9, 2006 Share Posted September 9, 2006 testing on a live web server off in a separate test folder may be it will work well and i test code and give me result*gd in localhost give me also error Quote Link to comment Share on other sites More sharing options...
bandit8 Posted September 9, 2006 Author Share Posted September 9, 2006 [quote author=ahmed17 link=topic=107488.msg431361#msg431361 date=1157838712]testing on a live web server off in a separate test folder may be it will work well and i test code and give me result*gd in localhost give me also error [/quote]I have it on a live server, in a separate folder for testing... Quote Link to comment Share on other sites More sharing options...
jefkin Posted September 10, 2006 Share Posted September 10, 2006 Hi bandit,I don't think this will solve your problem, but may help locate it specifically, as I count it, this is line 8 in your code:[code]$_SESSION['image_random_value'] = md5($rand); [/code]With that error, it seems to me that it's choking on the 'image_random_value'.If I've counted right, then this is just a dummy test, but try putting new lines in the code like this:[code]$rand = $rand; // see if error might be from above then should give this line as error again.$_SESSION['image_random_value'] = md5($rand); [/code]See if or how the line number changes, to pinpoint what is causing the problem. Good Luck.Jeff Quote Link to comment Share on other sites More sharing options...
bandit8 Posted September 11, 2006 Author Share Posted September 11, 2006 I figured out what the problem was...I had copied a section of the tutorial code straight from the browser..and somehow it must have picked up an invisible character... for as soon as I retyped it all manually, it worked fine.Thanks for all the suggestions and trying to help though!-b. Quote Link to comment 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.