[HELP] PHP Coding [HELP]

Status
Not open for further replies.

JoshuaLuke

Posting Freak
Jan 29, 2012
529
51
Hey,

As some of you may know, im developing ParaCMS. Ive come across a small problem.
I have a code:
Code:
mysql_connect($CONFIG['mysql']['hostname'],$CONFIG['mysql']['username'],$CONFIG['mysql']['password']) or die("Could not connect to server, error: ".mysql_error());
mysql_select_db($CONFIG['mysql']['database']) or die("Could not connect to database, error: ".mysql_error());
and I want to put it in a global.php document. Rather than having it in my config.php. I have tried to use include 'config.php' in my global.php page, but its failing. CODE:

Config:
Code:
<?php

/*=======================================================================
| Paranormal CMS - A Habbo hotel Content Managment System
| #######################################################################
| Copyright 2012 Josh 'JoshuaLuke or FreddyZoom' All Rights Reserved
| This is a free CMS: You may not distribute this under ANY condition
| without the owners permission. Failure to do so may result in
| legal action.
| #######################################################################
| This program is distributed in the hope that it will be useful and
| efficient for your needs.
\======================================================================*/

// Below is the configuration for MySQL. Please fill all of it out correctly in order for the website to function

$CONFIG['mysql']['hostname'] = 'localhost'; // MySQL Host

$CONFIG['mysql']['username'] = 'root'; // MySQL Username

$CONFIG['mysql']['password'] = 'hello12'; // MySQL Password

$CONFIG['mysql']['database'] = 'phx'; // MySQL Database
?>

Global:
Code:
<?php
include_once 'config.php';

mysql_connect($CONFIG['mysql']['hostname'],$CONFIG['mysql']['username'],$CONFIG['mysql']['password']) or die("Could not connect to server, error: ".mysql_error());
mysql_select_db($CONFIG['mysql']['database']) or die("Could not connect to database, error: ".mysql_error());


?>

If you can sort my problams, please tell me :)
 

Alam

shietttt
Jul 3, 2011
433
166
I already did, after posting:

GLOBAL:
Code:
<?php
 
class engine {
 
    public function __construct() {
        global $CONFIG;
        $CONFIG = array();
   
            $CONFIG = mysql_connect($CONFIG['mysql']['hostname'], $CONFIG['mysql']['username'], $CONFIG['mysql']['password']) or die("y u no put right password");
            mysql_select_db($CONFIG['mysql']['database'], $CONFIG) or die("wrong database");
    }
}
 
?>

CONFIG:
Code:
<?php
 
/*=======================================================================
| Paranormal CMS - A Habbo hotel Content Managment System
| #######################################################################
| Copyright 2012 Josh 'JoshuaLuke or FreddyZoom' All Rights Reserved
| This is a free CMS: You may not distribute this under ANY condition
| without the owners permission. Failure to do so may result in
| legal action.
| #######################################################################
| This program is distributed in the hope that it will be useful and
| efficient for your needs.
\======================================================================*/
 
$CONFIG = array();
 
// Below is the configuration for MySQL. Please fill all of it out correctly in order for the website to function
 
$CONFIG['mysql']['hostname'] = 'localhost'; // MySQL Host
 
$CONFIG['mysql']['username'] = 'root'; // MySQL Username
 
$CONFIG['mysql']['password'] = 'hello12'; // MySQL Password
 
$CONFIG['mysql']['database'] = 'phx'; // MySQL Database
?>

Cant you just correct them for me :l
You didn't initiate the new class
Type in $engine = new Engine();
(OUTSIDE THE CLASS - Right above of ?>)
 

RastaLulz

fight teh power
Staff member
May 3, 2010
3,926
3,921
I already did, after posting:

GLOBAL:
Code:
<?php
 
class engine {
 
    public function __construct() {
        global $CONFIG;
        $CONFIG = array();
     
            $CONFIG = mysql_connect($CONFIG['mysql']['hostname'], $CONFIG['mysql']['username'], $CONFIG['mysql']['password']) or die("y u no put right password");
            mysql_select_db($CONFIG['mysql']['database'], $CONFIG) or die("wrong database");
    }
}
 
?>

Cant you just correct them for me :l
Why are you reseting $CONFIG? When you set $CONFIG to Array(), anything that it was set to is now gone, and $CONFIG will only return Array().

Remove:
PHP:
$CONFIG = array();
 

JoshuaLuke

Posting Freak
Jan 29, 2012
529
51
Why are you reseting $CONFIG? When you set $CONFIG to Array(), anything that it was set to is now gone, and $CONFIG will only return Array().

Remove:
PHP:
$CONFIG = array();

I emoved it. Everything failed, can someone do it all for me, like config and the global, i cant seem to figure out whats happening :S
 

Alam

shietttt
Jul 3, 2011
433
166
I emoved it. Everything failed, can someone do it all for me, like config and the global, i cant seem to figure out whats happening :S
We are not your slave figure it out your self , and if you can't get this working then you will hardly release a stable CMS.
 

JoshuaLuke

Posting Freak
Jan 29, 2012
529
51
We are not your slave figure it out your self , and if you can't get this working then you will hardly release a stable CMS.

Cant people read THE CMS ISNT GOING TO BE RELEASED UNTIL I AM FLUENT WITH PHP. I asked someone to do it because I couldnt, no one has figured it out.
 

Livar

Now 35% cooler!
Oct 15, 2010
846
86
Adil you fucking faggot, stop crying and help him, you don't need to use Arrays, here's my configuration:

PHP:
<?php
/*==========================================================================\
| LeightCMS - Content Management System for Habbo Hotel Private Servers     |
| Compatible with PhoenixEmulator 3.0 (+ higher builds)                     |
| ==========================================================================|
| Revision: 1         Copyright (c) Livar Shekhani               Build: 0.2 |
| ==========================================================================|
| Attention: If any bugs occur contact Livar on *****                    |
\==========================================================================*/ 

//So the page doesn't load directly!
if(!DEFINED('SECURITY')) { die ('Direct Loading is Forbidden!'); }

//System Configuration variables
$Configuration['System']['http'] = 'http://127.0.0.1';
$Configuration['System']['name'] = 'Phoenix 3.0';
$Configuration['System']['name_extension'] = 'Hotel';
$Configuration['System']['password_encryption'] = 'sha1';
$Configuration['System']['password_hash'] = 'hYi^*\'lol%"?leight';

//System SQL variables
$Configuration['Database']['host'] = '127.0.0.1';
$Configuration['Database']['user'] = 'root';
$Configuration['Database']['pass'] = 'lala1';
$Configuration['Database']['data'] = 'phoenix3';

?>

See, I haven't used any arrays.

And here's my global.php:

PHP:
<?php
/*==========================================================================\
| LeightCMS - Content Management System for Habbo Hotel Private Servers     |
| Compatible with PhoenixEmulator 3.0 (+ higher builds)                     |
| ==========================================================================|
| Revision: 1         Copyright (c) Livar Shekhani               Build: 0.2 |
| ==========================================================================|
| Attention: If any bugs occur contact Livar on *****                    |
\==========================================================================*/ 

//Running some required statements
session_start();
error_reporting(E_ALL);
DEFINE('SECURITY', true);

//Calling our classes
require_once 'includes/configuration.php';
require_once 'includes/application.php';
require_once 'includes/database.php';

//Initiating our Classes
$app = new Application();
$db = new Database($app->Configuration['Database']['host'], $app->Configuration['Database']['user'], $app->Configuration['Database']['pass'], $app->Configuration['Database']['data']);

echo $app->Configuration['System']['http'];

?>

I've made a var to call config vars from my app class.

;D
 

JoshuaLuke

Posting Freak
Jan 29, 2012
529
51
Adil you fucking faggot, stop crying and help him, you don't need to use Arrays, here's my configuration:

PHP:
<?php
/*==========================================================================\
| LeightCMS - Content Management System for Habbo Hotel Private Servers    |
| Compatible with PhoenixEmulator 3.0 (+ higher builds)                    |
| ==========================================================================|
| Revision: 1        Copyright (c) Livar Shekhani              Build: 0.2 |
| ==========================================================================|
| Attention: If any bugs occur contact Livar on ********                    |
\==========================================================================*/
 
//So the page doesn't load directly!
if(!DEFINED('SECURITY')) { die ('Direct Loading is Forbidden!'); }
 
//System Configuration variables
$Configuration['System']['http'] = 'http://127.0.0.1';
$Configuration['System']['name'] = 'Phoenix 3.0';
$Configuration['System']['name_extension'] = 'Hotel';
$Configuration['System']['password_encryption'] = 'sha1';
$Configuration['System']['password_hash'] = 'hYi^*\'lol%"?leight';
 
//System SQL variables
$Configuration['Database']['host'] = '127.0.0.1';
$Configuration['Database']['user'] = 'root';
$Configuration['Database']['pass'] = 'lala1';
$Configuration['Database']['data'] = 'phoenix3';
 
?>

See, I haven't used any arrays.

And here's my global.php:

PHP:
<?php
/*==========================================================================\
| LeightCMS - Content Management System for Habbo Hotel Private Servers    |
| Compatible with PhoenixEmulator 3.0 (+ higher builds)                    |
| ==========================================================================|
| Revision: 1        Copyright (c) Livar Shekhani              Build: 0.2 |
| ==========================================================================|
| Attention: If any bugs occur contact Livar on ********                    |
\==========================================================================*/
 
//Running some required statements
session_start();
error_reporting(E_ALL);
DEFINE('SECURITY', true);
 
//Calling our classes
require_once 'includes/configuration.php';
require_once 'includes/application.php';
require_once 'includes/database.php';
 
//Initiating our Classes
$app = new Application();
$db = new Database($app->Configuration['Database']['host'], $app->Configuration['Database']['user'], $app->Configuration['Database']['pass'], $app->Configuration['Database']['data']);
 
echo $app->Configuration['System']['http'];
 
?>

I've made a var to call config vars from my app class.

;D

Thank you, at least someone decent posts on the thread.
 

Adil

DevBest CEO
May 28, 2011
1,276
714
Adil you fucking faggot, stop crying and help him, you don't need to use Arrays, here's my configuration:

PHP:
<?php
/*==========================================================================\
| LeightCMS - Content Management System for Habbo Hotel Private Servers    |
| Compatible with PhoenixEmulator 3.0 (+ higher builds)                    |
| ==========================================================================|
| Revision: 1        Copyright (c) Livar Shekhani              Build: 0.2 |
| ==========================================================================|
| Attention: If any bugs occur contact Livar on ********                    |
\==========================================================================*/
 
//So the page doesn't load directly!
if(!DEFINED('SECURITY')) { die ('Direct Loading is Forbidden!'); }
 
//System Configuration variables
$Configuration['System']['http'] = 'http://127.0.0.1';
$Configuration['System']['name'] = 'Phoenix 3.0';
$Configuration['System']['name_extension'] = 'Hotel';
$Configuration['System']['password_encryption'] = 'sha1';
$Configuration['System']['password_hash'] = 'hYi^*\'lol%"?leight';
 
//System SQL variables
$Configuration['Database']['host'] = '127.0.0.1';
$Configuration['Database']['user'] = 'root';
$Configuration['Database']['pass'] = 'lala1';
$Configuration['Database']['data'] = 'phoenix3';
 
?>

See, I haven't used any arrays.

And here's my global.php:

PHP:
<?php
/*==========================================================================\
| LeightCMS - Content Management System for Habbo Hotel Private Servers    |
| Compatible with PhoenixEmulator 3.0 (+ higher builds)                    |
| ==========================================================================|
| Revision: 1        Copyright (c) Livar Shekhani              Build: 0.2 |
| ==========================================================================|
| Attention: If any bugs occur contact Livar on ********                    |
\==========================================================================*/
 
//Running some required statements
session_start();
error_reporting(E_ALL);
DEFINE('SECURITY', true);
 
//Calling our classes
require_once 'includes/configuration.php';
require_once 'includes/application.php';
require_once 'includes/database.php';
 
//Initiating our Classes
$app = new Application();
$db = new Database($app->Configuration['Database']['host'], $app->Configuration['Database']['user'], $app->Configuration['Database']['pass'], $app->Configuration['Database']['data']);
 
echo $app->Configuration['System']['http'];
 
?>

I've made a var to call config vars from my app class.

;D
Your config is in the format of an array.
 
Status
Not open for further replies.

Users who are viewing this thread

Top