Last active
February 24, 2022 06:41
-
-
Save ahelord/59193c0c4aaa01238127031087c42c55 to your computer and use it in GitHub Desktop.
Php connect postgres
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$ip = $_SERVER['REMOTE_ADDR']; | |
// display it back | |
echo "<h1>Internal Load Balancing Lab</h1>"; | |
echo "<h2>Client IP</h2>"; | |
echo "Your IP address : " . $ip; | |
echo "<h2>Hostname</h2>"; | |
echo "Server Hostname: " . php_uname("n"). "<br>"; | |
echo "Region and Zone: " . "region-here". "<br>"; | |
$db_handle = pg_connect("host=35.226.49.26 dbname=dbcct user=usercct password=cct2021"); | |
if ($db_handle) { | |
echo 'Connection with DB attempt succeeded. <br>'; | |
} else { | |
echo 'Connection with DB attempt failed. <br>'; | |
} | |
echo "<h3>Connection Information</h3>"; | |
echo "DATABASE NAME:" . pg_dbname($db_handle) . "<br>"; | |
echo "HOSTNAME: " . pg_host($db_handle) . "<br>"; | |
echo "PORT: " . pg_port($db_handle) . "<br>"; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment