Jump to content

[SOLVED] global scope help


jarednz

Recommended Posts

file = main_api.php

[code]
$database = "blah";
[/code]

[code]
function dbConnect()
{
global $database, $hostname, $username, $password, $db;

$db = mysql_connect($hostname, $username, $password) or die ("Error connecting to database.");
mysql_select_db($database, $db) or die ("Couldn't select the database.");

return $db;
}
[/code]

returns..
[code]
Undefined variable: database in d:\inetpub\www\core\main_api.php on line 48
Couldn't select the database.
[/code]

what am I missing here? I've specified my global variables but it still complains?
Link to comment
https://forums.phpfreaks.com/topic/31649-solved-global-scope-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.