这是我的config.inc.php,如下所示,
<?php
$mysql_host = "http://sql9.000webhost.com/phpMyAdmin/index.php?db=a7026992_poslaju&lang=en-utf-8&token=XXXXXXXXXXXXXXX";
$mysql_dbname = "dbName";
$mysql_username = "userName";
$mysql_password = "passWord";
$options = array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8');
try
{
$db = new PDO("mysql:host={$mysql_host};port=3306;dbname={$mysql_dbname};charset=utf8", $mysql_username, $mysql_password, $options);
}
catch(PDOException $ex)
{
die("Failed to connect to the database: " . $ex->getMessage());
}
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$db->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
if(function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc())
{
function undo_magic_quotes_gpc(&$array)
{
foreach($array as &$value)
{
if(is_array($value))
{
undo_magic_quotes_gpc($value);
}
else
{
$value = stripslashes($value);
}
}
}
undo_magic_quotes_gpc($_POST);
undo_magic_quotes_gpc($_GET);
undo_magic_quotes_gpc($_COOKIE);
}
header('Content-Type: text/html; charset=utf-8');
session_start();
?>
此完整错误消息如下,无法连接到数据库:SQLSTATE[HY000][2005]未知MySQL服务器主机http://sql9.000webhost.com/phpMyAdmin/index.php?db=DBDBDB&lang=en-utf-8&token=XXXXXXXXXX'(3)
您尝试过通过命令行登录吗???检查path
变量中是否设置了mysql。。。然后尝试:START->RUN->CMD
mysql -u <username> -p
并检查登录状态。。。请检查mysql服务是否在操作系统后台运行。
谢谢。