Jump to content

Is this correct?


maxudaskin

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.