On my local computer the code is working and but it's not working on the free hosting (www.aba.ae).
Error message with pdo
(SQLSTATE[HY000] [2002] No such file or directory)
code php:
function create($table)
{
$servername = "localhost";
$username = "root" ;
$password = "********";
$dbname = "*****";
try {
$conn = new PDO("mysql:host=$servername; dbname=$dbname", $username, $password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql = "CREATE TABLE $table (
`id` INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
`name` VARCHAR(30) NOT NULL,
`email` VARCHAR(50) NOT NULL,
`phone` INT(15) NULL,
`comment` VARCHAR(500) NOT NULL,
`datee` DATE NOT NULL)";
$conn->exec($sql);
} catch(PDOException $e)
{
echo $sql . "<br> " . $e->getMessage();
}
$conn = null;
}