Jump to content

Connecting Error


Cetanu

Recommended Posts

I get this error message after logging in:

 

Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

 

The script for logging in:

<?php
session_start(); 
if(!isset($_POST['login'])){ 
echo "<h3>Log In</h3><br/> 
<form action='../index.php' method='post'> 
<label for='name'>Username</label> <input type='text' name='name' id='name' maxlength='16'/> <br/> 
<label for='pass'>Password</lable> <input type='password' name='pass' id='pass'/> <br/> 
<input type='submit' name='login' value='Log In'/><br/> 
</form>"; 
} 
else{ 
  include "includes/db.php";
  $user = protect($_POST['name']);
  $pass = protect($_POST['pass']);
  
if($user && $pass)
{
$pass = md5($pass); //compare the encrypted password
$sql="SELECT id,username FROM `d9_users` WHERE `username`='$user' AND `password`='$pass'";
$query=mysql_query($sql) or die(mysql_error());

    if(mysql_num_rows($query) > 0)
    {
      $row = mysql_fetch_assoc($query);
      $_SESSION['id'] = $row['id'];
      $_SESSION['username'] = $user;
    header('Location: http://d9fans.freezoka.com');
    }
    else
   {
    echo "Username - Password Combination Incorrect.";
    echo "<a href=\"../index.php\"> Try Again!</a>";
   }	
}
else
{			
   echo "<script type=\"text/javascript\">
alert(\"You need to gimme a username AND password!\");
window.location=\"../index.php\"</script>";
}
}
?>

 

The script for what happens after you log in:

<?php 
include "includes/db.php";

$result = mysql_query("SELECT * FROM d9_users WHERE username='{$_SESSION['username']}'") 
or die(mysql_error());  

while($row = mysql_fetch_array( $result )) {

if($row['species'] == "Non Human"){ 
echo "<img src='images/nhdisplay.png' class='center' alt='Non Human'/><br/>"; 
} 
if($row['species'] == "Human"){ 
echo "<img src='images/hdisplay.png' class='center' alt='Human'/><br/>"; 
} 
echo "Hey there, ".$_SESSION['username']."<br/>"; 
} 
?>

Link to comment
Share on other sites

 

<?php

$con = mysql_connect("sql308.freezoka.com","zoka_3628910","------") or die(mysql_error());
$db = mysql_select_db("zoka_3628910_d9_users",$con);

function protect($string)
{
$string = mysql_real_escape_string($string);
return $string;
}
?>

 

I used that to connect for registering and it worked...

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.