Php 未定义变量$db_hostname
我正在使用mysql,我试图简单地登录到数据库,但每当我尝试这样做时,就会出现一个错误Php 未定义变量$db_hostname,php,mysql,Php,Mysql,我正在使用mysql,我试图简单地登录到数据库,但每当我尝试这样做时,就会出现一个错误 Notice: Undefined variable: db_hostname in D:\xampp\htdocs\index.php on line 3 Notice: Undefined variable: db_username in D:\xampp\htdocs\index.php on line 3 Notice: Undefined variable: db_password in D:\xa
Notice: Undefined variable: db_hostname in D:\xampp\htdocs\index.php on line 3
Notice: Undefined variable: db_username in D:\xampp\htdocs\index.php on line 3
Notice: Undefined variable: db_password in D:\xampp\htdocs\index.php on line 3
下面是我的login.php代码
<?php//login.php
$db_hostname = 'localhost';
$db_database = 'publications';
$db_username = 'root';
$db_password = '';
?>
index.php的代码
<?php
require_once('login.php') ;
$db_server = mysql_connect($db_hostname, $db_username, $db_password);
if(!$db_server) die ("Unable to connect to MySQL: " . mysql_error());
?>
我不知道我做错了什么。更改此项(删除注释行或在其前面留出空间)
对,
在PHP中
<?php//login.php
$db_hostname = 'localhost';
$db_database = 'publications';
$db_username = 'root';
$db_password = '';
?>
<?php //login.php
$db_hostname = 'localhost';
$db_database = 'publications';
$db_username = 'root';
$db_password = '';
?>