Jump to content


This topic is now archived and is closed to further replies.


Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'

Recommended Posts

Im not sure why I am getting this error but I only get it when trying to transfer sessions from 1 page to another i believe. Im not positive its the sessions but I think it could be. Im not the greatest at php yet so I am posting my scripts here to see what the experts say I should do to fix this problem.


[code]Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)[/code]




header("Cache-control: private");

$user = $_POST['username'];
$pass = $_POST['password'];


// Check to see if the user exists.

$sql_user_check = "SELECT username FROM users WHERE username='$user'";
$result_name_check = mysql_query($sql_user_check) or die(mysql_error());
$usersfound = mysql_num_rows($result_name_check) or die(mysql_error());

// If the user is not found note that and end.
if($usersfound < 1){
$error = "User ".$user." was not found in the database.";

$user = $_POST['username'];
$pass = md5($_POST['password']);
$sql = "select * from users where `username` = '$user'";
$result = mysql_query($sql);
while ($text = mysql_fetch_array($result)) {
$id = $text['id'];
$password = $text['encrytpass'];
$access = $text['access'];
if ($pass == $password) {
$error = "Wrong Username / Password <a href=\"?act=login\">Back</a>";

// If the passwords do match, let in and go to the session variables.
$_SESSION['userid'] = $text['userid'];
$_SESSION['first_name'] = $text['first_name'];
$_SESSION['last_name'] = $text['last_name'];
$_SESSION['username'] = $text['username'];
$_SESSION['password'] = $text['password'];
$_SESSION['encryptpass'] = $text['encryptpass'];
$_SESSION['email'] = $text['email'];
$_SESSION['location'] = $text['location'];
$_SESSION['steamid'] = $text['steamid'];
$_SESSION['handle'] = $text['handle'];
$_SESSION['bio'] = $text['bio'];
$_SESSION['photo'] = $text['photo'];
$_SESSION['team_name'] = $text['team_name'];
$_SESSION['team_tag'] = $text['team_tag'];
$_SESSION['access'] = $text['access'];
$_SESSION['webs'] = $text['webs'];
$_SESSION['priv_message'] = $text['priv_message'];

echo $error;
header("Location: index2.php");
echo "<html><head><title>Welcome Back</title></head>Welcome back ". $_SESSION['username'] .".<a href=index2.php>Click here</a> to proceed.";


[code]<?php session_start();
header("Cache-control: private");
echo "You are logged in as:". $_SESSION['username'] ."<br/><br/>";
echo "<font id=UserPanelText />You are not logged in.<br/><br/>";
$newpms = $_SESSION['priv_messages'];
if($newpms > "0"){
echo "<a href=?page=newpmessage=$id>Unread Messages</a> (". $newpms .")<br/>";
echo "<font id=UserPanelText /><a href=?page=pmessages=$id>Mailbox</a><br/><font id=UserPanelText /><a href=?page=user_panel>User Panel</a><br/>";

Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.