[PHP-DB] PDO Connection problem

2014-01-10 Thread Jim Giner

History:
I'm trying to help a friend who is hosting his domain with the same 
company that I use.  I've been using this company for several years and 
have used a certain 'connection' script all the time.  Part of it looks 
like this:


$host=mysql:host=mydomain.com;dbname=$sc_dbname;charset=utf8;
$uid = uid;
$pswd = pswd;
Try
{
$mysql = new PDO($host,$uid,$pswd,$db_options);
}
.

So - when I tried to provide this template to my friend (who is new to 
all of this) we went thru days of emails trying to make sure everything 
was setup correctly but could never get a connection using the above 
code.  Finally last night, after reviewing how my 'old' mysql interface 
connection worked, I experimented with the above changing my host= from 
my domain name to simply 'localhost'.  Voila - it worked for him.  It 
also worked for my site.


Here's my question:  What would make by friend's account not work when 
referencing a true domain name in the host= attribute?  I'm assuming 
that our (shared) provider is setting up his many accounts  servers the 
same way, but I could be wrong.  And of course, I don't have a clue 
about what makes any of this work - I simply follow 
instructions/guidance I get from manuals and searches until I get things 
to work.  That's how I got his account to finally work, but I'd love to 
have an idea why it now does.



--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] PDO Connection problem

2014-01-10 Thread Aziz Saleh
On Fri, Jan 10, 2014 at 10:13 AM, Jim Giner jim.gi...@albanyhandball.comwrote:

 History:
 I'm trying to help a friend who is hosting his domain with the same
 company that I use.  I've been using this company for several years and
 have used a certain 'connection' script all the time.  Part of it looks
 like this:

 $host=mysql:host=mydomain.com;dbname=$sc_dbname;charset=utf8;
 $uid = uid;
 $pswd = pswd;
 Try
 {
 $mysql = new PDO($host,$uid,$pswd,$db_options);
 }
 .

 So - when I tried to provide this template to my friend (who is new to all
 of this) we went thru days of emails trying to make sure everything was
 setup correctly but could never get a connection using the above code.
  Finally last night, after reviewing how my 'old' mysql interface
 connection worked, I experimented with the above changing my host= from my
 domain name to simply 'localhost'.  Voila - it worked for him.  It also
 worked for my site.

 Here's my question:  What would make by friend's account not work when
 referencing a true domain name in the host= attribute?  I'm assuming that
 our (shared) provider is setting up his many accounts  servers the same
 way, but I could be wrong.  And of course, I don't have a clue about what
 makes any of this work - I simply follow instructions/guidance I get from
 manuals and searches until I get things to work.  That's how I got his
 account to finally work, but I'd love to have an idea why it now does.


 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php


It could be that your MySQL configs -bind-address and skip-networking are
set, so it is not allowing for external connections. My guess (could be
wrong) that using yourdomain.com is the same as making an external call, as
opposed to using localhost (no DNS lookup).