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
insert_record($databaseConnection);
function insert_record($databaseConnection)
{
$query_insert = "INSERT INTO MYTABLE1 (username, password) VALUES ('myuser', 'mypassword')";
if ($databaseConnection->query($query_insert)) {
echo "</br>Record created!";
}
else
{
echo "</br>An error has occurred!";
}
mysqli_close($databaseConnection);
}
?>
The most helpful PHP solutions
detect browser phpPHP
Click to see more ...
4.8K
408
create QR code phpPHP
Click to see more ...
3.2K
289
create relative date phpPHP
Click to see more ...
2.3K
264
drag and drop upload file using phpPHP
Click to see more ...
2.9K
253
delete array item phpPHP
Click to see more ...
2.6K
245
detect ie phpPHP
Click to see more ...
1.8K
213
detect speed internet phpPHP
Click to see more ...
1.8K
198
get current url phpPHP
Click to see more ...
2K
197
get meta tag phpPHP
Click to see more ...
1.6K
193
Get real client country using php ?PHP
Click to see more ...
1.6K
181