add: read, write data to database + some explainations
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
// db_connection_data.php
|
||||
|
||||
|
||||
$db_engine ="mysql";
|
||||
$db_name = "E2FI1_2025";
|
||||
$db_host = "localhost";
|
||||
$db_user = "phpmyadmin";
|
||||
$db_password = "server";
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
// db_connection_function.php
|
||||
|
||||
function db_connect(){
|
||||
require_once("db_connection_data.php");
|
||||
// db_server = "mysql:dbname=testdb;host:localhost";
|
||||
$db_server = "$db_engine:dbname=$db_name;host=$db_host";
|
||||
try {
|
||||
$dbh = new PDO ($db_server, $db_user, $db_password);
|
||||
echo "<p>DB Connection succesfull established!</p>";
|
||||
return $dbh;
|
||||
} catch (PDOException $e){
|
||||
//echo "Could not connect to DB!<br> ";
|
||||
die("More:".$e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Test:
|
||||
// db_connect();
|
||||
Reference in New Issue
Block a user