So I just finally installed the PDO drivers, and now I have another issue. When I try to use
<?php
$username = "root";
$password = "allen123";
$conn = new PDO('mysql:host=localhost;dbname=test', $username, $password);
?>
Just to connect to the DB, I get the following error
Fatal error: Uncaught exception 'PDOException' with message
'SQLSTATE[HY000] [2002] No such file or directory' in
/Users/idrisk/Colourity/site/index.php:4 Stack trace: #0
/Users/idrisk/Colourity/site/index.php(4):
PDO->__construct('mysql:host=loca...', 'root', 'allen123') #1 {main}
thrown in /Users/idrisk/Colourity/site/index.php on line 4
I've looked at other posts on SO about this issue, but they all seem different. Any ideas?
EDIT
So I installed the drivers via Macports and this is what I get once It was installed
To use mysqlnd with a local MySQL server, edit /opt/local/etc/php55/php.ini and set mysql.default_socket, mysqli.default_socket and pdo_mysql.default_socket to the path
to your MySQL server's socket file.
For mysql51, use /opt/local/var/run/mysql51/mysqld.sock
For mysql55, use /opt/local/var/run/mysql55/mysqld.sock
For mysql56, use /opt/local/var/run/mysql56/mysqld.sock
For mariadb, use /opt/local/var/run/mariadb/mysqld.sock
For percona, use /opt/local/var/run/percona/mysqld.sock`
The other answers say to use something else.
Related
I am wondering when I instantiate a new PDO object it still uses the local IP of the server.
<?php
$dsn = 'mysql:host=10.0.0.4;charset=utf8';
$username = 'user';
$password = 'pass';
$pdo = new PDO($dsn, $username, $password);
?>
It gives me this weird error.
Fatal error: Uncaught exception 'PDOException' with message
'SQLSTATE[28000] [1045] Access denied for user 'user'#'10.0.0.5'
(using password: YES)' in /var/www/html/mysql_test.php:7
Stack trace:
#0 /var/www/html/mysql_test.php(7): PDO->__construct('mysql:host=10.0...', 'user', 'pass')
#1 {main}
thrown in /var/www/html/mysql_test.php on line 7
I noticed that it is connecting to 10.0.0.5 which is the IP address of the local server. The remote server (10.0.0.4) enables remote access.
Is there an internal config file for PDO that I should configure? The current PHP and PDO versions are 5.5.15RC1 and 5.5.38 respectively.
When I run the following PHP code:
<?php
$username = "root";
$password = "allen123";
$conn = new PDO('mysql:host=localhost;dbname=test', $username, $password);
?>
I get the following error.
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] [2002] No >such file or directory' in /Users/idrisk/Colourity/site/index.php:4 Stack trace: #0 >/Users/idrisk/Colourity/site/index.php(4): PDO->__construct('mysql:host=loca...', 'root', >'allen123') #1 {main} thrown in /Users/idrisk/Colourity/site/index.php on line 4
Any ideas? I downloaded the PDO drivers via Macports by the way
EDIT
To use mysqlnd with a local MySQL server, edit /opt/local/etc/php55/php.ini and set mysql.default_socket, mysqli.default_socket and pdo_mysql.default_socket to the path
to your MySQL server's socket file.
For mysql5, use /opt/local/var/run/mysql5/mysqld.sock
For mysql51, use /opt/local/var/run/mysql51/mysqld.sock
For mysql55, use /opt/local/var/run/mysql55/mysqld.sock
For mysql56, use /opt/local/var/run/mysql56/mysqld.sock
For mariadb, use /opt/local/var/run/mariadb/mysqld.sock
For percona, use /opt/local/var/run/percona/mysqld.sock
---> Cleaning php55-mysql
---> Updating database of binaries: 100.0%
---> Scanning binaries for linking errors: 100.0%
---> No broken files found.
It looks like you have an invalid socket in your php.ini file. Change the pdo_mysql.default_socket setting to an empty string to use the default socket.
I have a problem while trying to connect to my SQL Server 2000 database using pdo_mssql with this line:
$connection = new PDO ('mssql:host=localhost;dbname=DNAME', 'user', 'password');
The exception is the following:
PHP Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] General SQL Server error: Check messages from the SQL Server. (severity 5)' in C:\Inetpub\wwwroot\public\test.php:2 Stack trace: #0 C:\Inetpub\wwwroot\public\test.php(2): PDO->__construct('mssql:host=loca...', 'user', 'password') #1 {main} thrown in C:\Inetpub\wwwroot\public\test.php on line 2
If I make the connection using the function mssql_connect() as follows, I obtain no error and my connection is correctly made:
$link = mssql_connect ('localhost', 'user', 'password');
Any idea? Where can I read the detailed error message? Thanks
My database name had the character "-", removing it solved the problem!
I have installed PDO_INFORMIX and CSDK already on CentOS5.6 32bits
and index.php have
<?php
error_reporting(E_ALL);
ini_set("display_errors", 1);
$db = new PDO("informix:host=172.30.179.81; service=5000;database=cms; EnableScrollableCursors=1", "myuser", "mypassword");
print("OK");
?>
but i still got this error
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE=HY000, SQLDriverConnect: -11060 [Informix][Informix ODBC Driver]General error.' in /usr/local/apache/htdocs/index3.php:5 Stack trace: #0 /usr/local/apache/htdocs/index3.php(5): PDO->__construct('informix:host=1...', 'myuser', 'mypassword') #1 {main} thrown in /usr/local/apache/htdocs/index3.php on line 5
Have anyone know what it is ?
Thanks
Ouch! The standard technique for finding out more about errors is:
$ finderr -11060
-11060 General error.
An error occurred that has no specific SQL_STATE. In this case,
additional text is provided that identifies the source of the problem.
This IBM Informix CLI error code is the same as SQLSTATE value S1000.
$
That is not very helpful - to be polite about it.
There are spaces in the connect string; does removing them help at all?
Can you telnet to the host 172.30.179.81?
Can you telnet to the port (service) 5000 on the host?
Can you connect from this machine using any other Informix tool?
Can you connect from other machines using the same connect string?
In case of desparation, can you track down whether all the shared libraries are loading correctly?
i have PHP Version 5.2.8 on my windows 2003 server, i am trying to connect with database
$dbh = new PDO("mysql:host=localhost;port=3306;dbname=$db_name", $db_user, $db_pass);
but when i use this statement i got following error
Fatal error: Uncaught exception 'PDOException' with message 'could not find driver'
in bin\db.php:14 Stack trace: #0 bin\db.php(14):
PDO->__construct('mysql:host=loca...', 'root', '123') #1
main.php(4): include_once('C:\Inetpub\wwwr...') #2
{main} thrown in bin\db.php on line 14
how can i fix this problem?
Thanks
You must remove the ; on this line in php.ini :
;extension=php_pdo_mysql.dll
extension=php_pdo_mysql.dll
If you're upgrading PHP, be sure to check your environment variable information, especially your `PATH, and reboot if you change it.
I was using a php.ini file from a different directory. As Sebastian Grignoli suggests, check your phpinfo() results for the location of the php.ini it's using.