Re: Notice:Use of undefined constant

From: Date: Sat, 22 Jan 2005 00:28:36 +0000
Subject: Re: Notice:Use of undefined constant
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-207017@lists.php.net to get a copy of this message
In a file, which is included into all my scripts, I defined constants (for MySQL access). PHP claims these constants as undifined constants, however, if I let them print out they have the right values (HOST='localhost'; NOT: HOST='HOST').
Where do you print them out? In the file in which they're defined or somewhere else? I was wrong. In my test scritp I do not include any other file, just define the constants, and print them out.
This suggests that your file containing the constants definitions was not included. Which means you're not going to be able to connect to mysql (unless by some fluke that your host happens to be 'HOST', etc). This could not happen, since I did not inserted any other file in my test script.
=========== But now I run the test script on my local machine without any notice. My php -v: PHP 4.3.2 (cgi), Copyright (c) 1997-2003 The PHP Group Zend Engine v1.3.0, Copyright (c) 1998-2003 Zend Technologies The script: --------------- <?php //-- Ez a teszt define( HOST, 'localhost'); define( USER, 'hae'); define( PWD, 'hae'); define( DB, 'haetest'); echo 'Host/User/db: ' . HOST . USER . DB; exit; /*-- Ez az eredeti define( HOST, 'localhost'); define( USER, 'h'); define( PWD, 'h'); define( DB, 'hae'); */ $link = mysql_connect( HOST, USER, PWD); mysql_select_db( DB); ... Thanks, Tamas -- Tamas Hegedus, Research Fellow | phone: (1) 480-301-6041 Mayo Clinic Scottsdale | fax: (1) 480-301-7017 13000 E. Shea Blvd | mailto:hegedus@mayo.edu Scottsdale, AZ, 85259 | http://hegedus.brumart.org

« previous php.general (#207017) next »