Please Help! Can't connect to remote MySQL server using PHP

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • courtney.machi@gmail.com

    Please Help! Can't connect to remote MySQL server using PHP

    Hello,

    I am trying to connect to a remote mysql server through php. Here's the
    code:

    mysql_connect(" my.hostname.edu ", "username", "password") or die
    (mysql_error()) ;
    mysql_select_db ("db_name") or die ("unable to select
    db".mysql_error ());
    $r1 = mysql_query('SE LECT * FROM table') ;

    Using the mysql prompt on the remote server, the mysql -h -u -p works
    just fine with the parameters i've specified here. According to the
    user table I have the proper permissions. I just can't figure out what
    could be preventing the connection here, although I am no expert...can
    anyone help?!

    BTW, I am using PHP 4.4.1 and mysql 5.0.

    Thanks in advance...

  • Alan Little

    #2
    Re: Please Help! Can't connect to remote MySQL server using PHP

    Carved in mystic runes upon the very living rock, the last words of
    <courtney.machi @gmail.com> of comp.lang.php make plain:
    [color=blue]
    > I am trying to connect to a remote mysql server through php.
    >
    > Using the mysql prompt on the remote server, the mysql -h -u -p works
    > just fine with the parameters i've specified here. According to the
    > user table I have the proper permissions.[/color]

    1) What does mysql_error() say?

    2) Is your database configured to allow remote connections?

    --
    Alan Little
    Phorm PHP Form Processor

    Comment

    • courtney.machi@gmail.com

      #3
      Re: Please Help! Can't connect to remote MySQL server using PHP

      Hi,

      My error (actually a warning):
      Warning: mysql_connect() : Lost connection to MySQL server during query
      in /cm/sums/data.php on line 23
      Lost connection to MySQL server during query

      I'm not sure if it is configured to allow remote connections...w here
      would I look to find out?

      Thanks :-)

      Comment

      • Alan Little

        #4
        Re: Please Help! Can't connect to remote MySQL server using PHP

        Carved in mystic runes upon the very living rock, the last words of
        <courtney.machi @gmail.com> of comp.lang.php make plain:
        [color=blue]
        > My error (actually a warning):
        > Warning: mysql_connect() : Lost connection to MySQL server during query
        > in /cm/sums/data.php on line 23
        > Lost connection to MySQL server during query[/color]

        That's weird. I've seen connections time out when I'm in the mysql
        monitor, but not a script connection.
        [color=blue]
        > I'm not sure if it is configured to allow remote connections...w here
        > would I look to find out?[/color]

        I'm afraid I don't know. MySQL administration is voodoo to me. I just
        know such a setting exists.

        You might be better off asking in a MySQL group.

        --
        Alan Little
        Phorm PHP Form Processor

        Comment

        • courtney.machi@gmail.com

          #5
          Re: Please Help! Can't connect to remote MySQL server using PHP

          Voodoo...quite an accurate comparison, hehe.
          Thanks anyway, have a great day!

          Comment

          Working...