Trying to connect with other mysql databace

Alles, was PHP betrifft, kann hier besprochen werden.

Trying to connect with other mysql databace

Postby _mi_ » 04. July 2018 11:52

Hello!
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? :?
_mi_
 
Posts: 3
Joined: 04. July 2018 11:31
XAMPP version: 3.2.1
Operating System: windows 7

Re: Trying to connect with other mysql databace

Postby _mi_ » 05. July 2018 13:44

Everything work fine but now ihave to connect to another mysql server which is located on my network.
:!: :!: So sorry, no mysql - microsoft sql server ! :!: :!:
_mi_
 
Posts: 3
Joined: 04. July 2018 11:31
XAMPP version: 3.2.1
Operating System: windows 7

Re: Trying to connect with other mysql databace

Postby Altrea » 06. July 2018 07:11

phpMyAdmin cannot connect to MS SQL Servers
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 9336
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 10 Pro x64

Re: Trying to connect with sql Server databace SOLVED

Postby _mi_ » 06. July 2018 09:39

Its solved:
This is solve my problem:
https://programmium.wordpress.com/2014/04/20/retrieve-all-tables-of-sql-server-db-with-php-on-wamp/
Sorry again my wrong question about mysql connection!
_mi_
 
Posts: 3
Joined: 04. July 2018 11:31
XAMPP version: 3.2.1
Operating System: windows 7


Return to PHP

Who is online

Users browsing this forum: No registered users and 4 guests