maxudaskin Posted March 13, 2008 Share Posted March 13, 2008 It is my first time using constants, I usually use variables, so I want to know if the following is correct. <?php /* PIREP SYSTEM - WRITTEN BY MAX UDASKIN - BASIC SYSTEM */ /* CONSTANTS.PHP */ /* Database */ define("DBSERVER","localhost"); // Database Server define("DBNAME","database"); // Database Name define("DBUSER","username"); // Database User define("DBPASS","password"); // Database Password /* Generic */ define("ROOT","http://www.someurl.com"); // Root URL ?> <?php /* PIREP SYSTEM - WRITTEN BY MAX UDASKIN - BASIC SYSTEM */ /* FUNCTIONS.PHP */ function initializePage (){ session_start(); include("constants.php"); include("login.php"); } function database($do){ if($do == "con"){ $con = mysql_connect(DBSERVER,DBUSER,DBPASS) or trigger_error(mysql_error(),E_USER_ERROR); mysql_select_db(DBNAME,$conn); }elseif($do == "dis"){ mysql_close($con); } } ?> If I was to call initializePage then database(con), would it work? Would it connect or give an error? Quote Link to comment https://forums.phpfreaks.com/topic/95904-is-this-correct/ Share on other sites More sharing options...
pocobueno1388 Posted March 13, 2008 Share Posted March 13, 2008 Why not just try it? Quote Link to comment https://forums.phpfreaks.com/topic/95904-is-this-correct/#findComment-491015 Share on other sites More sharing options...
maxudaskin Posted March 13, 2008 Author Share Posted March 13, 2008 I don't have it set up for a server. Quote Link to comment https://forums.phpfreaks.com/topic/95904-is-this-correct/#findComment-491018 Share on other sites More sharing options...
trq Posted March 13, 2008 Share Posted March 13, 2008 You would need to call database('con'), but yes, it would work. Quote Link to comment https://forums.phpfreaks.com/topic/95904-is-this-correct/#findComment-491023 Share on other sites More sharing options...
maxudaskin Posted March 13, 2008 Author Share Posted March 13, 2008 thx Quote Link to comment https://forums.phpfreaks.com/topic/95904-is-this-correct/#findComment-491027 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.