开发者

Problem on displaying the variables of a require file in PHP [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. 开发者_如何学编程 Closed 10 years ago.

My file includes/global.inc.php contains info about the DB and it is just like below

<?php
$glob['dbdatabase'] = 'xxx';
$glob['dbhost'] = 'localhost';
$glob['dbpassword'] = 'xxx';
$glob['dbusername'] = 'xxx';
?>

In my new PHP file I did that

<?php
require('includes/global.inc.php');
$host = $glob['dbhost'];
$user = $glob['dbusername'];
$pass = $glob['dbpassword'];
$database = $glob['dbdatabase'];
?>

but it is wrong because it won't let me connect. How can I assign correct the variables?

UPDATE

I pasted more variables.


You had a typo there.

It should be

$database = $glob['dbdatabase']; but not $database = $glob['database'];

Also, your $glob['dbusername'] seems to be not defined anywhere. `

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜