Title: [Plugin: PostgreSQL for WordPress (PG4WP)] Alternative port in conection
Last modified: August 20, 2016

---

# [Plugin: PostgreSQL for WordPress (PG4WP)] Alternative port in conection

 *  Resolved [malguzt](https://wordpress.org/support/users/malguzt/)
 * (@malguzt)
 * [14 years ago](https://wordpress.org/support/topic/plugin-postgresql-for-wordpress-pg4wp-alternative-port-in-conection/)
 * I changed driver_pgsql.php to allow an alternative port in connection. Now can
   connect with host:port
 * function wpsql_connect($dbserver, $dbuser, $dbpass) {
    $GLOBALS[‘pg4wp_connstr’]
   = ”; **if (!empty($dbserver)) { $hostAndPort = explode(‘:’, $dbserver); $GLOBALS[‘
   pg4wp_connstr’] .= ‘ host=’ . $hostAndPort[0]; if(isset($hostAndPort[1])){ $GLOBALS[‘
   pg4wp_connstr’] .= ‘ port=’ . $hostAndPort[1]; } } if (!empty($dbuser)) $GLOBALS[‘
   pg4wp_connstr’] .= ‘ user=’ . $dbuser; if (!empty($dbpass)) $GLOBALS[‘pg4wp_connstr’].
   = ‘ password=’ . $dbpass; elseif (!PG4WP_INSECURE) wp_die(‘Connecting to your
   PostgreSQL database without a password is considered insecure.
 * If you want to do it anyway, please set “PG4WP_INSECURE” to true in your “db.
   php” file.’);
 *  // While installing, we test the connection to ‘template1’ (as we don’t know
   the effective dbname yet)
    if (defined(‘WP_INSTALLING’) && WP_INSTALLING) return
   wpsql_select_db(‘template1’);
 *  return 1;
    }
 * [http://wordpress.org/extend/plugins/postgresql-for-wordpress/](http://wordpress.org/extend/plugins/postgresql-for-wordpress/)

Viewing 1 replies (of 1 total)

 *  Plugin Author [hawk__](https://wordpress.org/support/users/hawk_/)
 * (@hawk_)
 * [14 years ago](https://wordpress.org/support/topic/plugin-postgresql-for-wordpress-pg4wp-alternative-port-in-conection/#post-2808277)
 * Hi !
 * You don’t tell which version of PG4WP you were using, so I assume 1.2.2 (which
   was the latest stable version when you posted)…
 * I’ve integrated a similar patch in PG4WP 1.3.0b1 and so the new stable version(
   released earlier today) has it included 🙂
 * Anyway, thank you for your effort, please keep me informed if you have any issue
   using PG4WP.

Viewing 1 replies (of 1 total)

The topic ‘[Plugin: PostgreSQL for WordPress (PG4WP)] Alternative port in conection’
is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/postgresql-for-wordpress.svg)
 * [PostgreSQL for WordPress (PG4WP)](https://wordpress.org/plugins/postgresql-for-wordpress/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/postgresql-for-wordpress/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/postgresql-for-wordpress/)
 * [Active Topics](https://wordpress.org/support/plugin/postgresql-for-wordpress/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/postgresql-for-wordpress/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/postgresql-for-wordpress/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [hawk__](https://wordpress.org/support/users/hawk_/)
 * Last activity: [14 years ago](https://wordpress.org/support/topic/plugin-postgresql-for-wordpress-pg4wp-alternative-port-in-conection/#post-2808277)
 * Status: resolved