hi all i am getting following error while i am using php 5.2.12 and mysql4.1 in windows

Fatal error: Call to undefined function mysql_connect()

please help me to solve my problem

thanks in advance

    Run a phpinfo() to see if the php_mysql extension module is loaded.
    If it is not, you should activate mysql extension.
    For example in php.ini:
    extension=php_mysql.dll

    <?php
    
    phpinfo();
    
    ?>

      Moved to Install forum. If enabling the "extesion=" line in your php.ini file doesn't work, read over the FAQ stickied at the top of this forum (specifically, the post entitled "2. PHP5 :: Can't use mysql_*() functions").

      If neither of those solves your problem, let us know.

        hi halojoy
        i am sending you following files containing my phpinfo files

          Thanks, but that does not show.

          Run this script I have made.
          Call the page: extensions.php and run it.

          <?php // extensions_list.php
          
          $list = get_loaded_extensions();
          $list2 = array_map('strtolower',$list);
          sort($list2);
          echo '<pre>'.print_r($list2,true).'</pre>';
          
          ?>

          If you have not [xx] => mysql
          on the list,
          then you have to activate php_mysql.dll
          in your php.ini
          change
          ;extension=php_mysql.dll
          to
          extension=php_mysql.dll

            hi halojoy
            my problem is still not solved
            i am sending php.ini and the extensions_list php output and httd.conf

              1. the list of extensions in my script
                shows you have not mysql and not mysqli extensions loaded

              2. your php.ini shows that BOTH should be loaded
                because this php.ini is correct

                ;extension=php_mime_magic.dll
                ;extension=php_ming.dll
                ;extension=php_msql.dll
                ;extension=php_mssql.dll
                extension=php_mysql.dll
                extension=php_mysqli.dll

                ;extension=php_oci8.dll
                ;extension=php_openssl.dll
                ;extension=php_pdo.dll
                ;extension=php_pdo_firebird.dll

              3. httpd.conf show that the php.ini used by *Apache is inside:

                LoadModule php5_module "C:\php\php5apache2.dll"
                AddType application/x-httpd-php .php
                PHPIniDir "c:/php"

              You should change
              PHPIniDir "to your php directory, which inlcudes your php.ini file"
              The php.ini you sent me.

              It happens sometimes, that Apache will use some old php.ini
              somewhere else in your PC
              where it is not where you think it is

              Running a phpinfo()

              <?php
              
              phpinfo();
              
              ?>

              will tell you which php.ini is being used:
              It is called Loaded Configuration File

              Loaded Configuration File C:\Program\PHP\php.ini

                2 years later

                hi! im a newbie in setting up php 5, apache and mysql. please bear with me, please...need a help.

                Im using php 5.2.17, apache 2.2 and mysql 5.1.42. I

                my php codes are working in loading some pages, but when I tried connecting to MySQL, i got the same error. "Fatal error: Call to undefined function mysql_connect()"

                when i run test.php which has "<?php

                phpinfo();

                ?> "
                i have

                C:\php\php.ini for the Loaded Configuration File

                my php.ini is configured with:

                extension_dir = "C:\php\ext"

                extension=php_pdo.dll
                extension=php_pdo_mysql.dll
                extension=php_mysql.dll
                extension=php_mysqli.dll

                my libmysql.dll is in c:\php

                my httpd.conf has
                LoadModule php5_module "C:/php/php5apache2_2.dll"
                AddType application/x-httpd-php .php
                PHPIniDir "C:/php"

                I run the code:
                <?php // extensions_list.php

                $list = get_loaded_extensions();
                $list2 = array_map('strtolower',$list);
                sort($list2);
                echo '<pre>'.print_r($list2,true).'</pre>';

                ?>

                and it doesnt show the mysql.

                any help would be highly appreciated.

                  So did you read the thread you replied to?

                    More specifically, I don't see any mention of you verifying that the PHP installation directory is in your system's PATH environment variable. Have you done that? (If not, if you don't know, my FAQ entry here talks about this towards the end of the post.)

                    EDIT: Possibly even more important would be the preface to my FAQ entry:

                    bradgrafelman;10805646 wrote:

                    Let me preface this FAQ by suggesting you ditch the MySQL extension - hey, the PHP team already did, that's why it's not enabled by default anymore! - and instead use a more robust set of functions/classes, such as [man]MySQLi[/man] or [man]PDO[/man].

                      Weedpacket;10995667 wrote:

                      So did you read the thread you replied to?

                      yup, I did before and tried everything before I posted my message here. 🙂

                        bradgrafelman;10995675 wrote:

                        More specifically, I don't see any mention of you verifying that the PHP installation directory is in your system's PATH environment variable. Have you done that? (If not, if you don't know, my FAQ entry here talks about this towards the end of the post.)

                        EDIT: Possibly even more important would be the preface to my FAQ entry:

                        Thank you for your immediate reply!

                        the system's PATH environment variable adding of c:\php work. 🙂

                          Please consider marking your thread RESOLVED using the link under "Thread Tools" on the bar above the first post. Thank you.

                            dalecosp;10995904 wrote:

                            Please consider marking your thread RESOLVED using the link under "Thread Tools" on the bar above the first post. Thank you.

                            Since (s)he hijacked an old thread, I doubt (s)he is able to do that. (However I'm going to mark it resolved anyway due to the thread necromancy plus the fact that this issue has been resolved a few times over.)

                              3 years later
                              bradgrafelman;10995911 wrote:

                              Since (s)he hijacked an old thread, I doubt (s)he is able to do that. (However I'm going to mark it resolved anyway due to the thread necromancy plus the fact that this issue has been resolved a few times over.)

                              ERROR: Call to undefined function mysqli_connect(),
                              I have tried all of the following :
                              1) set c:\php in path
                              2) checked phpinfo() see below it said loaded configuration file "C:\php\php.ini"
                              3) uncommented extension: php_mysql_...dll and php_mysqli.dll
                              4) check extension_dir =ext;

                              Apache2.2
                              PHP5.4.23

                              Really appreciate any help!!!

                              System Windows NT 6.1 build 7601 (Windows 7 Home Premium Edition Service Pack 1) i586
                              Build Date Dec 11 2013 00:52:57
                              Compiler MSVC9 (Visual C++ 2008)
                              Architecture x86
                              Configure Command cscript /nologo configure.js "--enable-snapshot-build" "--disable-isapi" "--enable-debug-pack" "--without-mssql" "--without-pdo-mssql" "--without-pi3web" "--with-pdo-oci=C:\php-sdk\oracle\instantclient10\sdk,shared" "--with-oci8=C:\php-sdk\oracle\instantclient10\sdk,shared" "--with-oci8-11g=C:\php-sdk\oracle\instantclient11\sdk,shared" "--enable-object-out-dir=../obj/" "--enable-com-dotnet=shared" "--with-mcrypt=static" "--disable-static-analyze" "--with-pgo"
                              Server API Apache 2.0 Handler
                              Virtual Directory Support enabled
                              Configuration File (php.ini) Path C:\Windows
                              Loaded Configuration File C:\php\php.ini
                              Scan this dir for additional .ini files (none)
                              Additional .ini files parsed (none)
                              PHP API 20100412
                              PHP Extension 20100525
                              Zend Extension 220100525
                              Zend Extension Build API220100525,TS,VC9
                              PHP Extension Build API20100525,TS,VC9
                              Debug Build no
                              Thread Safety enabled
                              Zend Signal Handling disabled
                              Zend Memory Manager enabled
                              Zend Multibyte Support disabled
                              IPv6 Support enabled
                              DTrace Support disabled
                              Registered PHP Streams php, file, glob, data, http, ftp, zip, compress.zlib, phar
                              Registered Stream Socket Transports tcp, udp
                              Registered Stream Filters convert.iconv., mcrypt., mdecrypt., string.rot13, string.toupper, string.tolower, string.strip_tags, convert., consumed, dechunk, zlib.*

                                [0] => apache2handler
                                [1] => bcmath
                                [2] => calendar
                                [3] => core
                                [4] => ctype
                                [5] => date
                                [6] => dom
                                [7] => ereg
                                [8] => filter
                                [9] => ftp
                                [10] => hash
                                [11] => iconv
                                [12] => json
                                [13] => libxml
                                [14] => mcrypt
                                [15] => mhash
                                [16] => mysqlnd
                                [17] => odbc
                                [18] => pcre
                                [19] => pdo
                                [20] => phar
                                [21] => reflection
                                [22] => session
                                [23] => simplexml
                                [24] => spl
                                [25] => standard
                                [26] => tokenizer
                                [27] => wddx
                                [28] => xml
                                [29] => xmlreader
                                [30] => xmlwriter
                                [31] => zip
                                [32] => zlib

                                  Weedpacket;11046185 wrote:

                                  Did you restart the server?

                                  Thanks for the help.
                                  Yes I did. Every time. Also reboot after update path.

                                    Weedpacket;11046185 wrote:

                                    Did you restart the server?

                                    mysqlnd

                                    mysqlnd enabled
                                    Version mysqlnd 5.0.10 - 20111026 - $Id: e707c415db32080b3752b232487a435ee0372157 $
                                    Compression supported
                                    SSL supported
                                    Command buffer size 4096
                                    Read buffer size 32768
                                    Read timeout 31536000
                                    Collecting statistics Yes
                                    Collecting memory statistics No
                                    Tracing n/a
                                    Loaded plugins mysqlnd,example,debug_trace,auth_plugin_mysql_native_password,auth_plugin_mysql_clear_password
                                    API Extensions no value

                                      i found that in php.ini that pdo_mysql.default_socket=
                                      empty.

                                      could this be the reason?