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)

 

Link to comment
Share on other sites

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)

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.