0

I can handle errors just fine on MySQL, but what about warnings? If I use the following code I still get to see the warning, while that is not what I want:

if(mysql_connect($host, $user, $pass)) {
			 $conn_server = true;
		}
	else {
			$msg = "Fout bij verbinden naar de server.";
			$type = "error";
		}
	
	if($conn_server = true) {
		if(mysql_select_db($database)) {
				$msg = "Verbonden met de server en database.";
				$type = "notification";
			}
		else {
				$msg = "Fout bij verbinden naar de database.";
				$type = "error";
			}
		}
4
Contributors
6
Replies
7
Views
8 Years
Discussion Span
Last Post by brechtjah
0

if($conn_server = true) {

This is a comparison operator and you are comparing if the value of $conn_server is "true". So, you should use == instead of =.
Apart from that, I don't see anything wrong with your code which could cause an error.

0

Bah, what a stupid mistake, I can't believe it. Anyway the warnings include, but are not limited to:
Warning: mysql_connect() [function.mysql-connect]: Access denied for user **'@'localhost' (using password: YES) in /opt/lampp/htdocs/VC/connect.php on line 9
arning: mysql_connect() [function.mysql-connect]: Unknown MySQL server host 'locahost' (1) in /opt/lampp/htdocs/VC/connect.php on line 9

In other words: when the connection information is wrong, I get warnings, but I don't want these :)
Thanks

0

You can use @ before mysql statements to supress the warning and error messages. @mysql_connect(...)

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.