Jeg har et lite problem med å kunne bruke .conf filen. Det som er problemet er at jeg ønsker å bruke den delen som er markert under #hidden. Kodene jeg bruker ser dere under,
data.conf File
In my PHP file i have this code:
Dette er det jeg får som output
SQLSTATE[3D000]: Invalid catalog name: 1046 No database selected
Takk på forhånd
data.conf File
Kode
# global variables pageTitle = "Main Menu" bodyBgColor = #000000 tableBgColor = #000000 rowBgColor = #00ff00 [Customer] pageTitle = "Customer Info" [Login] pageTitle = "Login" focus = "username" Intro = """This is a value that spans more than one line. you must enclose it in triple quotes.""" # hidden section -> This par is where my problem starts. I can't use this [.Database] host=my.example.com db=ADDRESSBOOK user=php-user pass=foobarenter code here
Kode
require_once("configs/smarty/Smarty.class.php"); $smarty = new Smarty; $smarty->setConfigDir('configs/'); $smarty->setTemplateDir('templates/'); $smarty->setCompileDir('templates_c/'); $smarty->setPluginsDir('plugins/'); $smarty->setCacheDir('cache/'); ## DATABASE ## $database = $smarty->configLoad('data.conf', 'Database'); $db_host = $database->getConfigVars('host'); $db_name = $database->getConfigVars('db'); $db_user = $database->getConfigVars('user'); $db_pass = $database->getConfigVars('pass'); try{ $pdo = new PDO('mysql:host='.$db_host.';dbname='.$db_name, $db_user, $db_pass); $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); }catch(PDOException $e){ die($e->getMessage()); }
SQLSTATE[3D000]: Invalid catalog name: 1046 No database selected
Takk på forhånd