Time remaining:
Define() Constant inside mysql connection string probelm

label Programming
account_circle Unassigned
schedule 0 Hours
account_balance_wallet $5

Hello All:

I am experiencing some difficulties getting some variables from an included file to my mysql connection. Here is what i have:

file one Called config.inc.php:

[PHP]

session_register("client_id");

$_SESSION['client_id'] = $_SESSION['SESS_ACCT_ID'];// 

$club_id=$_SESSION['client_id'];

ob_start();

include('../../../page_title.php');

ob_end_clean();

include('../../../datalogin.php');

if (!defined('DEFAULT_HOST')) define('DEFAULT_HOST','localhost');

if (!defined('DEFAULT_USER')) define('DEFAULT_USER',$account_user);

if (!defined('DEFAULT_PASS')) define('DEFAULT_PASS',$account_pass);

if (!defined('DEFAULT_DB')) define('DEFAULT_DB',$account_db); 

[/PHP]

the variables inside the define() are from the included datalogin.php.

Now, from my second file:

[PHP]

include('config.inc.php');

$link = @mysql_connect(DEFAULT_HOST, DEFAULT_USER, DEFAULT_PASS);

//var_dump($link);

if (!$link) {

   die('Could not connect: ' . mysql_error());

}

# mysql_query("SET SESSION time_zone = '-0:00';");

#mysql_query("SET NAMES 'utf8'", $link);

$db_selected = mysql_select_db(DEFAULT_DB, $link);

if (!$db_selected) {

   die ("Cannot use database: ".DEFAULT_DB.mysql_error());

}

[/PHP]

I'm unable to pass the variable to both:

[PHP]$link = @mysql_connect(DEFAULT_HOST, DEFAULT_USER, DEFAULT_PASS);[/PHP]

and

[PHP]

$db_selected = mysql_select_db(DEFAULT_DB, $link);

[/PHP]

However, I can echo (or print) to screen of:

DEFAULT_DB

DEFAULT_HOST

DEFAULT_USER

DEFAULT_PASS

Any ideas as to what is happening with the lost of the values in the db connection string


Nov 30th, -0001
you are create a new id okay...!
Jun 24th, 2013

I'm not able to connect to db. I get the following error:

Could not connect: Access denied for user 'username'@'localhost' (using password: NO)

Jun 24th, 2013

Did you know? You can earn $20 for every friend you invite to Studypool!
Click here to
Refer a Friend
...
Nov 30th, -0001
...
Nov 30th, -0001
Aug 22nd, 2017
check_circle
Mark as Final Answer
check_circle
Unmark as Final Answer
check_circle
Final Answer

Secure Information

Content will be erased after question is completed.

check_circle
Final Answer