DB connection Error In PHP Slim framework in mac Connection failed: SQLSTATE[HY000] [2002] Connection timed...
up vote
0
down vote
favorite
I have installed Xampp VM in mac for PHP slim framework(V3).
get an error when try to connect remote db over the internet using vpn.
error is Connection failed: SQLSTATE[HY000] [2002] Connection timed out
but xampp local db connect without any error.
I used this code for connecting.
class db
{
public $dbhost = '192.168.1.78';
public $dbuser = 'root';
public $dbpass = 'Raven898';
public $dbname = 'xyz';
public $dbport = '3306';
// Connect
public function connect()
{
$connection = 'mysql:host='.$this->dbhost.';dbname='.$this->dbname;
try {
$dbh = new PDO($connection, $this->dbuser, $this->dbpass);
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch (PDOException $e) {
echo 'Connection failed: '.$e->getMessage();
}
}
}
php database slim
add a comment |
up vote
0
down vote
favorite
I have installed Xampp VM in mac for PHP slim framework(V3).
get an error when try to connect remote db over the internet using vpn.
error is Connection failed: SQLSTATE[HY000] [2002] Connection timed out
but xampp local db connect without any error.
I used this code for connecting.
class db
{
public $dbhost = '192.168.1.78';
public $dbuser = 'root';
public $dbpass = 'Raven898';
public $dbname = 'xyz';
public $dbport = '3306';
// Connect
public function connect()
{
$connection = 'mysql:host='.$this->dbhost.';dbname='.$this->dbname;
try {
$dbh = new PDO($connection, $this->dbuser, $this->dbpass);
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch (PDOException $e) {
echo 'Connection failed: '.$e->getMessage();
}
}
}
php database slim
You're probably not allowed to connect to the database remotely.
– miken32
Nov 9 at 23:12
that way to set the db connection is from slim 2, are you sure about the version?
– DaFois
Nov 10 at 9:38
@miken32 my workbanch connected successfully using same vpn only slim not connected i dont know why
– M.Bilal Murtaza
Nov 11 at 0:38
Yes @DaFois i double check after your comment its v3.0
– M.Bilal Murtaza
Nov 11 at 0:39
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have installed Xampp VM in mac for PHP slim framework(V3).
get an error when try to connect remote db over the internet using vpn.
error is Connection failed: SQLSTATE[HY000] [2002] Connection timed out
but xampp local db connect without any error.
I used this code for connecting.
class db
{
public $dbhost = '192.168.1.78';
public $dbuser = 'root';
public $dbpass = 'Raven898';
public $dbname = 'xyz';
public $dbport = '3306';
// Connect
public function connect()
{
$connection = 'mysql:host='.$this->dbhost.';dbname='.$this->dbname;
try {
$dbh = new PDO($connection, $this->dbuser, $this->dbpass);
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch (PDOException $e) {
echo 'Connection failed: '.$e->getMessage();
}
}
}
php database slim
I have installed Xampp VM in mac for PHP slim framework(V3).
get an error when try to connect remote db over the internet using vpn.
error is Connection failed: SQLSTATE[HY000] [2002] Connection timed out
but xampp local db connect without any error.
I used this code for connecting.
class db
{
public $dbhost = '192.168.1.78';
public $dbuser = 'root';
public $dbpass = 'Raven898';
public $dbname = 'xyz';
public $dbport = '3306';
// Connect
public function connect()
{
$connection = 'mysql:host='.$this->dbhost.';dbname='.$this->dbname;
try {
$dbh = new PDO($connection, $this->dbuser, $this->dbpass);
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch (PDOException $e) {
echo 'Connection failed: '.$e->getMessage();
}
}
}
php database slim
php database slim
asked Nov 9 at 21:58
M.Bilal Murtaza
285
285
You're probably not allowed to connect to the database remotely.
– miken32
Nov 9 at 23:12
that way to set the db connection is from slim 2, are you sure about the version?
– DaFois
Nov 10 at 9:38
@miken32 my workbanch connected successfully using same vpn only slim not connected i dont know why
– M.Bilal Murtaza
Nov 11 at 0:38
Yes @DaFois i double check after your comment its v3.0
– M.Bilal Murtaza
Nov 11 at 0:39
add a comment |
You're probably not allowed to connect to the database remotely.
– miken32
Nov 9 at 23:12
that way to set the db connection is from slim 2, are you sure about the version?
– DaFois
Nov 10 at 9:38
@miken32 my workbanch connected successfully using same vpn only slim not connected i dont know why
– M.Bilal Murtaza
Nov 11 at 0:38
Yes @DaFois i double check after your comment its v3.0
– M.Bilal Murtaza
Nov 11 at 0:39
You're probably not allowed to connect to the database remotely.
– miken32
Nov 9 at 23:12
You're probably not allowed to connect to the database remotely.
– miken32
Nov 9 at 23:12
that way to set the db connection is from slim 2, are you sure about the version?
– DaFois
Nov 10 at 9:38
that way to set the db connection is from slim 2, are you sure about the version?
– DaFois
Nov 10 at 9:38
@miken32 my workbanch connected successfully using same vpn only slim not connected i dont know why
– M.Bilal Murtaza
Nov 11 at 0:38
@miken32 my workbanch connected successfully using same vpn only slim not connected i dont know why
– M.Bilal Murtaza
Nov 11 at 0:38
Yes @DaFois i double check after your comment its v3.0
– M.Bilal Murtaza
Nov 11 at 0:39
Yes @DaFois i double check after your comment its v3.0
– M.Bilal Murtaza
Nov 11 at 0:39
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53233775%2fdb-connection-error-in-php-slim-framework-in-mac-connection-failed-sqlstatehy0%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
You're probably not allowed to connect to the database remotely.
– miken32
Nov 9 at 23:12
that way to set the db connection is from slim 2, are you sure about the version?
– DaFois
Nov 10 at 9:38
@miken32 my workbanch connected successfully using same vpn only slim not connected i dont know why
– M.Bilal Murtaza
Nov 11 at 0:38
Yes @DaFois i double check after your comment its v3.0
– M.Bilal Murtaza
Nov 11 at 0:39