读书人

PHP5如何连接不上MySQL数据库

发布时间: 2012-04-25 19:32:32 作者: rapoo

PHP5怎么连接不上MySQL数据库?
代码
<?php
$db_host='localhost';
$db_database='120422db_1';
$db_username='root';
$db_password='1234';

?>


<?php

include('120422php_1.php');

$connection = mysql_connect($db_host, $db_username, $db_password);
if(!$db_connection){
die ("Could not connect to the database: <br />". mysql_error());
}
?>


结果:Could not connect to the database:

[解决办法]
if(!$db_connection){
用错了变量!
应该是 $connection

读书人网 >PHP

热点推荐