I'm developing a code to insert data and print a list of products from a database in MS SQL and using a IIS server (for first time). Is imposible display errors (even setting on php.ini) and I haven't used PHP for a year, so I don't know what is wrong in my code. I'm not the administrator and he is busy, so it's difficult see the log file too. The web service only show "500 - Internal server error". Please help me to find a solution. There is the code:
<?php
$serverName = "server\SQLEXPRESS";
$connectionInfo = array( "Database"=>"dbName", "UID"=>"userID", "PWD"=>"pass");
$conn = sqlsrv_connect( $serverName, $connectionInfo);
$sql = "SELECT * FROM products";
if( $conn ) {
$stmt = sqlsrv_query( $conn, $sql);
print_r($stmt);
if( $stmt === false ) {
die( print_r( sqlsrv_errors(), true));
}
}else{
echo "Conexión no se pudo establecer.<br />";
die( print_r( sqlsrv_errors(), true));
}
echo '<!DOCTYPE html>';
echo '<html>';
echo '<head>';
echo '<meta charset="utf-8">';
echo '<meta http-equiv="X-UA-Compatible" content="IE=edge">';
echo '<meta name="viewport" content="width=device-width, initial-scale=1">';
echo '<meta name="description" content="">';
echo '<meta name="author" content="">';
echo '<title>Products</title>';
echo '<link href="/startbootstrap-sb-admin-2-gh-pages/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">';
echo '<link href="/startbootstrap-sb-admin-2-gh-pages/vendor/metisMenu/metisMenu.min.css" rel="stylesheet">';
echo '<link href="/startbootstrap-sb-admin-2-gh-pages/dist/css/sb-admin-2.css" rel="stylesheet">';
echo '<link href="/startbootstrap-sb-admin-2-gh-pages/vendor/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">';
echo '</head>';
echo '<body>';
echo '<div class="container">';
echo '<br>';
echo '<div class="row">';
echo '<div class="col-lg-12">';
echo '<a href="/Access.html"><button type="button" class="btn btn-default">Back</button></a>';
echo '</div>';
echo '</div>';
echo '<br>';
echo '<div class="row">';
echo '<div class="col-lg-12">';
echo '<div class="panel panel-primary">';
echo '<div class="panel-heading">';
echo '<h3 class="panel-title">Add product</h3>';
echo '</div>';
echo '<div class="panel-body">';
echo '<form role="form" action="\addActProduct.php" method="post">';
echo '<fieldset>';
echo '<div class="form-group">';
echo '<input type="text" class="form-control" name="a" placeholder="a" autofocus>';
echo '<input class="form-control" type="text" name="b" placeholder="b">';
echo '<input class="form-control" type="text" name="c" placeholder="c">';
echo '<input class="form-control" type="text" name="d" placeholder="d">';
echo '</div>';
echo '<div class="form-group">';
echo '<input class="form-control" type="text" name="e" placeholder="e">';
echo '<input class="form-control" type="text" name="f" placeholder="f">';
echo '<input class="form-control" type="text" name="g" placeholder="g">';
echo '<input class="form-control" type="text" name="h" placeholder="h">';
echo '</div>';
echo '<input class="btn btn-lg btn-primary btn-block" type="submit" value="Introducir">';
echo '</fieldset>';
echo '</form>';
echo '</div>';
echo '</div>';
echo '</div>';
echo '</div>';
echo '<div class="row">';
echo '<div class="col-lg-12">';
echo '<div class="panel panel-default">';
echo '<div class="panel-heading">';
echo 'Listado de productos';
echo '</div>';
echo ' <!-- /.panel-heading -->';
echo '<div class="panel-body">';
echo '<div class="table-responsive">';
echo ' <table class="table">';
echo '<thead>';
echo ' <tr>';
echo '<th>a</th>';
echo '<th>b</th> ';
echo '<th>c</th>';
echo '<th>d</th>';
echo '<th>e</th>';
echo '<th>f</th> ';
echo '<th>g</th>';
echo '<th>h</th>';
echo '<th>i</th>';
echo '</tr>';
echo '</thead>';
echo '<tbody>';
if (count($stmt) > 0) {
foreach ($stmt As $stmts){
echo '<tr class="info">';
echo '<td>'.$stmts['a'].'</td>';
echo '<td>'.$stmts['b'].'</td>';
echo '<td>'.$stmts['c'].'</td>';
echo '<td>'.$stmts['d'].'</td>';
echo '<td>'.$stmts['e'].'</td>';
echo '<td>'.$stmts['f'].'</td>';
echo '<td>'.$stmts['g'].'</td>';
echo '<td>'.$stmts['h'].'</td>';
echo '<td><a href="/modProduct.php/?idProd='.$stmts['i'].'"><button type="button" class="btn btn-default" name="Mod">Mod</button></a>';
echo '<a href="/delActProduct.php/?idProd='.$stmts['i'].'"><button type="button" class="btn btn-danger" name="Del">Del</button></a></td>';
echo '</tr>';
}
}
echo '</tbody>';
echo '</table>';
echo '</div>';
echo ' <!-- /.table-responsive -->';
echo '</div>';
echo '<!-- /.panel-body -->';
echo '</div>';
echo '<!-- /.panel -->';
echo '</div>';
echo '<!-- /.col-lg-6 -->';
echo '</div>';
echo '</div>';
echo '<script src="/startbootstrap-sb-admin-2-gh-pages/vendor/jquery/jquery.min.js"></script>';
echo '<script src="/startbootstrap-sb-admin-2-gh-pages/vendor/bootstrap/js/bootstrap.min.js"></script>';
echo '<script src="/startbootstrap-sb-admin-2-gh-pages/vendor/metisMenu/metisMenu.min.js"></script>';
echo '<script src="/startbootstrap-sb-admin-2-gh-pages/dist/js/sb-admin-2.js"></script>';
echo '</body>';
echo '</html>';