Fatal Error: Call to undefined function mysql_connect() – PHP5 doesn’t support MySQL by default??!!

April 1, 2008

This is a follow-up of the post below. I boot up my computer today and tried logging into my PHP site. Nothing appears. Uh, uh. What could be the problem this time? Yesterday it was OK.

So I checked the Apache error log, and found this: “PHP Fatal error: Call to undefined function mysql_connect()”. What the….

Googled the problem, and it turns out that PHP 5 does not enable MySQL support by default. Uh uh.. what are they thinking? Why do they don’t automatically enable it like the previous PHP version? Do they think they own PHP? Uh uh.. oh well yes they do.. [Anyway here’s the link to the reasons why they decide not to enable and bundle MySQL by default].

So here’s what I did to remedy the problem, hope it will be of help to anyone out there.

  1. Tried adding the MySQL function through PHP’s Windows Add/Remove programs, but it seems the PHP installer doesn’t have this feature. So it seems the easiest is to uninstall PHP, and reinstall PHP back with the MySQL feature.
  2. So I run PHP installer, and choose to install all MySQL related function/libraries.
  3. Don’t forget to point Apache’s configuration file correctly (httpd.conf) when asked. Mine resides in “I:\Program Files\Apache Software Foundation\Apache2.2\conf”
  4. Complete the installation and restart your computer as suggested by the installer. That’s it.

Alhamdulillah, thank God. My PHP + MySQL + Apache works perfectly well now.

The only thing I hate is, usually all this kind of ‘small’ but annoying and important stuff tends to take a long time to be fixed. (I mean all the installing and uninstalling and restarting the computer part…)

Entry Filed under: Technology. Tags: , , , , , .

9 Comments Add your own

  • 1. Vishwajeet Singh  |  July 19, 2008 at 8:48 am

    Hi,

    Thanks; that really helped.

    Reply
  • 2. imin83  |  July 22, 2008 at 9:03 am

    welcome. Glad to know that post helped you :)

    Reply
  • 3. Runi  |  July 22, 2008 at 7:40 pm

    I have been fighting this problem for days until I saw you post and now I got PHP and MySQL talking, finally thanks to you.
    Thanks alot.
    :-)

    Reply
  • 4. imin83  |  July 23, 2008 at 7:48 am

    welcome,too, runi :)

    Reply
  • 5. usha  |  September 20, 2008 at 9:21 am

    I am new to PHP …I am getting the following problem when working with PHP

    Fatal error: Call to undefined function mysql_connect() in F:\php\php works\phpmysql.php on line 5

    Please help me ASAP

    Reply
  • 6. kbrick  |  October 10, 2008 at 12:32 pm

    Nice one …

    Stoopid confusing documentation got me nowhere but this really helped … saved me a lot of work …

    Cheers !!

    Reply
  • 7. Lukas  |  March 11, 2009 at 11:14 pm

    Thank You , I spend last 5h try to find any solution, It’s working now!Thankssssssssss!

    Reply
  • 8. Swati  |  August 17, 2009 at 8:10 am

    I have run PHP installer (5.2.10) selected all MySQL related function/libraries. But its not asking for Apache’s configuration file and directly askin me to install.

    Please help me..

    Reply
  • 9. Yawar Saeed Khan  |  October 21, 2009 at 12:36 pm

    any ideas how to troubleshoot this very same issue in Linux??

    Reply

Leave a Comment

Required

Required, hidden

Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Trackback this post  |  Subscribe to the comments via RSS Feed


Calendar

April 2008
M T W T F S S
« Mar   Jul »
 123456
78910111213
14151617181920
21222324252627
282930  

Most Recent Posts