jamesxg1 Posted July 16, 2009 Share Posted July 16, 2009 <?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) Quote Link to comment https://forums.phpfreaks.com/topic/166252-mysql-function-connect-help-errors-all-over-the-place/ Share on other sites More sharing options...
Maq Posted July 16, 2009 Share Posted July 16, 2009 You're not giving the DBConnect() method any parameters. Quote Link to comment https://forums.phpfreaks.com/topic/166252-mysql-function-connect-help-errors-all-over-the-place/#findComment-876747 Share on other sites More sharing options...
ignace Posted July 16, 2009 Share Posted July 16, 2009 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) Quote Link to comment https://forums.phpfreaks.com/topic/166252-mysql-function-connect-help-errors-all-over-the-place/#findComment-876749 Share on other sites More sharing options...
jamesxg1 Posted July 16, 2009 Author Share Posted July 16, 2009 You're not giving the DBConnect() method any parameters. =/ What do you mean =/ ? Quote Link to comment https://forums.phpfreaks.com/topic/166252-mysql-function-connect-help-errors-all-over-the-place/#findComment-876751 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.