Jump to content

mysql function connect help :( errors all over the place :(


jamesxg1

Recommended Posts

<?php

class member {

private $firstname;
private $lastname;
private $username;
private $password;
private $telephone;
private $address;
private $postcode;
private $dbpassword;
private $dbusername;
private $dbname;
private $dbhost;
private $connect;

     function __construct($_dbpassword = "", $_dbusername = "root", $_dbname = "music", $_dbhost = "localhost", $_firstname = "none", $_lastname = "none", $_username = "none", $_password = "none", $_telephone = "00000000000", $_address = "none", $_postcode = "0000000") {

$this->dbpassword = $_dbpassword;
$this->dbusername = $_dbusername;
$this->dbname = $_dbname;
$this->dbhost = $_dbhost;
$this->firstname = $_firstname;
$this->lastname = $_lastname;
$this->username = $_username;
$this->password = $_password;
$this->telephone = $_telephone;
$this->address = $_address;
$this->postcode = $_postcode;

     }

     function DBconnect($_dbpassword, $_dbusername, $_dbname, $_dbhost) {
        $this->connect = mysql_connect("$this->dbhost", "$this->dbusername", "$this->dbpassword") or die(mysql_error());
         mysql_select("$this->dbname", $connect) or die(mysql_error());
         return ($this->connect);
         mysql_close("$this->connect");
     }

     function getfirstname() {
         return ($this->firstname);
     }
     
     function getlastname() {
         return ($this->lastname);
     }
     
     function getusername() {
         return ($this->username);
     }

     function getpassword() {
         return ($this->password);
     }

     function gettelephone() {
         return ($this->telephone);
     }

     function getaddress() {
         return ($this->address);
     }

     function getpostcode() {
         return ($this->postcode);
     }

     function save() {
        mysql_query("INSERT INTO `members` VALUES('getfirstname()', 'getlastname()', 'getusername()', 'getpassword()', 'gettelephone()', 'getaddress()', 'getpostcode()')") or die(mysql_error());
    }
}

$test = new member('test' , 'test' , 'test', 'test', 'test', 'test', 'test');
$test->DBconnect();
$test->save();

?>

 

 

heres the errors,

 

Warning: Missing argument 1 for member::DBconnect(), called in C:\xampp\htdocs\test\db.php on line 75 and defined in C:\xampp\htdocs\test\db.php on line 34

 

Warning: Missing argument 2 for member::DBconnect(), called in C:\xampp\htdocs\test\db.php on line 75 and defined in C:\xampp\htdocs\test\db.php on line 34

 

Warning: Missing argument 3 for member::DBconnect(), called in C:\xampp\htdocs\test\db.php on line 75 and defined in C:\xampp\htdocs\test\db.php on line 34

 

Warning: Missing argument 4 for member::DBconnect(), called in C:\xampp\htdocs\test\db.php on line 75 and defined in C:\xampp\htdocs\test\db.php on line 34

 

Warning: mysql_connect() [function.mysql-connect]: Unknown MySQL server host 'geedy123' (11001) in C:\xampp\htdocs\test\db.php on line 35

Unknown MySQL server host 'geedy123' (11001)

 

This second line is never executed.. It's also very unwise to close something you just opened.

 

return ($this->connect);
mysql_close("$this->connect");//

 

You are calling Member::DbConnect() with no parameters, that's why:

Warning: Missing argument 1 for member::DBconnect(), called in C:\xampp\htdocs\test\db.php on line 75 and defined in C:\xampp\htdocs\test\db.php on line 34
Warning: Missing argument 2 for member::DBconnect(), called in C:\xampp\htdocs\test\db.php on line 75 and defined in C:\xampp\htdocs\test\db.php on line 34
Warning: Missing argument 3 for member::DBconnect(), called in C:\xampp\htdocs\test\db.php on line 75 and defined in C:\xampp\htdocs\test\db.php on line 34
Warning: Missing argument 4 for member::DBconnect(), called in C:\xampp\htdocs\test\db.php on line 75 and defined in C:\xampp\htdocs\test\db.php on line 34

 

You are mistaken your db username for your db host:

Warning: mysql_connect() [function.mysql-connect]: Unknown MySQL server host 'geedy123' (11001) in C:\xampp\htdocs\test\db.php on line 35
Unknown MySQL server host 'geedy123' (11001)

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.