Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 694971
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T02:54:41+00:00 2026-05-14T02:54:41+00:00

I am a newbie to both PHP and WordPress (but do ok in C#),

  • 0

I am a newbie to both PHP and WordPress (but do ok in C#), and am struggling to understand the error handling in a custom plugin I am attempting to write. The basics of the plugin is to query an exsiting MSSQL database (note its not the standard MYSQL db…) and return the rows back to the screen. This was working well, but the hosting provider has taken my database offline, which led me to the error handling problem (which I thought was ok).

The following code is failing to connect to the database (as expected), but puts an error onto the screen and stops the page processing. It does not even output the ‘or die’ error text.

QUESTION: How can I just output a simple “Cant load data” message, and continue on normally?

function generateData()

{

 global $post; 

 if ("$post->post_title" == "Home")
 { 
  try 
  {
   $myServer = "<servername>";
   $myUser = "<username>";
   $myPass = "<password>";
   $myDB = "<dbName>"; 

   //connection to the database
   $dbhandle = mssql_connect($myServer, $myUser, $myPass) 
                              or die("Couldn't open database $myDB"); 


            //... query processing here...
        }
        catch (Exception $e)
  {
         echo "Cannot load data<br />";
  }

 }

 return $content;
}

Error being generated: (line 31 is $dbhandle = mssql_connect…)

Warning: mssql_connect() [function.mssql-connect]: Unable to connect to server: <servername> in <file path> on line 31

Fatal error: Maximum execution time of 30 seconds exceeded in <file path> on line 31

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T02:54:41+00:00Added an answer on May 14, 2026 at 2:54 am

    First of all, if mssql_connect raises a warning when there’s a problem, there is not much you can do to avoid it : the only thing you could do is hide it, using the @ operator :

    if (($dbhandle = @mssql_connect($myServer, $myUser, $myPass)) === false) {
        // connection failed
    }
    

    Note : you should not die() when a connection error occurs : it’ll stop the execution of the whole application, which is most certainly not desired.

    The Fatal Error is a second problem *(which is probably a consequence of the first one)*.

    Note that you cannot recover from a Fatal Error : it is Fatal. Which means you must avoid it, one way or another.

    Here, the error is that your script is working for more than max_execution_time seconds ; as the error is reported on the mssql_connect line, I suppose the script is waiting for the connection to succeed, and it doesn’t get etablished in less that 30 seconds.

    I don’t have an SQL Server database to test, but looking at the [Runtime Configuration][4] section of the manual for mssql, I’d say that these look interesting :

           name               Default value
    mssql.connect_timeout        "5"
    mssql.timeout                "60"
    

    You could try changing those,

    • either in your php.ini file, if you can modify it
    • or using ini_set() before trying to connect.

    In the second case, something like this might do the trick :

    ini_set('mssql.connect_timeout', '3');
    ini_set('mssql.timeout', '3');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Newbie to LINQ, and trying to write the following query... select f.Section_ID, f.Page_ID, f.SortOrder,
I'm newbie on both ruby and linux, so I'm sure this is trivial but
Newbie here...can I write one program which incorporates .NET LINQ and also various Java
Total newbie question but this is driving me mad! I'm trying this: myInt =
What happens: When I write two values in both text boxes, the page doesn't
Newbie question: Python 2.6, Ubuntu 10.04, I can import both pycurl and curl ,
am newbie to both WCF and Named pipes. I need a way to securely
Here goes newbie question number 5, but I don't have a teacher.. so.. anyhow
Sorry for this newbie question but I cannot figure how I can do this..
Newbie question. I have a NSMutableArray that holds multiple objects (objects that stores Bezier

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.