Edit report at https://bugs.php.net/bug.php?id=62390&edit=1

 ID:                 62390
 Updated by:         johan...@php.net
 Reported by:        rbnsjnr at gmail dot com
 Summary:            localhost x 127.0.0.1
-Status:             Open
+Status:             Not a bug
 Type:               Bug
 Package:            MySQL related
 Operating System:   Linux-3.2.21 Debian/Wheezy
 PHP Version:        5.4.4
 Block user comment: N
 Private report:     N

 New Comment:

Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

When using localhost it won't try connecting using TCP/IP but using a Unix 
Domain Socket. By default it expects the socket file to be /tmp/mysql.sock. If 
that's not your socket location youhave to use the --with-mysql-sock configure 
option or set mysql.default_socket, mysqli.default_socket and 
pdo_mysql.default_socket in php.ini or use a specific socket using i.e. 
mysql_connect(":/path/to/socket", "user", "pass");

You can find the socket location fromyour my.cnf file or by doing something like
  <?php
  mysql_connect("127.0.0.1", "root", "");
  $r = mysql_query("SHOW VARIABLES LIKE 'socket'");
  print_r(mysql_fetch_row($r));
  ?>

Please mind that using mysql_* functions from the "mysql" extension is not 
suggested anymore. You should migrate to either mysqli or PDO.


Previous Comments:
------------------------------------------------------------------------
[2012-06-22 02:58:51] rbnsjnr at gmail dot com

Description:
------------
Dear (a) With PHP5.4.4 my projects do not connect more in the mysql database. I 
could not find answers on the Internet.

The PHP5.4.4 is not connecting to the mysql database with the function 
mysql_connect () and the parameter "localhost". When using the parameter 
"127.0.0.1", this function connects without problem.

See the example below that the error does not return PHP5.4.3 and PHP5.4.4 
returns an error.

Note: My PHP5.4.3 and 5.4.4 were compiled with the following parameters:

--prefix=/opt/php-5.4.3 --with-apxs2=/opt/httpd-2.4.2/bin/apxs --with-mysql 
--with-pgsql=/opt/PostgreSQL/9.0/ --with-zlib --with-bz2 --with-openssl 
--with-kerberos --enable-calendar --enable-ftp --enable-intl --enable-soap 
--enable-sockets --enable-zip

--prefix=/opt/php-5.4.4 --with-apxs2=/opt/httpd-2.2.22/bin/apxs --with-mysql 
--with-pgsql=/opt/PostgreSQL/9.0/ --with-zlib --with-bz2 --with-openssl 
--with-kerberos --enable-calendar --enable-ftp --enable-intl --enable-soap 
--enable-sockets --enable-zip

Test script:
---------------
<?php

$con = mysql_connect("localhost","u_joomlades","u_joomlades");
if (!$con) 
{
 die('Could not connect: ' . mysql_error());
 echo "\n";
}

mysql_close($con);
echo "\n";

?>


Expected result:
----------------
Replacing the parameter "localhost" to "127.0.0.1" the PHP5.4.4 connects 
without problems.

rubens@debian:~$ /opt/php-5.4.3/bin/php bd.php 

rubens@debian:~$ /opt/php-5.4.4/bin/php bd.php 

rubens@debian:~$ 


Actual result:
--------------
rubens@debian:~$ /opt/php-5.4.3/bin/php bd.php 

rubens@debian:~$ /opt/php-5.4.4/bin/php bd.php 

Warning: mysql_connect(): No such file or directory in /home/rubens/bd.php on 
line 3
Could not connect: No such file or directory

rubens@debian:~$ 


------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=62390&edit=1

Reply via email to