Hi , I am using PHP ver 4.1.2 in linux OS, when i try to connect to mysql databases using mysql_connect function, php show an error :

error in connection "undefine function 'mysql_connect' "

what is the problem?? is it due to php configuration problem??

    You need to make usre that mysql is enabled in the php.ini.

      Hi Houdini, i check the php.ini and found that mysql extension is not enable..below is the php.ini in my system:

      [MySQL]
      ; Allow or prevent persistent links.
      mysql.allow_persistent = On
      ; Maximum number of links (persistent + non-persistent). -1 means no limit.
      odbc.max_links = -1
      ;extension=php_hyperwave.dll
      ;extension=php_iconv.dll
      ;extension=php_ifx.dll
      ;extension=php_iisfunc.dll
      ;extension=php_imap.dll
      ;extension=php_ingres.dll
      ;extension=php_interbase.dll
      ;extension=php_java.dll
      extension=ldap.so
      ;extension=php_mbstring.dll
      ;extension=php_mcrypt.dll
      ;extension=php_mhash.dll
      ;extension=php_ming.dll
      ;extension=php_mssql.dll
      ;extension=php_mysql.dll
      ;extension=php_oci8.dll
      ;extension=php_odbc.dll
      ;extension=php_openssl.dll
      ;extension=php_oracle.dll
      ;extension=php_pdf.dll
      extension=pgsql.so
      ;extension=php_printer.dll
      ;extension=php_sablot.dll
      ;extension=php_shmop.dll
      ;extension=php_snmp.dll
      ;extension=php_sockets.dll
      ;extension=php_sybase_ct.dll
      ;extension=php_xslt.dll
      ;extension=php_yaz.dll

      how to enable the mysql in linux redhat??

        remove the ; (semicolon) in front of it then restart Apache and run phpinfo and see if MySQL doesn't show up in the install.

          I am not familiar with linux system...from what i know, dll is for window used extension right?? Linux can use dll also?? how to restart the apache is linux??

            you should have an so extension like

            ;;;;;;;;;;;;;;;;;;;;;;
            ; Dynamic Extensions ;
            ;;;;;;;;;;;;;;;;;;;;;;
            ;
            ; If you wish to have an extension loaded automatically, use the following
            ; syntax:
            ;
            ; extension=modulename.extension
            ;
            ; For example, on Windows:
            ;
            ; extension=msql.dll
            ;
            ; ... or under UNIX:
            ;
            ; extension=msql.so

            So in your ext directory there should be a mysql.so and in your extensions of the php.ini it needs to be there also (minus the semicolon).

              Hi, i cant find the mysql.so file... where is the ext directory location?

                It should be within the php directory (folder)

                  it only have pgsql.so... can i just download the mysql.so and put inside the directory or i need to recompile my php/mysql?? if yes, can tell me where can i get the file??

                    Actually all that should be on php.net and you might need to recompile, so I guess just go to the PHP Install page and see what is there. I do not use Linux but there are install instructions for that, and you might want to also look at the MySQL page also, but the link above should get you started.

                      OK..i will try it ...thanks a lot Houdini..... u are so kindly !!! -

                        Hi,

                        which distribution do you use ? There might be a rpm (or whatever, depends on the distribution) package available that just needs to be installed.

                        If there's no such package available then you can compile just the mysql extension which is a lot easier than recompiling php completely.

                        Thomas

                          Hi, if can, i chose to re-compile the mysql extension rather than recompiling php completely, but i not sure how to do that, very much appreciate if can u teach me how to do?? :p

                            Which linux distribution (incl. the version) is installed on your server ? Which PHP version and which MySQL version is installed ?

                            Thomas

                              sql version 3.23.49
                              php version 4.1.2

                              linux version not sure, i am a newbie in linux OS, this system was installed by my admin.
                              I just start to learn linux and has limited knowledge on it. Is it possible to check the linux ver through the command coz the x-window was not installed.

                                find out your distro version information at command line type:
                                uname -a

                                  thinking about that again...
                                  type:
                                  cat /etc/issue

                                  for example on my debian server, it returns:
                                  Debian GNU/Linux 3.1 \n \l

                                  on my redhat server it returns:
                                  Red Hat Enterprise Linux WS release 3 (Taroon Update 4)
                                  Kernel \r on an \m

                                    thanks ... i now able to find my linux version..

                                    Red Hat Linux release 7.3 (Valhalla)
                                    Kernel \r on an \m

                                      can somebody teach me how to rebuild the php for linux ?? I found a lot of info on how to install php on linux...but with php already installed, can i just install a new version of php without uninstall the old one??

                                        I think there's an easier solution:

                                        download php-mysql-4.1.2-7.3.6.i386.rpm from http://ftp.freshrpms.net/pub/updates/redhat-7.3-i386/

                                        and execute the command:

                                        rpm -Uvh php-mysql-4.1.2-7.3.6.i386.rpm

                                        That should install the package. Then make sure that the extension is enabled by removing the semicolon in front of the line extension=mysql.so
                                        If there's no such line then add that line in the extension section of php.ini.

                                        Then restart apache.

                                        Thomas

                                          Write a Reply...