Fixing the “Fatal Error: Call to undefined imagecreate() function” in PHP

The "call to undefined imagecreate() function" normally appears if you try to execute graphic related scripts such as CAPTCHA scripts. To fix this problem, follow these simple steps:

1. Download a copy of PHP zip package from http://php.net/downloads.php.

2. For the sake of example, we will be using PHP 5.2.14 Windows Binary Zip Package.

3. Once you have downloaded the file, Right-Click it>Extract files>In the Winrar Destination path, enter “C:\PHP\” no quotes. If you have previously installed PHP distros just overwrite it.(I’ve assumed here that you have Winrar installed on your computer.)

4. Go to where your PHP file was extracted, in this case in the C:\ directory.

5. Locate php.ini-dist and rename it to php.ini.(Overwite the previous php.ini).



6. Right-click php.ini>Select Open. The following should then appear:



7. Click Edit>Select Find then enter extension_dir in the Find what textbox.



8. Change the line extension_dir=”./” to extension_dir=”C:\PHP\ext”.



9. Click Edit>Find>Enter “gd”(no quotes) in the Find what textbox then click Find Next.



10. Delete the semi-colon(;) before the line ;extension=php_gd2.dll.




11. Click File the Save. You should now be able to execute your captcha scripts without errors. Here is the screenshot of my captcha that I was able to execute effortlessly using these fixes:



12. If you continue to encounter error messages, try restarting your computer.

13. That's all. Ciao!

Changing the text color of an F# Console Application

By default, console texts are displayed in white. To change the text color, use the Console object together with its ForegroundColor Property.

Syntax:
Console.ForegroundColor<-Color value
Color values are stored in the ConsoleColor object and has the following values:

1. Black
2. DarkBlue
3. DarkGreen
4. DarkCyan
5. DarkRed
6. DarkMagenta
7. DarkYellow

8. Gray
9. DarkGray
10. Cyan
11. Red
12. Yellow
13. White
 

To assign the ConsoleColor object as a value of the Console ForegroundColor property, use the following syntax:
Console.ForegroundColor<-ConsoleColor.Colorname
For the sake of example, let us make a console application that will display the text “I am cyan” in cyan text color by following these steps: 1. Click Start>All Programs>Microsoft Visual Studio 2008>Microsoft Visual Studio 2008. 2. Click File>New>Project>Select Visual F# in the project types>Select F# application in the Visual Studio installed templates category. 3. The following should then come into view: 4. Enter the following code after the line “// Learn more about F# at http://fsharp.net “:
//Use the F# Library
open System
//assigns Cyan color to our console text color
Console.ForegroundColor<-ConsoleColor.Cyan
//Create a function named myfunction()
let myfunction()=
//adds an action to our function
//in this case, displays an "I am Cyan" text
printfn "I am Cyan"
//executes our function        
myfunction()
5. Press Ctrl+F5 to execute the console application. You should now see the following output:
6. To add a background color, you can use the BackgroundColor property of the Console object which follows the same syntax as ForegroundColor property. That’s all. Thanks!