Sunday, December 30, 2007

Fatal error: Call to undefined function: mysql_connect()

Hello everybody!

I've finally got solved the splinter for me! Here are the steps to get rid of it.

What I did first was reinstalling php by a new way.

I have zipped version of php-5.0.2-Win32.

I created a new folder php on c: disk and put all the unzziped files into it.

I deleted files I had copied before from C:\windows\system32. libmysql.dll libmysqli.dll php5apache2.dll php5apache.dll php5ts.dll php_mysql.dll

In the Next step I opened a config. file 'httpd.conf' for apache (i have ver.2.0.52) and added this content into the bottom of the page.

LoadModule php5_module 'c:/php/php5apache2.dll'

AddType application/x-httpd-php .php

PHPIniDir 'C:/php'

1-st line indicates where the module needed for apache to load php is located

2-nd line indicates the type of php script whether it php or php3 e.t.c

3-d line indicates where your php.ini file is located (the path where apache is have to look for it) Saved and close it.

Restarted the apache.

After that I went to c:\php, located 'php.ini-recommended' file, made a copy of it and renamed the original one into php.ini. Since now my php started to work, but without mysql.

In the next step, I opened php.ini file, found a line extension_dir = './' and changed it for extension_dir = 'C:\php\ext' (to find it fast, press ctrl+f on your keyboard, make sure you have clicked your mouse at the start of the page, to make it search from the top.).

Then I found a line ;extension=php_mysql.dll and removed the semicolon in the begining. Saved the document. Restarted the apache.

After all, I ran the test.php file and finally got Mysql info. If you already got the page opened, don't click go button, refresh the page. I believe it will work with you too.

WAMP Installation TIPS

Dear Reader,

I was trying to install PHP on Windows, With Apache as web server and My SQl as backend system. I want to install a open source software weberp(www.weberp.org) on my localhost. I worked on PHP4 so earlier there was an installer for the PHP avialable. When i read the installation guide on PHP Documentation it was noted that "Manual Installation is the best choice". I have struggled with the installation steps but finally i installed the PHP5.2.5 sucessfully on my machine. Steps that i followed are mentioned below.


1. Go to the PHP Site: www.php.net and download the php5 version into your softwares store directory.
Example: I store all my softwares under D:/Softwares/PHP. My operating System is on C:/ only.You will get a zip file.

2. Create a directory under C drive as C:/PHP. Paste the zip file and extract here. You willget all the dll's and other files

3. Copy the php.ini-recommended file and paste it in your C:/WINT directory and change the extension from php.ini-recommended into php.ini

4. Go to the Control Panel->System->Advanced tab

5. Click on Environment Variables. There will be two sections one is for "User variables" and another one is "System Variables". Under System Variables you will find the Path.

6. Double click on that path and add these lines in the front:C:\php;C:\php\dev;
C:\php;C:\php\dev;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;

7. Under System Variables only you can find "New" button. Click on that new button entervariable name as "PHPRC" and Variable Value as "C:\WINT"

8. Click on OK and restart the Computer.

9. Open the php.ini under C:/WINT directory and edit the following line like this:
from extension_dir = "./" into extension_dir = "C:/php5/ext"
To run on Apache Steps to be followed

10. Open the httpd.conf file under conf directory.11. Add these lines after LoadModules list
LoadModule php5_module "c:/php/php5apache2_2.dll"
AddHandler php5-script php
# configure the path to php.ini
PHPIniDir "c:/php/"

ScriptAlias /php/ "c:/php/"
AddType application/x-httpd-php .php

# For PHP 5
Action application/x-httpd-php "/php/php-cgi.exe"

12. Restart the computer.

13. Go to the Notepad and type this:
Save this file as testphp.php under htdocs of your apache directory.

14. type in the browser "http://localhost:8080/testphp.php". If you get your php set-upinformation then it is installed fine.


Any Queries i will be reaching you on meduriphani@yahoo.co.in

I have an intermediate knowledge on PHP. So please update if there is anything wrong on this message.

--By Phanendra Kumar Meduri