Problem on displaying the variables of a require file in PHP [closed]
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.
`
精彩评论