5a7af4cdf120bc1dbc49bd872cbbc2aa4f62de8f..4d8bfd9942fc5801e048487a9cde91a64326e4d3
2023-03-01 Olaf Bohlen
minor update
4d8bfd diff | tree
2023-03-01 Olaf Bohlen
added db connection support
4f3af1 diff | tree
1 files modified
19 ■■■■■ changed files
index.php 19 ●●●●● patch | view | raw | blame | history
index.php
@@ -24,6 +24,25 @@
      echo "no other file found!";
    }
    echo '</p>';
    $host = $_ENV["DBHOST"];
    $user = $_ENV["DBUSER"];
    $pass = $_ENV["DBPASS"];
    $db = $_ENV["DBNAME"];
    echo '<p>Connecting to database at ' .$host . '</p>';
    $con = pg_connect("host=$host dbname=$db user=$user password=$pass")
        or die ("Could not connect to server\n");
    $query = "SELECT * FROM foo LIMIT 5";
    $rs = pg_query($con, $query) or die("Cannot execute query: $query\n");
    echo '<p>Database results:<hr>';
    while ($row = pg_fetch_row($rs)) {
      echo "$row[0]\n";
    }
    echo "</p>";
    pg_close($con);
?>
 </body>
</html>