Jump to content

is this style of coding considered obsolete?


otuatail

Recommended Posts

<?
// Bank Version 1.0.0   21-05-2014   Desmond O'Toole.
include ("secure/SecureFunctions.php");
include ("secure/SecureFunctionsLibAdmin.php");
session_start();
Session_Init();
$page = "Bank_EE Doc";

define ('hostname16', 'xxx'); // Des-otoole.co.uk
define ('username16', 'xxx');
define ('password16', 'xxx');
define ('database16', 'xxx');

function myErrorHandler($errno, $errstr, $errfile, $errline)
{
    switch ($errno) {
    case E_USER_ERROR:
		    $_SESSION['MyError'] = "Gotcha: <br>$errstr<br>$errfile<br>$errline";
				mailtoX('Error', $errstr,$_SESSION['MyError']);
				$redirect = "Location: myerror.php";
	      header($redirect);
	      exit(0);
        break;

    case E_USER_WARNING:
         echo "This is your last warning";
        break;

    case E_USER_NOTICE:
        echo "This is your final warning";
        break;

    default:
        echo "Just go away";
        break;
    }
    /* Don't execute PHP internal error handler */
    return true;
}

$old_error_handler = set_error_handler("myErrorHandler");



function connectDB($db)
{
    $host = hostname16;
    $user = username16;
    $pass = password16;
    $data = database16;

  if(!$link = @mysql_connect($host, $user, $pass))
    trigger_error('Can\'t connect to server: ('. $db . ')', E_USER_ERROR);

  if(!$database = @mysql_select_db($data, $link))
    trigger_error('Can\'t select database on: (' . $db . ')', E_USER_ERROR);
}

connectDB(CURRENT_DB);

echo "Hi there";

?>

Hi this coding works on another website although I have reduced it down here for clarity. I have had my website moved to another server and I can't connect now.

 

If there is a better way? I was given this coding from someone on this website about 4 years ago. I didn't want to use a strait connect because when there was difficulty connecting to the database I received an error giving me and any hacker all the details of the database server. This was to be a more controlled access.

Edited by ignace
Link to comment
Share on other sites

Ok thanks but without the server and website stuff I think I am safe. I would not be safe if I used the standard MySQL connection which could result in a web page unable to connect to this database at this server . I need security really.

 

sorry I didn't realise that I had shown the URL.

 

This is very important to me and very urgent to get going.

Edited by otuatail
Link to comment
Share on other sites

This is just a basic query. I have no server networking experience so a little help might solve this.

 

on my main website I can connect to the database using the code I supplied. I asked my provider for another sub domain and the same code does not connect to the database.

 

Is this because a sub domain has to access the database different?

Is it because the sub domain is on a different server from my main website and has not been set up

Does the website have to be on the same server as the sub domain website

 

This might sound stupid to you but it is the only idea I can come up with.

 

As stated above I am desperate to get this working.

 

PLEASE.

Edited by otuatail
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.