I'd like to suppress MySQL errors being printed in the header, so that errors can be passed back into the PHP page...

My current code is as follows:

if ( ! mysql_connect($server, $database_username, $database_password) )
{ $error = "There was error when attempting to connect to the specified database server: ".mysql_error(); }

When I deliberately enter wrong a wrong server, username, or password, I continue to get errors printed at the top of the page. How do I stop this?

Thanks!

Recommended Answers

All 2 Replies

Try this:

if (! @mysql_connect($server, $database_username, $database_password)) {
  $error = "There was error when attempting to connect to the
	specified database server: ".mysql_error();
}

Fantastic. Thanks!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.