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

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

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…)


  1. July 19, 2008 at 8:48 am | #1

    Hi,

    Thanks; that really helped.

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

    welcome. Glad to know that post helped you :)

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

    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.
    :-)

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

    welcome,too, runi :)

  5. September 20, 2008 at 9:21 am | #5

    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

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

    Nice one …

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

    Cheers !!

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

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

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

    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..

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

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

  10. imin83
    November 10, 2009 at 3:48 am | #10

    hmmm, sorry saeed khan, never tried this on linux.. but I think you can download the full php file, and compile it with mysql support

  1. No trackbacks yet.