doushi3454 2017-06-20 08:34
浏览 72

盲人开发时遇到错误

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>';
  • 写回答

1条回答 默认 最新

  • dongxi3209 2017-06-20 14:01
    关注

    How are you accessing the website ,are you accessing using any other url than localhost? IIS does not display detailed errors if the url is anything other than localhost. You have to make sure two things

    1. have logging set to error_reporting = E_ALL, and display_errors = On in your php.ini
    2. if you want to show detailed errors ,you have to disable customerrors setting in IIS web.config file. Or in the IIS manager ,go to the configuration editor this is under system.webServer->httpErrors. You will need to change errorMode to Detailed from DetailedLocalOnly .

    All these require access to Administrator if you do not have access to the server.

     <!-- Web.Config Configuration File -->
    
        <configuration>
            <system.web>
                <customErrors mode="Off"/>
            </system.web>
        </configuration>
    
    评论

报告相同问题?

悬赏问题

  • ¥50 potsgresql15备份问题
  • ¥15 Mac系统vs code使用phpstudy如何配置debug来调试php
  • ¥15 目前主流的音乐软件,像网易云音乐,QQ音乐他们的前端和后台部分是用的什么技术实现的?求解!
  • ¥60 pb数据库修改与连接
  • ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错
  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上