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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.