Jump to content

Silly OO problem!


jonsamwell

Recommended Posts

Hi,

 

I am having problems getting this method to see the variables! I keep getting the error.

 

'Fatal error: Cannot access empty property in C:\wamp\www\parser\Parser\Database\Database_Connection.php on line (db_connect() method)'

 

I don't understand why the variables are seen as empty as they are intitalised????

 

class Database_Connection {

    var $username = 'User_main';
    var $password = 'password';
    var $server = 'localhost';
    var $database_name = 'pricing';
    var $link_identifier = null;


    function _constructor()
    {//Default Constructor
    }

    function db_connect()
    {
        $this->$link_identifier = mysql_connect($this->$server, $this->$username, $this->$password);
    }
}

 

If i hard code the values everything works fine.

Link to comment
https://forums.phpfreaks.com/topic/140573-silly-oo-problem/
Share on other sites

mysqli stands for "mysql Improved". It's recommended extension to use, when connecting to MySQL server version 4.1 or later.

 

Foreign key capability is a thing of storage engine itself. MyISAM doesn't have it, InnoDB does.

 

whats the big difference between mysql and mysqli?

 

It's object oriented, enables use of prepared statements (and some other features, that mysql lacks), it is said to be faster.

Link to comment
https://forums.phpfreaks.com/topic/140573-silly-oo-problem/#findComment-735654
Share on other sites

Doing the same here....i find it dificult to not make things over complicated sometimes...i end up getting rid of something i dont need in my OO code all the time... i star out thinking i think i need it when in fact i dont/wont.. :-)

 

cheers!

Link to comment
https://forums.phpfreaks.com/topic/140573-silly-oo-problem/#findComment-735713
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.