Welcome aboard! We are happy you are here and wish you good net-raft!
// index.php
<?php
require_once ("/Includes/connectDB.php");
require_once ("/Includes/myfunctions.php");
?>
// connectDB.php
<?php
require_once ("/Includes/myconnectiondata.php");
// Create database connection
$databaseConnection = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
if ($databaseConnection->connect_error)
{
die("Database selection failed: " . $databaseConnection->connect_error);
}
else
{
echo "Connection created!";
}
?>
// myconnectiondata.php
<?php
define('DB_NAME', 'xxx');
define('DB_USER', 'xxx');
define('DB_PASSWORD', 'xxx');
define('DB_HOST', 'localhost');
?>
// myfunctions.php
<?php
create_table($databaseConnection);
function create_table($databaseConnection)
{
$query_users = "CREATE TABLE MYTABLE1 (id INT NOT NULL AUTO_INCREMENT, username VARCHAR(50), password CHAR(40), PRIMARY KEY (id))";
$databaseConnection->query($query_users);
echo "</br>Table has been created!";
mysqli_close($databaseConnection);
}
?>
The most helpful PHP solutions
detect browser phpPHP Click to see more ... 4.6K 408