• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 231
  • Last Modified:

PHP want to display error messages

Is my sytax correct (or die(mssql_error());
for error outputting for this php script or could it be to do withwebserver setup

CODE
$strSQL="select* from tbl_test";
$rs = mssql_query($strSQL) or die(mssql_error());

Result:
blank page but SQL SHOULD FAIL becuase table does not exist

Many thanks


Blank page no error messaeg
0
david_88
Asked:
david_88
  • 3
  • 2
  • 2
  • +1
3 Solutions
 
Loganathan NatarajanLAMP DeveloperCommented:
print this on top,


<?php
 
ini_set('error_reporting', E_ALL);
ini_set('display_errors', 'On');
ini_set('display_startup_errors', 'On');
 
?>

Open in new window

0
 
biztigerCommented:
instead of mssql_error() try

mssql_get_last_message()
0
 
david_88Author Commented:
     logudotcom: that worked a charm on my sql statement!!! what can i add to the below code to output an error message because something is wrong with the below part but again only blank page

if (mssql_num_rows($rs)>1)) {

                        $_SESSION['logid'] = $rs['SystemUserID'];
            $_SESSION['Sysuser'] = $rs['Username'];

            header("Location: ".$redir);
            exit();
      }else{

            header("Location: ".$redir);
            exit();      

      }

many thanks

dave
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
biztigerCommented:
Modified code:

$strSQL="select* from tbl_test";
$rs = mssql_query($strSQL) or die(mssql_get_last_message());

Open in new window

0
 
Loganathan NatarajanLAMP DeveloperCommented:
i doubt there may be problem in the header();?

just print the echo in the condition where it falls like...
0
 
biztigerCommented:
ommit the exit() statement, I think and check if any change occurs.
0
 
darren-w-Commented:
put this at the top of your script

set_error_handler("on_error");

also have a look at your php / webserver error logs
0
 
david_88Author Commented:
good quick advice thanks guys saved me alot of time yesterday

dave
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 3
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now