Solved

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

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Consider the following scenario: You are working on a website and make something great - something that lets the server work with information submitted by your users. This could be anything, from a simple guestbook to a e-Money solution. But what…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
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.

706 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

20 Experts available now in Live!

Get 1:1 Help Now