Solved

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

Posted on 2004-09-21
4
1,578 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
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.

912 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