If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Fatal error: Call to undefined function mysql_connect()

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-23-04, 12:33
sczimmerman sczimmerman is offline
Registered User
 
Join Date: Sep 2004
Posts: 1
Question Fatal error: Call to undefined function mysql_connect()

Complete newbe,
Win98SE, Apache2.0.47, MySQL4.0.21, PHP 5.0.1, I can connect and manipulate the databases using MySQLCC from client and on the host PC but I can not connect using mysql_connect() function Getting error mentioned in title. Where are the arguments defined for this function? I have set the php.ini the my.ini and the httpd.confg files best I know how. This seems fairly simple but I have yet to make it work. phpinfo() shows that php seems to work, Apache shows it's index page when browsed but I am having migrains over this connecting to MySQL database. Please assist if you can. Thanks
Reply With Quote
  #2 (permalink)  
Old 09-24-04, 13:22
cristiu cristiu is offline
Registered User
 
Join Date: Sep 2004
Posts: 46
look in php.ini and uncomment where to see MySQL
Reply With Quote
  #3 (permalink)  
Old 10-31-04, 22:35
martongergo martongergo is offline
Registered User
 
Join Date: Oct 2004
Location: Romania
Posts: 5
Wink Resolving a Fatal error: Call to undefined function mysql_connect() in RedHat

Resolving a Fatal error: Call to undefined function mysql_connect() in RedHat

Symptoms
----------
In RedHat Linux, you have installed the PHP, MySQL, and Apache packages through the package manager. After starting the MySQL and Apache services through the service manager, you write a simple test php page to access the MySQL database. When the page is loaded in the web browser, you receive the error, Fatal error: Call to undefined function mysql_connect().

Sample Code
----------
<?php
$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_close($link);
?>

Cause
----------
The mysql.so extension library does not come with the PHP or MySQL distributions. It must be installed separately by downloading the php-mysql RPM.

Fix
----------
Verify that your installation of PHP has been compiled with mysql support. Create a test web page containing <?php phpinfo(); exit(); ?> and load it in your browser. Search the page for MySQL. If you don't see it, you need to recompile PHP with MySQL support, or reinstall a PHP package that has it built-in, both of which are beyond the scope of this document.

Verify that the line to load the extension in php.ini has been uncommented. In Linux, the line is extension=mysql.so and in Windows, the line is extension=php_mysql.dll. Uncomment the line by removing the semi-colon. You might also need to configure the extension_dir variable.

Check if the php-mysql package is installed by opening a terminal window (bash), and typing, rpm -qa | grep php. If you don't see it, make a note of the exact version of PHP that is installed.

Find the php-mysql RPM for the version of PHP that is installed on your system. The easiest way to find it is to search by the version of RedHat you have.

Go to a RedHat mirror or look on your RedHat CDs. For example, you can go to http://redhat.usu.edu/mirrors/redhat/linux/. If you have RedHat 8.0, then navigate to the folder /linux/8.0/en/os/i386/RedHat/RPMS/ and search for php-mysql. Download this file. (For a list of mirror sites, try RedHat Mirrors or search Google for redhat mirrors.)

To install the file, open a terminal window and cd to the directory where you saved the RPM. Then type rpm -hivv php-mysql-4.2.2-17.i386.rpm and press enter. This will install the RPM for RedHat 9.0.

You might also need MySQL-shared-compat RPM if you get a dependency of libmysqlclient.so.10 error while installing.

The last step is to restart Apache. You can do this with one of the following commands, apachectl restart or /etc/rc.d/init.d/httpd restart.

Applies To
----------
RedHat 7.x, 8.0, 9.0, Fedora, Apache, MySQL
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On