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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
Fundamentals of JavaScript

Learn the fundamentals of the popular programming language JavaScript so that you can explore the realm of web development.

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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.