编辑一个php连接nysql的网页 包括下列四种情况
假设web server与mysql都在同一部server
连线位置用 localhost即可
假设帐号为bbb
密码为ccc
复制程式
<?
echo "===================完整无误的连接=================<br>";
mysql_connect("localhost","bbb","ccc");
echo "===================连接server位置错误=================<br>";
mysql_connect("111.111.111.111","bbb","ccc");
echo "===================server与user正确,但passwd错误=================<br>";
mysql_connect("localhost","bbb","xxx");
echo "===================server正确,但user,passwd错误=================<br>";
mysql_connect("localhost","aaa","aaa");
?>
连上测试网页后将看到
===================完整无误的连接=================
(连线成功无任何讯息)
===================连接server位置错误=================
Warning: mysql_connect(): Can't connect to MySQL server on 飇.111.111.111' (4) in /srv/www/htdocs/phptest/php_mysql.php on line 5
===================server与user正确,但passwd错误=================
Warning: mysql_connect(): Access denied for user: 'bbb@localhost' (Using password: YES) in /srv/www/htdocs/phptest/php_mysql.php on line 7
===================server正确,但user,passwd错误=================
Warning: mysql_connect(): Access denied for user: 'aaa@localhost' (Using password: YES) in /srv/www/htdocs/phptest/php_mysql.php on line 9