I know this has been asked on almost every forum but I've been at this for two evenings now and I'm stumped.

PHP 5.4.6-1ubuntu1.2
Server version: 5.5.31-0ubuntu0.12.10.1 (Ubuntu)

Initially I had no access to mysql functions either but that hurdle has been overcome.

I've placed the extension modules (.so files) in "/usr/lib/php5/ext"

In my php.ini files I set;

extension_dir = "/usr/lib/php5/ext"

and

; ... or under UNIX:
;
extension=mysqli.so
;
; ... or with a path:
;
extension=/usr/lib/php5/ext/mysqli.so

Doing this it what seems to have enabled the mysql functions for me but mysqli is still not enabled.

in php.ini mysqli.so was msql.so. Not sure if I was correct to change this...???

Does anyone have any other suggestions?

Hi,

The best way to find out the exact location of the actual php.ini file use by your server as the server configuration file is to run php info.

<?php 

  phpinfo();

?>

Upload the file to your server and then open it with your favorite browser, and look for the value of the following..

Loaded Configuration File 

The value given by your php info(), will be the PHP currently running on your server.. for example if your find

usr/lib/php5/php.ini as the value then your ext directory to add your mysqli.so extension should be in the usr/lib/php5/ext directory.

I am pretty sure, you have something else..

Thanks veedeoo but I know all this. As stated in the OP, I've been editing the php.ini file. I also mentioned that I've placed the .so files, which includes mysqli.so, in the usr/lib/php5/ext directory which I created.

My main query was, why do I have access to only the mysql functions when I set extension=mysqli.so?

Dude,

You are welcome...:)

I am not assuming that you don't know. I know that you already knew, but how are you going to confirm which loaded configuration file your server uses? The easiest way to find out that you are indeed editing the right php.ini file for your server is to view what is on the phpinfo()..

There are two types of php.ini file in most servers configured with fast CGI, if apache module you might end up with the third one located in the apache2 directory.

  1. cofiguration file =====> /usr/lib ( common in shared hosting or vps with multiple accounst created through the WHM)

  2. Loaded configuration file ==> this is the one being utilize by the server, and this is where the editing should be done. We will not know where it is exactly, without running the phpinfo().

I am aware about your query... but in order for me to help, we need to find out and make sure you are editing the right php.ini file. Again, I am not assuming here that you don't know. My only concern is that , is it the right php.ini file? Your ability to edit php.ini file here is not in question..it is the right configuration file.

As what you already stated, even after uncommenting this extension=mysqli.so mysqli is a no show.

What is left there to investigate is the possiblity of ==> server has not been restarted since the last edit of the php.ini file (hence, I always assume people always remember to restart their server after editing php.ini file. I must not bring this up),. OR back to what I already mentioned above.

here is a code that will instantly check if mysqli is activated or not..

echo (function_exists('mysqli_connect')) ? 'Yes your msqli extension is activated' : ' NO! You gonna try a little harder';

Aside from the extension entry, this is how the mysqli section on php.ini file should look or similar to this. Again this is all dependent to what..value of your Server API ? Apache module or fast CGI? should be shown on your phpinfo();

[MySQLi]

; Maximum number of persistent links.  -1 means no limit.
; http://php.net/mysqli.max-persistent
mysqli.max_persistent = -1

; Allow accessing, from PHP's perspective, local files with LOAD DATA statements
; http://php.net/mysqli.allow_local_infile
mysqli.allow_local_infile = On

; Allow or prevent persistent links.
; http://php.net/mysqli.allow-persistent
mysqli.allow_persistent = On

; Maximum number of links.  -1 means no limit.
; http://php.net/mysqli.max-links
mysqli.max_links = -1

; If mysqlnd is used: Number of cache slots for the internal result set cache
; http://php.net/mysqli.cache_size
mysqli.cache_size = 2000

; Default port number for mysqli_connect().  If unset, mysqli_connect() will use
; the $MYSQL_TCP_PORT or the mysql-tcp entry in /etc/services or the
; compile-time value defined MYSQL_PORT (in that order).  Win32 will only look
; at MYSQL_PORT.
; http://php.net/mysqli.default-port
mysqli.default_port = 3306

; Default socket name for local MySQL connects.  If empty, uses the built-in
; MySQL defaults.
; http://php.net/mysqli.default-socket
mysqli.default_socket = "MySQL"

; Default host for mysql_connect() (doesn't apply in safe mode).
; http://php.net/mysqli.default-host
mysqli.default_host =

; Default user for mysql_connect() (doesn't apply in safe mode).
; http://php.net/mysqli.default-user
mysqli.default_user =

; Default password for mysqli_connect() (doesn't apply in safe mode).
; Note that this is generally a *bad* idea to store passwords in this file.
; *Any* user with PHP access can run 'echo get_cfg_var("mysqli.default_pw")
; and reveal this password!  And of course, any users with read access to this
; file will be able to reveal the password as well.
; http://php.net/mysqli.default-pw
mysqli.default_pw =

; Allow or prevent reconnect
mysqli.reconnect = Off

The mysql socket was derived from the phpinfo(), mysql table with the following values

mysql
MySQL Support   enabled
Active Persistent Links     0
Active Links    0
Client API version  5.1.69
MYSQL_MODULE_TYPE   external
MYSQL_SOCKET    /var/lib/mysql/mysql.sock
MYSQL_INCLUDE   -I/usr/include/mysql
MYSQL_LIBS  -L/usr/lib64 -lmysqlclient

this justify the mysl socket to be use by the mysqli

MYSQL_SOCKET    /var/lib/mysql/mysql.sock

Thats how I would set my php.ini.. Again, that is for me.. there are many people who are 100X knowledgeable than me..

Thanks for all the help veedeeo. I was unaware of the different php.ini files. I was ,however, editing the correct one.

My php.ini file differed from yours only in that

mysqli.default_socket = "MySQL"

was set as,

mysqli.default_socket = 

looking at phpinfo(), where you had

    MYSQL_SOCKET /var/lib/mysql/mysql.sock

I have

MYSQL_SOCKET    /var/run/mysqld/mysqld.sock 

Is this what could be causing the problem?

Oh, and instead of

MYSQL_LIBS  -L/usr/lib64 -lmysqlclient

I have

MYSQL_LIBS     -L/usr/lib -lmysqlclient_r 

I'm running
Server version: Apache/2.2.22 (Ubuntu)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.