This is the code I have for the query:
$query = "SELECT * FROM articles LIMIT 1";
$mysqli = mysqli_connect($host, $user , $pass , $database);
$res = mysqli_query($mysqli, $query) or
die("Couldn't execute query.");
$row = mysqli_fetch_assoc($res);
echo $row;
Does anyone see any obvious problems with this that would stop it from executing? $host, $user etc are defined in a separate config file.
This is the error message I get:
Warning: mysqli_connect() [function.mysqli-connect]: (HY000/2002):
Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in
/websites/123reg/LinuxPackage22/bu/ck/et/public_html/admin/config.php on line 8
Connect failed: Can't connect to local MySQL server through socket
'/var/lib/mysql/mysql.sock' (2)
I have read that this means there is an issue with an SQL setting, can anyone confirm this?
Your mysql did not use default location for the socket, which is /var/lib/mysql/mysql.sock
.
So, check your configuration to find out the actual socket file, and replace the connection string accordingly, see mysqli_connect