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? 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? 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. 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. 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 Link to comment https://forums.phpfreaks.com/topic/95904-is-this-correct/#findComment-491027 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.