DelphiFAQ Home Search:
General :: Programming :: php
Find help with php (PHP: Hypertext Preprocessor), an open source, server-side, HTML embedded scripting language used to create dynamic Web pages.

Articles:

This list is sorted by recent document popularity (not total page views).
New documents will first appear at the bottom.

Featured Article

Fatal error: Call to undefined function: mysql_connect()

Question:

I install Apache, php 4.1.2 and mysql on RedHat Linux. When calling a php script that connects to the mysql database, I get this error message:

Fatal error: Call to undefined function: mysql_connect()
in /var/www/html/buyersguides/global/system_globals.inc on line 12


Answer:

Most likely mysql is not enabled on your php installation. You configured this when you compiled the php sources.

Create a dummy HTML page on your web server with the php code from below and call it through the web browser. It will tell you if mysql is enabled. (If you do not see a table with parameters for mysql, then mysql is not enabled in your php build.)

How do I enable mysql in my php installation?

If you have an RPM based system like Mandrake, then you need to install package php-mysql-4.3.2-3mdk.i586.rpm. You may need to resolve the requirement of libmysql12 - these are shared libraries needed to dynamically load and use MySQL.

Visit libmysql on rpmfind.net and get the RPM there.

Install it all then with and restart Apache:

 [root]#ls *.rpm
 
    -rw-r--r--  1 nobody nogroup  22333 Jul 26  2004 php-mysql-4.3.2-3mdk.i586.rpm
    -rwxr--r--  1 nobody nogroup 263560 Aug  9 10:55 libmysql12-4.0.23-2mdk.i586.rpm
 
 [root]#rpm --install libmysql12-4.0.23-2mdk.i586.rpm
 
    warning: libmysql12-4.0.23-2mdk.i586.rpm: V3 DSA signature: NOKEY, key ID 70771ff3
 
 
 [root]#rpm --install php-mysql-4.3.2-3mdk.i586.rpm
 
    warning: php-mysql-4.3.2-3mdk.i586.rpm: V3 DSA signature: NOKEY, key ID 70771ff3
 
 [root]#apachectl -k restart
 
 

On a system that is not based on RPM installation you need to go to your php installer directory and call configure to create a new make file, then recompile:


 # ./configure --with-apxs=/usr/local/apache/bin/apxs --with-mysql=/usr/local/mysql
 # make
 # make install
 
At the end do not forget to restart Apache.

<?php
   echo phpinfo();
 ?>

Generated 12:02:00 on Aug 17, 2017