Jump to content

[SOLVED] Warning: mysqli_connect()


chokk

Recommended Posts

Hey,I'm trying to learn OOPHP. I keep running into problems I can't quite figure out, because OOP is a totally new concept to me.

//classes.phpclass testSys{	protected $host = 'localhost';	protected $user = 'root';	protected $pass = '';	protected $db = 'system';		function __construct(){		$connect = mysqli_connect($this->host, $this->user, $this->pass, $this->db);		if(!$connect){			echo '<p style="color:red;">Connection problems!</p>';		}		else{			echo '<p style="color:red;">Connection established!</p>';		}	}		function doConnect(){		$connect = mysqli_connect($this->host, $this->user, $this->pass, $this->db) or die('Connection problems.');		mysqli_set_charset($connect, 'utf-8');		return $connect;	}		function doFilter($data){		$data = htmlspecialchars($data);		$data = trim($data);		$data = stripslashes($data);		$data = preg_replace("#'#", "'", $data);		$data = preg_replace("#`#", "‘", $data);		$data = preg_replace('#"#', """, $data);		return $data;	}}

And here's the error I'm getting:

Warning: mysqli_connect() [function.mysqli-connect]: (28000/1045): Access denied for user 'SYSTEM'@'localhost' (using password: NO) in C:\wamp\www\test\classes.php on line 10Connection problems!Warning: mysqli_connect() [function.mysqli-connect]: (28000/1045): Access denied for user 'SYSTEM'@'localhost' (using password: NO) in C:\wamp\www\test\classes.php on line 20Connection problems.

Link to comment
Share on other sites

you did not filled up password i think. make sure host,password,user are correct and database name already exist.

Link to comment
Share on other sites

There is no password and the database does exist. I have a subclass that extends from this main class which posts data to a table within the database. It worked yesterday but now it doesn't. I created a new subclass to read data from another table and now it doesn't connect...?Oh wait here's the thing. I accidentally changed the variables containing the login information from within the subclass. D'oh!

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...