"Can't connect to local MySQL server through socket '/tmp/mysqld.sock' (2)"
Here's my code:
<?php
$dbhost=$_POST['dbhost']; // Host name
$dbusername=$_POST['dbusername']; // Mysql username
$dbpassword=$_POST['dbpassword']; // Mysql password
$db_name=$_POST['database']; // Database name
$tbl_name=$_POST['tablename']; // Table name
$action=$_POST['action'];
if($action == 'connect')
{
if(mysql_connect("$dbhost", "$dbusername", "$dbpassword") == true)
{
if(mysql_select_db("$db_name") == true)
{
echo('Connected to Database.');
}
else
{
die('Error: Can\'t use ' . DB_NAME . ': ' . mysql_error());
}
}
else
{
die('Error: Connection failed ' . mysql_error());
}
}
if($action == 'post')
{
$avatarname = $_POST["avatarname"];
// $rank = $_POST['rank'];
// $status = $_POST['status'];
echo($avatarname.' loaded into MySQL Database.');
$sql = "INSERT INTO $tbl_name (avatarname) VALUES ('$avatarname')";
if (!mysql_query($sql))
{
die('Error: ' . mysql_error());
}
}
if($action == 'done')
{
echo('Closing connection..');
mysql_close();
}
?>
It works up the the connection part, and returns "Connected to Database", but then it throws the error.. My hosting site is 1and1.com if that makes any difference.
Thanks in advance for any help, this has really been trying me..