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
david_88Asked:
Who is Participating?
 
Loganathan NatarajanConnect With a Mentor LAMP 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
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

 
biztigerConnect With a Mentor Commented:
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-Connect With a Mentor 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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.