Define() Constant inside mysql connection string probelm

User Generated

zonenaqnb

Programming

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


User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

Explanation & Answer

you are create a new id okay...!


Anonymous
I use Studypool every time I need help studying, and it never disappoints.

Studypool
4.7
Trustpilot
4.5
Sitejabber
4.4

Related Tags