Working with a Wordpress website that is being hosted by Godaddy. I am familiar with creating custom templates and scripting pages (php) and running them on this specific Wordpress webpage. I am at the point where I need to access my mysql database and interact with custom templates+data via programmatically. Just in the past few days I've searched hundreds threads+tutorials and copied examples with no luck. I have a created a php file called display_data.php Code:
<?php /* Template Name: display_data */ ?>
<?php
$db_host = 'localhost'; // Server Name
$db_user = 'root'; // Username
$db_pass = ''; // Password
$db_name = 'tutorial'; // Database Name
$conn = mysql_connect($db_host, $db_user, $db_pass, $db_name);
if (!$conn) {
die ('Failed to connect to MySQL: ' . mysqli_connect_error());
}
$sql = 'SELECT *
FROM sales';
$query = mysqli_query($conn, $sql);
if (!$query) {
die ('SQL Error: ' . mysqli_error($conn));
}
?>
I get this error: "Failed to connect to MySQL: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)"
I have had no luck figuring out what this error specifically means in my case and I've searched for many hours.
I am at the point where I believe I am missing something stupid simple that I am looking past.
Either I am filling the parameters wrong - $db_user, $db_pass, $db_name, or missing something entirely.
I used the same parameters (User name, password) from the ones I got from Godaddy to access phpmyadmin, and for $db_name I used the one I see in my database (picture).Taken from my database, I used what is said to the right of "Database:"
Taken from Gogdaddy (Database PHPMyadmin - View)
Please any help is greatly appreciated, and be nice. I've never used mysql before but I am also not a total noob to programming.
Thank you.