I checked with phpmyadmin and the query that I'm trying to do is working.
$user
= to the username login. I see it because I echo it. So I don't think that's the error.
The error I get is
> PHP Warning: mysql_query(): Can't connect to local MySQL server through socket
'/var/run/mysqld/mysqld.sock' (2) in
/hermes/bosweb/web161/b1615/ipg.jmdev/nmc/admin/user.php on line 14
> PHP Warning: mysql_query(): A link to the server could not be established in
/hermes/bosweb/web161/b1615/ipg.jmdev/nmc/admin/user.php on line 14
Line 14 is my query line (below), which is the piece of code that doesn't work...
Here is my code:
$host="link"; // Host name
$username="username"; // Mysql username
$password="password"; // Mysql password
$db_name="nmc"; // Database name
$tbl_name="account"; // Table name
session_start();
$user = $_SESSION['myusername'];
echo $user . '<br>';
//[Working on PHPMyAdmin](SELECT `role` FROM `account` WHERE `username`='jean8mathieu') (Working)
$result = mysql_query("SELECT `role` FROM `account` WHERE `username`='$user'");//I would like to make this work...
//$result = mysql_query("SELECT role FROM account WHERE username='jean8mathieu'"); /I try this line and did not ever work...
if (!$result) {
echo 'Could not run query: ' . mysql_error();
exit;
}
$row = mysql_fetch_row($result);
echo $row[0];
My problem is not to connect on the server it's the query. I am able to connect to it just my query doesn't seems to work... It working for all my other page...