Re: Can't connect to MySQL via PHP

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I agree.  Thanks Ash.  Always good recommendations from your end.

On Sat, Jan 12, 2013 at 3:03 PM, Ashley Sheridan
<ash@xxxxxxxxxxxxxxxxxxxx>wrote:

> On Sat, 2013-01-12 at 19:53 +0000, Ashley Sheridan wrote:
>
> >
> > admin <admin@xxxxxxxxxxxxxxxxxxx> wrote:
> >
> > >
> > >
> > >
> > >
> > >From: Ashley Sheridan [mailto:ash@xxxxxxxxxxxxxxxxxxxx]
> > >Sent: Saturday, January 12, 2013 10:03 AM
> > >To: admin
> > >Cc: 'Rick Dwyer'; php-general@xxxxxxxxxxxxx
> > >Subject: RE:  Can't connect to MySQL via PHP
> > >
> > >
> > >
> > >On Sat, 2013-01-12 at 12:56 -0800, admin wrote:
> > >
> > >
> > >
> > >> -----Original Message-----
> > >> From: Rick Dwyer [mailto:rpdwyer@xxxxxxxxxxxxx]
> > >> Sent: Saturday, January 12, 2013 8:26 AM
> > >> To: php-general@xxxxxxxxxxxxx
> > >> Subject:  Can't connect to MySQL via PHP
> > >>
> > >> Hello all.
> > >>
> > >> I used the code below successfully to connect to a MySQL db on one
> > >> hosting provider.  I've moved the code to a new hosting provider with
> > >> new values and it returns:
> > >>
> > >> Access denied for user 'user'@'db.hostprovider.net' (using password:
> > >> YES)
> > >>
> > >> Even though I can copy and paste these three values (host, user and
> > >> pass) and paste into Navicat to make a connection.  So the
> > >credentials
> > >> are correct, but they are not authenticating when used in PHP.  I've
> > >> tried making host "localhost" and "127.0.0.1". both with the same
> > >> result.
> > >>
> > >> Can someone tell me what I am doing wrong here?
> > >>
> > >> Appreciate it.
> > >>
> > >> Thanks,
> > >> --Rick
> > >>
> > >>
> > >>
> > >> $db_name = "mydb";
> > >> $vc_host    = "db.hostprovider.net";
> > >> $vc_user    = "user";
> > >> $vc_pass    = "pass";
> > >>
> > >> $connection = @mysql_connect($vc_host, $vc_user, $vc_pass); $db =
> > >> mysql_select_db($db_name, $connection);
> > >>
> > >> echo mysql_error();
> > >>
> > >>
> > >>
> > >>
> > >> --
> > >> PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:
> > >> http://www.php.net/unsub.php
> > >
> > >
> > >Try this for me
> > >
> > >-----------------------------------------------------------
> > >
> > >$db = mysql_connect($vc_host, $vc_user, $vc_pass);
> > >mysql_select_db($db_name, $db);
> > >
> > >if (!$db) {
> > >    die('Could not connect: ' . mysql_error());
> > >}
> > >echo 'Connected successfully';
> > >mysql_close($db);
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >Please at least use mysqli_* functions. Every time someone recommends
> > >we use mysql_* functions, a kitten kills a programmer.
> > >
> > >
> > >Thanks,
> > >Ash
> > >http://www.ashleysheridan.co.uk
> > >
> > >
> > >
> > >
> > >
> > >Ash,
> > >
> > >              The question was asked about mysql functions.
> > >
> > >As much as the php list would like to force people from using mysql, I
> > >guess you should not have invented it, if you don't want people to
> > >still use it.
> > >
> > >
> > >
> > >Shoots a small fluffy kitten with big blue eyes... Waste a cap save a
> > >gui!!!!
> > >
> > >
> > >
> > >
> > >
> > >
> >
> > Actually, the question never mentioned mysql_* functions, so telling
> someone to use them is wrong.
> >
> > Thanks,
> > Ash
> > http://www.ashleysheridan.co.uk
> >
>
>
> Sorry, just re-read the OP and realised he was using the mysql_*
> functions.
>
> I still stand by my statement of not using them though. People should be
> advised that the functions are deprecated fully now and are not safe to
> use.
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>
>

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux