Use of undefined constant

In order to understand an error following require_once() I’ve made a simple test script that throws the same error. Can someone please explain what’s not working?
[php] //…tstCMMDS.php…
echo date('l dS \of F Y h:i:s A ');
//require_once works
The error mssgs are …
PHP Notice: Use of undefined constant DB_PASSWORD - assumed ‘DB_PASSWORD’ in /home…/lib/php
/cnnct2mysql.php on line 9
PHP Notice: Use of undefined constant DB_HOST - assumed ‘DB_HOST’ in /home/…/lib/php/cnnct2mysql.php
on line 10
PHP Notice: Use of undefined constant DB_NAME - assumed ‘DB_NAME’ in /home/…/lib/php/cnnct2mysql.php
on line 11
The script for cnnct2mysql.php has these constants defined, as follows…
[php] // cnnct2mysql.php
DEFINE (DB_USR, “intelleckdb12”);
DEFINE (DB_PASSWORD, “xxxxxxxx”);
DEFINE (DB_NAME, “ntelleckdb”);

$db_connection = mysql_connect (DB_HOST, DB_USR, DB_PASSWORD);
mysql_select_db (DB_NAME);
Apparently Define() doesn’t work as I’m using it.
I’m stuck. Help appreciated.

Check the PHP manual for define(). You’ll see this:

bool define ( string $name , mixed $value [, bool $case_insensitive = false ] )

What you are doing is using an undefined constant instead of “string $name”

So the proper syntax would be

[php]define(‘DB_PASSWORD’, “xxxxxxxx”);[/php]

With your help M@tt, I’ve moved past several hurdles and then have had several setbacks. Most troubling has not been coding issues, but ISP service and unexpected changes that came as surprises.

I’d like to thank you again for your support. :slight_smile:

I’ll mark this chain as solved. I suspect I’ll be back by tomorrow wirh a new problem ('cannot redeclare clsss.phpmailer in …) – still reading stuff on the web. :frowning:


Sponsor our Newsletter | Privacy Policy | Terms of Service