Du kunne jo lave det om til OOP
- class Connect
- {
- private $host;
- private $user;
- private $pass;
- private $db;
-
- public function __construct($host, $user, $pass, $db)
- {
- $this->host = $host;
- $this->user = $user;
- $this->pass = $pass;
- $this->db = $db;
- }
-
- protected function opret()
- {
- $connection = mysql_connect($this->host, $this->user, $this->pass);
- if(!mysql_select_db($this->db, $connection))
- {
- return "Error: ". mysql_error();
- }
- }
-
- public function udgiv()
- {
- return $this->opret();
- }
- }
-
- $con = new Connect("localhost", "admin", "1admin", "test");
- $con->udgiv();
Koden er ikke testet.
Indlæg senest redigeret d. 14.03.2012 12:10 af Bruger #16025