// TEST SQL SEVER CONNECTION
$sname = $_SESSION['servername'];
$testconnect = array('UID'=>$_SESSION['uid'],
'PWD'=>$_SESSION['pwd'],
'Database'=>$_SESSION['DB']);
$testconn = sqlsrv_connect($sname,$testconnect);
if(!$testconn)
{
echo '<BR>CONNECTION TEST FAILED TO SQL SERVER';
echo '<BR>ABORTING APPLICATION AND EXITING' ;
die(print_r(sqlsrv_errors(), true));
sqlsrv_close($testconn);
session_destroy();
EXIT;
}else{
echo '<BR>CONNECTION TEST SUCCEED TO SQL SERVER';
echo '<BR>CONTINUING WITH APPLICATION';
}
// END OF TESTING SQL CONNECTION
Could someone take a look and see what is wrongASKER
|
---|
<?php
session_start();
include 'includes/masticsconfig.php';
//AWS
require 'aws-autoloader.php';
use Aws\S3\S3Client;
use Aws\S3\Exception\S3Exception;
// NEXT LINE FOR DEVELOPMENT
//error_reporting(E_ERROR | E_PARSE | E_NOTICE);
error_reporting(E_ALL); ini_set('display_errors', 1);
// TEST SQL SEVER CONNECTION
// DEFINE CONNECTION
$servername = $_SESSION['servername'];
$connectionInfo = array('Database'=>$_SESSION['DB'], 'UID'=>$_SESSION['uid'], 'PWD'=>$_SESSION['pwd']);
$connect = sqlsrv_connect($servername,$connectionInfo);
if(!$connect)
{
echo '<BR>CONNECTION TEST FAILED TO SQL SERVER';
echo '<BR>ABORTING APPLICATION AND EXITING';
die(print_r(sqlsrv_errors(), true));
sqlsrv_close($connect);
session_destroy();
EXIT;
}else{
echo '<BR>CONNECTION TEST SUCCEED TO SQL SERVER';
echo '<BR>CONTINUING WITH APPLICATION';
}
// END OF TESTING SQL CONNECTION
// SET EXECUTION TIME
//ini_set('max_execution_time', 300);
// NEXT LINE FOR PRODUCTION
//error_reporting(E_ERROR | E_PARSE);
AND SO FORTH...
I can not attach the complete file because of sensitive info.This is a common issue. This is going to take a little work on your part, but will make it easier to troubleshoot. Create a complete, short test case using only enough code to demonstrate the issue and it should create the similar error in your larger code, but pointing to the exact line number in your test case.
die(print_r(sqlsrv_errors(), true));
is the wrong syntax. See https://www.php.net/manual/en/function.exit.php and https://www.php.net/manual/en/function.print-r.php . Adding 'true' causes it to return a value, not print it.
ASKER
$result = print_r($value, true);
die($result);
But nothing after the 'die' line above will be executed. ??
Correct - die - kills any further execution - so the incorrect EXIT and destroying the session and closing the query are in the void.
ASKER
sqlsrv_close($connect);
session_destroy();
EXIT;
PHP is a widely-used server-side scripting language especially suited for web development, powering tens of millions of sites from Facebook to personal WordPress blogs. PHP is often paired with the MySQL relational database, but includes support for most other mainstream databases. By utilizing different Server APIs, PHP can work on many different web servers as a server-side scripting language.
TRUSTED BY