Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 382
  • Last Modified:

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.
0
bhavin_v
Asked:
bhavin_v
1 Solution
 
laurlyCommented:
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
0
 
spookjeCommented:
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.
0
 
spookjeCommented:
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
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
bhavin_vAuthor Commented:
Laurly
I don't see that in phpinfo(). Any idea what is wrong?
Spookie,
I do hve mysql running.
Thanks for you help!
0
 
spookjeCommented:
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?
0
 
bhavin_vAuthor Commented:
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 =
0
 
spookjeCommented:
Between the other extensions, the order in my php.ini
is like below, usually though it doesn't matter.

You need to restart apache after changing:

/etc/init.d/httpd restart

Good luck! :-)

;;;;;;;;;;;;;;;;;;;;;;
; Dynamic Extensions ;
;;;;;;;;;;;;;;;;;;;;;;
;
; If you wish to have an extension loaded automaticly, use the following
; syntax:
;
;   extension=modulename.extension
;
; For example, on Windows:
;
;   extension=msql.dll
;
; ... or under UNIX:
;
;   extension=msql.so
;
; Note that it should be the name of the module only; no directory information
; needs to go here.  Specify the location of the extension with the
; extension_dir directive above.

;extension=cpdf.so
;extension=curl.so
;extension=cybercash.so
;extension=db.so
extension=dbg.so
;extension=domxml.so
;extension=dotnet.so
;extension=exif.so
;extension=fdf.so
;extension=gd.so
;extension=gettext.so
;extension=ifx.so
extension=imap.so
;extension=interbase.so
;extension=java.so
extension=ldap.so
;extension=mhash.so
;extension=mssql65.so
;extension=mssql70.so
extension=mysql.so
;extension=oas.so
extension=odbc.so
;extension=oci8.so
;extension=oracle.so
;extension=pdf.so
;extension=pgsql.so
;extension=sablot.so
;extension=swf.so
;extension=sybase_ct.so
;extension=zlib.so
0
 
bhavin_vAuthor Commented:
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.
0
 
snoyes_jwCommented:
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
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now