Define() Constant inside mysql connection string probelm

Anonymous
timer Asked: Jun 24th, 2013
account_balance_wallet $5

Question Description

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


Tutor Answer

syedmudassar
School: UCLA

you are create a new id okay...!

flag Report DMCA
Review

Anonymous
Goes above and beyond expectations !

Similar Questions
Hot Questions
Related Tags
Study Guides

Brown University





1271 Tutors

California Institute of Technology




2131 Tutors

Carnegie Mellon University




982 Tutors

Columbia University





1256 Tutors

Dartmouth University





2113 Tutors

Emory University





2279 Tutors

Harvard University





599 Tutors

Massachusetts Institute of Technology



2319 Tutors

New York University





1645 Tutors

Notre Dam University





1911 Tutors

Oklahoma University





2122 Tutors

Pennsylvania State University





932 Tutors

Princeton University





1211 Tutors

Stanford University





983 Tutors

University of California





1282 Tutors

Oxford University





123 Tutors

Yale University





2325 Tutors