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

  • SEARCH
  • Home
  • 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 8327031
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T00:57:56+00:00 2026-06-09T00:57:56+00:00

I wrote a php page/script that connects to an ms sql db and execute

  • 0

I wrote a php page/script that connects to an ms sql db and execute some inserts/updates.
It is possible that errors might occur so I would like to log them to a file.

The current version of the logging function is:

function logMsSqlError($fileStream){
        fwrite($fileStream, "Error: ".mssql_get_last_message()."\n");
        fwrite($fileStream,urldecode(http_build_query( error_get_last()))."\n" );
}

And it’s used like:

 $res = mssql_query($q, $dbhandle);
        if(!$res) {
                logMsSqlError($fh);
                fclose($fh);
                die("query failed");
        }

The problem is that in the web page I see a lot of useful information when an error occurs:

"Warning: mssql_query(): message: The INSERT statement conflicted with the FOREIGN KEY constraint "FK_Test1". 

The conflict occurred in database "testDb", table "dbo.testTable", column 'TestColumn'. (severity 16) in /var/www/html/sms/utilities.php on line 31 

Warning: mssql_query(): General SQL Server error: Check messages from the SQL Server (severity 16) in /var/www/html/sms/utilities.php on line 31 

Warning: mssql_query(): Query failed in /var/www/html/sms/utilities.php on line 31"

while in the log file I’m unable to catch all these details. Right now I get:

Error: The statement has been terminated.
type=2&message=mssql_query(): Query failed&file=/var/www/html/sms/utilities.php&line=31

How can I get the details I have in the browser error in the log file? (where do the details in the web page come from?)

  • 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-06-09T00:57:58+00:00Added an answer on June 9, 2026 at 12:57 am

    You have a couple options: you can either turn on log_errors in php.ini or use the set_error_handler function to integrate your own logging system with the PHP error handler.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First of all, I wrote a simple php page, that picks up some variables
I wrote a PHP-CLI script that mixes two audio (.WAV PCM) files (with some
I have a PHP script that I wrote, and one of the pages connects
I wrote the following snippet in order to handle errors. (Page.php gets included in
I wrote a PHP script that retrieves values from a MySQL Query. I used
I wrote a php script that must be run on the php interpreter (Without
So I wrote a script in PHP that requires JavaScript to run with it.
I've modified and cleaned this PHP script that someone else wrote. Locally on my
I wrote a php-redirect script, that sends the user to different pages, depending on
I have a full working php script for user activation that I wrote. Fully

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.