Link to home
Start Free TrialLog in
Avatar of bhavin_v
bhavin_v

asked on

Call to undefined function: mysql_connect()

Hi,
I get the following error:
Call to undefined function: mysql_connect()
when I try to connect to a mysql DB.
I have gone through various postings and all point to the fact that PHP was compiled without mysql.
But here is what my phpinfo() shows me:
/configure' 'i386-redhat-linux' '--prefix=/us........
'--with-mysql=shared,/usr' '--with-pgsql=shared'..........
So you see, it is compiled with mysql. All RH 7.3 seem to be giving the same error. It's out-of-the-box RH 7.3 install.
Any help is greatly appreciated.

Thanks,
Bhavin.
Avatar of laurly
laurly
Flag of Denmark image

if you scoll down in phpinfo() do you see mysql something like

MySQL Support enabled
Active Persistent Links 1
Active Links 1
Client API version 3.23.47
MYSQL_MODULE_TYPE external
MYSQL_SOCKET /tmp/mysql.sock
MYSQL_INCLUDE -I/server/mysql//include/mysql
MYSQL_LIBS -L/server/mysql//lib/mysql -lmysqlclient  


laurly
Avatar of spookje
spookje

Maybe you didn't install the mysql-server itself although
your php-module for apache supports mysql.

Verify this with the command (for RedHat):

rpm -qa | grep mysql

It has to show mysql-versionnumber.

If you need mysql, try:

http://www.mysql.com/downloads/mysql-3.23.html

Also install the mysql-client btw. Very handy - then
you can enter queries in shell mode when you develop code.
My output on the rpm command show this btw:

$rpm -qa | grep mysql
mysql-server-3.23.54a-4
mod_auth_mysql-1.11-10
mysql-3.23.54a-4
mysqlclient9-3.23.22-6
mysql-devel-3.23.54a-4
php-mysql-4.2.2-8.0.7
Avatar of bhavin_v

ASKER

Laurly
I don't see that in phpinfo(). Any idea what is wrong?
Spookie,
I do hve mysql running.
Thanks for you help!
Perhaps your php.ini file is not ok?

grep -i mysql /etc/php.ini

should give a line like this to include the mysql
shared object into the php module:

extension=mysql.so

Anyway could you show us the output of above command?
Yes, you are right. There isn't a
extension=mysql.so.

Where should I put it in php.ini?
Here is the o/p

;extension=php_mysql.dll
mysql.allow_persistent = On
mysql.max_persistent = -1
mysql.max_links = -1
; Default port number for mysql_connect().  If unset, mysql_connect() will use
; the $MYSQL_TCP_PORT or the mysql-tcp entry in /etc/services or the
mysql.default_port =
mysql.default_socket =
; Default host for mysql_connect() (doesn't apply in safe mode).
mysql.default_host =
; Default user for mysql_connect() (doesn't apply in safe mode).
mysql.default_user =
; Default password for mysql_connect() (doesn't apply in safe mode).
; *Any* user with PHP access can run 'echo cfg_get_var("mysql.default_password")
mysql.default_password =
ASKER CERTIFIED SOLUTION
Avatar of spookje
spookje

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks. I tried enabling
extension=mysql.so
but to no avail. Same problem and no change in phpinfo() either. I am surprised that no one else has ran into this problem because it seems to be common on out-of-the-box RH7.3.
Any other ideas?
Thanks for all the help.
Bhavin.
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation in the Cleanup topic area:

Answered by spookje

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

snoyes_jw
EE Cleanup Volunteer