0

We have lan based .Net application with Postgresql 8.1 , now i have task to provide interface on website to read and write two tables on LAN based database I don't know where to start Please help me to solve this problem.

Lan: Windows NT 2003 .Net Postgresql 8.1

Website: PHP 5.3 Mysql

3
  • @MarcB how about making the link a bit more specific to the issue at hand yes? Commented Sep 26, 2011 at 15:03
  • You should also consider upgrading to a supported PostgreSQL version as soon as possible. 8.1 is definitely dead. 8.2 is the oldest version still being maintained but will be dropped at the end of this year. Additionally there were major performance improvements since then as well. I highly recommed to go straight for 9.1 Commented Sep 26, 2011 at 15:07
  • If you're already in production, I'd hold off on 9.1 until it's been out for 6 months or so. 9.0 has been out over a year and is rock solid stable. There's still the occasional wtf moment on the lists with 9.1 Commented Sep 27, 2011 at 11:37

3 Answers 3

1

You need to enable remote connections on Postgres. But be wary of security implications.

Haven't read it all, but this should give you an idea on the steps to take on the server. For the connector, you generally just need to point the connect function at the remote IP.

Sign up to request clarification or add additional context in comments.

Comments

1

Here is how to do the trick. Copied from here:

 <?php
// Connecting, selecting database
$dbconn = pg_connect("host=localhost dbname=publishing user=www password=foo")
    or die('Could not connect: ' . pg_last_error());

// Performing SQL query
$query = 'SELECT * FROM authors';
$result = pg_query($query) or die('Query failed: ' . pg_last_error());

// Printing results in HTML
echo "<table>\n";
while ($line = pg_fetch_array($result, null, PGSQL_ASSOC)) {
    echo "\t<tr>\n";
    foreach ($line as $col_value) {
        echo "\t\t<td>$col_value</td>\n";
    }
    echo "\t</tr>\n";
}
echo "</table>\n";

// Free resultset
pg_free_result($result);

// Closing connection
pg_close($dbconn);
?>

in the above code, replace localhost by the IP-address of your Postgres host.

Comments

0

On Linux, two files need to be modified to allow connections other than from localhost: postgresql.conf, change the listen_addresses = "*" to accept connections from anywhere. Then add a line to the pg_hba.conf file to allow access to the database from a particular IP or network. If you are not worried about security, entering:

host all all 192.168.1.0/24 trust

will allow anyone on the 192.168.1.0/24 network access to any database. Obviously this should only be used to test you can reach the database. Constrain this to the web servers IP address and use md5 so encrypted password authentication is used.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.