The scenario is as follows:
I have local web site php + mysql-phpMyadmin on the localhost.
Everything work fine but now ihave to connect to another mysql server which is located on my network.
And i do the connection in this way:
- Code: Select all
define('DB_SERVER1', '192.168.0.2');
define('DB_USER1', 'u');
define('DB_PASS1', 'p');
define('DB_DATABASE1', 'd');
define('DB_PORT', 'xxxx');
$dbh1 = new PDO('mysql:host='.DB_SERVER1.';dbname='.DB_DATABASE1.';port='.DB_PORT, DB_USER1, DB_PASS1, array(PDO::ATTR_PERSISTENT => true));
$dbh1 -> exec("set names utf8");
$sql = "SHOW TABLES";
//Prepare our SQL statement,
$statement = $dbh1->prepare($sql);
//Execute the statement.
$statement->execute();
$tables = $statement->fetchAll(PDO::FETCH_NUM);
exit(var_dump($tables));
When I put the data of my local database(127.0.0.1 / localhost) everything work like a charm but when I try to connect to the other one database the following errors ocur:
- Code: Select all
Warning: PDO::__construct(): MySQL server has gone away in....
- Code: Select all
Warning: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] [2006] MySQL server has gone away' in ....
Otherwise i connected successfully when i tried with SqlDeveloper!
What must be done?