Cetanu Posted September 3, 2009 Share Posted September 3, 2009 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/>"; } ?> Quote Link to comment Share on other sites More sharing options...
mellis95 Posted September 3, 2009 Share Posted September 3, 2009 It looks like mysql isn't running or you have bad connection info. What does your connection string look like. I assume it is in db.php. Quote Link to comment Share on other sites More sharing options...
Cetanu Posted September 3, 2009 Author Share Posted September 3, 2009 <?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... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.