Skip to content

Instantly share code, notes, and snippets.

@fernandokosh
Created January 16, 2020 19:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fernandokosh/f359bc8e4cf553703687cfde2e647fe3 to your computer and use it in GitHub Desktop.
Save fernandokosh/f359bc8e4cf553703687cfde2e647fe3 to your computer and use it in GitHub Desktop.
<?php
// WordPress database connection test usingo mysqli
// Enable all messages
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
$conn = mysqli_connect('localhost', 'username', 'password');
mysqli_select_db($conn, "my_wordpress_database");
if (!$conn) {
die('ERROR: Unable to connect: ' . mysql_error());
}
echo 'Connected to the database.<br>';
$result = mysqli_query($conn, 'SELECT user_login FROM wp_users');
$row = mysqli_fetch_row($result);
echo "User : ", $row[0], "<br>\n";
mysqli_close($conn);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment