ChrisMartino Posted February 12, 2011 Share Posted February 12, 2011 Hey there, This has me stumped here. I'm supplying an array as a valid argument to the class like so: $mysql_configuration = array( 'MySQL_Host' => "localhost", 'MySQL_Username' => "fdsfdsfsdfsd", 'MySQL_Password' => "sdf-sdf543", 'MySQL_Database' => "sfsdfsdfsdf"); $radio_core = array('Main' => new Radio_Core($mysql_configuration), 'Requests' => new Radio_Requests, 'Accounts' => new Radio_Accounts, 'Content' => new Radio_Content); And here is my small class: class Radio_Core { public $mysql_handle; function __construct($mysql_array) { $this->mysql_handle = mysql_connect($mysql_array['MySQL_Host'], $mysql_array['MySQL_Username'], $mysql_array['MySQL_Password']); if(!$this->mysql_handle) { die("The station failed to connect to the MySQL database."); } else { mysql_select_db($mysql_array['MySQL_Database'], $this->mysql_handle); } return 1; } } And when it is called I am prompted with the error that the argument is missing for it? Warning: Missing argument 1 for Radio_Core::__construct(), called in /home/atomnetw/public_html/Chris-Martino.com/projects/radio/index.php on line 10 and defined in /home/atomnetw/public_html/Chris-Martino.com/projects/radio/Core/radio.class.php on line 15 Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'atomnetw'@'localhost' (using password: NO) in /home/atomnetw/public_html/Chris-Martino.com/projects/radio/Core/radio.class.php on line 17 Thanks for your time! Link to comment https://forums.phpfreaks.com/topic/227471-warning-missing-argument-1-for-radio_core__construct/ Share on other sites More sharing options...
Jessica Posted February 12, 2011 Share Posted February 12, 2011 Is that the exact code? (obviously change/remove your passwords as you have done, but is that the exact code you're running? Link to comment https://forums.phpfreaks.com/topic/227471-warning-missing-argument-1-for-radio_core__construct/#findComment-1173320 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.