Skip to content

Instantly share code, notes, and snippets.

@boazcstrike
Last active October 4, 2017 04:59
Show Gist options
  • Save boazcstrike/9bf8abd55b8d8daef6cad4e3ffd9c193 to your computer and use it in GitHub Desktop.
Save boazcstrike/9bf8abd55b8d8daef6cad4e3ffd9c193 to your computer and use it in GitHub Desktop.
establish a connection for your sql database and select the database initially
<?php
//SQL CONNECTION
$url = '';
$db_user = '';
$db_pass = '';
$db = '';
$conn = mysqli_connect($url, $db_user, $db_pass, $db);
if(!$conn){
echo "<center>Connection not established, please check your code.<br>";
echo "<br>Debugging errno: " . mysqli_connect_errno() . PHP_EOL;
echo "<br>Debugging error: " . mysqli_connect_error() . PHP_EOL;
}else{
// echo "Connected to " . $url . " " . $db_user . " " . $db . " " ;
mysqli_query($conn, "USE $db;");
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment