Solved

URGENT. Hide warning message when I can't connect with my SQL server

Posted on 2004-09-21
4
1,580 Views
Last Modified: 2012-08-14
Hi all,
I am experimenting troubles with my (ultra-cheap) mysql server. Connection string is:
  $dbh=mysql_connect ($hostName, $usr, $pwd);
  if ($dbh) {
       // etcetera

But when there is an database error I still want to show some information and avoid this warning message:

Warning: Too many connections in /var/apache/htdocs/tecnologico/index.php on line 16
Warning: MySQL Connection Failed: Too many connections in /var/apache/htdocs/tecnologico/index.php on line 16

I want to show a message like "Page in maintenance. Please try in some minutes." and an Icon.

How do I can avoid these annoying messages?

Thanks in advance.
0
Comment
Question by:Jaime Olivares
  • 2
4 Comments
 
LVL 32

Accepted Solution

by:
ldbkutty earned 450 total points
ID: 12116829
$dbh=@mysql_connect ($hostName, $usr, $pwd);

if(!dbh) {
 
   // echo your warning message here,..
}

@ suppresses the error.
0
 
LVL 3

Assisted Solution

by:scn
scn earned 50 total points
ID: 12116892
Set display_errors=Off  in php.ini will avoid any error display
0
 
LVL 32

Assisted Solution

by:ldbkutty
ldbkutty earned 450 total points
ID: 12116894
0
 
LVL 55

Author Comment

by:Jaime Olivares
ID: 12116900
Oh, just like DOS batch files. Those where easy points.
Thanks,
Jaime.
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now