Search the Community
Showing results for tags 'config.inc.php'.
-
I have spent several months trying to teach myself web programming. I've managed to create a pretty cool dynamic website that works OK - so far. Then I found this great book. I am now trying to incorporate some of these important ideas into my code. My first attempt was to use the ideas behind the use of the config.inc.php and mysqli_connect.php files as explained in CH 18. This became a disaster as I tried various schemes to make it work which caused me to revert to the previously saved version of my code and start over. Before I do I'd like to be sure I have a clear understand of what I'm trying to do. The four 'connect' parameters are 'defined' as constants in the mysqli_connect.php file. In the config.inc.php file I defined the constant MYSQL as the path to this mysqli_connect.php file. As I read chapter 18 it says that I can now - require MYSQL; - in any script where I need to connect to the database. Questions: 1) When I run the app I get an error saying that I can not redefine a constant. The mysqli-connect.php file does attempt to re-define the four connect constants every time it is run in a script where it was 'included' and so the error is totally expected. What am I not getting here? 2) If I 'include' this file many times in scripts that echo html to the browser would not the connect constants then appear on my pages and be readable to anyone who wishes to "view source" in their browser? I'm sure I'm missing some important basic concept here. Some more info that might be relevant: I created a 'config' folder in both my localhost xampp development environment and on my GoDaddy server account right under the root directory. In both accounts I keep the config.inc.php file in there. In the local account I have placed the mysqli_connect.php file in the same config folder. In the GoDaddy account I placed it in a directory just above the root. This way in the config.inc.php the 'define MYSQL' path is different in each account and point to the respective locations for the mysqli_connect.php file. All files except 'config.inc.php' in the app can be the same this way. To migrate working code to the online account as I make improvements I just move all folders under the root in the xampp account to the GoDaddy server under the 'public_html' folder - except for the config folder which I should never have to touch. 3) Is this the correct way to do this? Regarding questions 1 and 2, I realize I have some very basic misunderstanding but I can't figure out what it is. Thanks.
- 5 replies
-
- config.inc.php
- mysqli_connect.php
-
(and 1 more)
Tagged with:
-
define ('BASE_URI', '/c:/xampp/htdocs/');----------I am Window 7 user and is this the right path ? define ('BASE_URL', 'www.example.com/'); define ('PDFS_DIR', BASE_URI . 'pdfs/'); // Added in Chapter 5. define ('MYSQL', BASE_URI . 'mysql.inc.php'); Hi (Larry)all, thanks for helping me