代码:$dbc = mysqli_connect('localhost','tom', '123123', 'aliendatabase')
or die('Error connecting to MySQL server.');
也分离了数据库一个mdf和一个ldf文件放在同一个文件夹中。
但是测试时还是出错,好像是无法连接SQL服务器位置:
Warning: mysqli_connect() [function.mysqli-connect]: (HY000/2003): Can't connect to MySQL server on 'localhost' (10061) in E:\Learing\phpWeb\aliens\report.php on line 22
Error connecting to MySQL server.
我用的是Microsoft SQL Server 2005,我的SQL是连接服务器的了,用户名和密码也没有错。求解。
回复讨论(解决方案)
你用的是微软Microsoft SQL却用mysqli去连接能连接上就见鬼了
mssql_connect
小弟刚学php,很多都不懂的。麻烦大神再帮我看看,我改了之后还是错。
$dbc = mysql_connect('localhost','tom', '123123', 'aliendatabase')
or die('Error connecting to MySQL server.');
$query = "INSERT INTO aliens_abduction (first_name, last_name, when_it_happened, how_long, " .
"how_many, alien_description, what_they_did, fang_spotted, other, email) " .
"VALUES ('$first_name', '$last_name', '$when_it_happened', '$how_long', '$how_many', " .
"'$alien_description', '$what_they_did', '$fang_spotted', '$other', '$email')";
$result = mysql_query($dbc, $query)
or die('Error querying database.');
mysql_close($dbc);
Warning: mysql_connect() [function.mysql-connect]: Can't connect to MySQL server on 'localhost' (10061) in E:\Learing\phpWeb\aliens\report.php on line 22
Error connecting to MySQL server.
本文原创发布php中文网,转载请注明出处,感谢您的尊重!