php and mysql

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Kenneth

    php and mysql

    I am trying to connect remotely to a mysql database.

    here is the code:

    <?php
    # FileName="Conne ction_php_mysql .htm"
    # Type="MYSQL"
    # HTTP="true"
    $hostname_myDB = "http://db195.perfora.n et";
    $database_myDB = "dbname";
    $username_myDB = "username";
    $password_myDB = "password";
    $myDB = mysql_pconnect( $hostname_myDB, $username_myDB, $password_myDB)
    or trigger_error(m ysql_error(),E_ USER_ERROR);
    ?>






    here is the error:

    Warning: mysql_pconnect( ): Unknown MySQL Server Host 'db195.perfora. net'
    (1) in /oldhome/WWW/wingsofthedawn. org/htdocs/final/Connections/myDB.php
    on line 9
  • Andy Hassall

    #2
    Re: php and mysql

    On Wed, 04 May 2005 14:58:36 -0700, Kenneth <jagger7774@hot mail.com> wrote:
    [color=blue]
    ><?php
    ># FileName="Conne ction_php_mysql .htm"
    ># Type="MYSQL"
    ># HTTP="true"
    >$hostname_my DB = "http://db195.perfora.n et";[/color]

    MySQL over HTTP? That's a new one on me. HTTP is a protocol, it wants a
    hostname. Remove the http:// , unless there's some wacky new protocol tunneling
    thing that's been added to MySQL that I'm not aware of.
    [color=blue]
    >$database_my DB = "dbname";
    >$username_my DB = "username";
    >$password_my DB = "password";
    >$myDB = mysql_pconnect( $hostname_myDB, $username_myDB, $password_myDB)
    >or trigger_error(m ysql_error(),E_ USER_ERROR);
    >?>
    >
    >here is the error:
    >
    >Warning: mysql_pconnect( ): Unknown MySQL Server Host 'db195.perfora. net'
    >(1) in /oldhome/WWW/wingsofthedawn. org/htdocs/final/Connections/myDB.php
    >on line 9[/color]

    --
    Andy Hassall / <andy@andyh.co. uk> / <http://www.andyh.co.uk >
    <http://www.andyhsoftwa re.co.uk/space> Space: disk usage analysis tool

    Comment

    • Tim Roberts

      #3
      Re: php and mysql

      Kenneth <jagger7774@hot mail.com> wrote:
      [color=blue]
      >I am trying to connect remotely to a mysql database.
      >
      >here is the code:
      >
      ><?php
      ># FileName="Conne ction_php_mysql .htm"
      ># Type="MYSQL"
      ># HTTP="true"
      >$hostname_my DB = "http://db195.perfora.n et";
      >$database_my DB = "dbname";
      >$username_my DB = "username";
      >$password_my DB = "password";
      >$myDB = mysql_pconnect( $hostname_myDB, $username_myDB, $password_myDB)
      >or trigger_error(m ysql_error(),E_ USER_ERROR);
      >?>
      >here is the error:
      >
      >Warning: mysql_pconnect( ): Unknown MySQL Server Host 'db195.perfora. net'
      >(1) in /oldhome/WWW/wingsofthedawn. org/htdocs/final/Connections/myDB.php
      >on line 9[/color]

      The error seems pretty self-explanatory to me. db195.perfora.n et does not
      exist. I can see that from here.

      Perfora.net DOES exist. What makes you think db195.perfora.n et should be
      valid?
      --
      - Tim Roberts, timr@probo.com
      Providenza & Boekelheide, Inc.

      Comment

      • Alvaro G Vicario

        #4
        Re: php and mysql

        *** Andy Hassall wrote/escribió (Wed, 04 May 2005 20:19:52 +0100):[color=blue]
        > MySQL over HTTP? That's a new one on me. HTTP is a protocol, it wants a
        > hostname. Remove the http:// , unless there's some wacky new protocol tunneling
        > thing that's been added to MySQL that I'm not aware of.[/color]

        SQLyog (a GUI client for Windows) has a HTTP tunneling system for MySQL
        (written in PHP, by the way) but of course mysql_pconnect( ) doesn't know
        how to handle it. I bet it's just a typo.

        BTW, in my experience mysql_pconnect( ) is the way to kill the database
        server: I used to get the max connections limit error when I had two
        visitors and 98 idle open connections. I'd suggest mysql_connect() instead.



        --
        -- Álvaro G. Vicario - Burgos, Spain
        -- http://bits.demogracia.com - Mi sitio sobre programación web
        -- Don't e-mail me your questions, post them to the group
        --

        Comment

        • Andy Hassall

          #5
          Re: php and mysql

          On Thu, 5 May 2005 13:37:55 +0200, Alvaro G Vicario
          <alvaro_QUITAR_ REMOVE@telecomp uteronline.com> wrote:
          [color=blue]
          >BTW, in my experience mysql_pconnect( ) is the way to kill the database
          >server: I used to get the max connections limit error when I had two
          >visitors and 98 idle open connections. I'd suggest mysql_connect() instead.[/color]

          It depends on your configuration (e.g. number of child processes from
          webserver) and number of distinct credentials used to access the database. If
          your config/usage pattern doesn't match up then persistent connections in
          general can easily knacker the database as you point out.

          I've always thought that PHP's persistent connection system should have a
          timeout where it closes connections after a while, it could piggy-back onto
          requests the same way as the sessions garbage collector. It seems the only way
          to do this is through your database config (if the database offers an "idle
          timeout" option), or through your webserver config (e.g. MaxRequests on Apache
          child processes). Seems to me it would be neater to have PHP manage its own
          connection pools a bit more intelligently instead of having to configure other
          tools further down the chain (which may have impact on things _other_ than PHP
          that are using them).

          --
          Andy Hassall / <andy@andyh.co. uk> / <http://www.andyh.co.uk >
          <http://www.andyhsoftwa re.co.uk/space> Space: disk usage analysis tool

          Comment

          • Mike Willbanks

            #6
            Re: php and mysql

            >>BTW, in my experience mysql_pconnect( ) is the way to kill the database[color=blue][color=green]
            >>server: I used to get the max connections limit error when I had two
            >>visitors and 98 idle open connections. I'd suggest mysql_connect() instead.[/color]
            >
            >
            > It depends on your configuration (e.g. number of child processes from
            > webserver) and number of distinct credentials used to access the database. If
            > your config/usage pattern doesn't match up then persistent connections in
            > general can easily knacker the database as you point out.[/color]

            I definitely agree.
            I have a dedicated box that is running 50 websites all on one database
            using p_connect. Some of the sites get a pretty intense load, but
            though the caching of pages and queries there hasn't been even one
            problem with a db connection yet.

            Mike

            Comment

            Working...