douyingmou1389 2017-05-02 05:39
浏览 50

php关闭连接不起作用

I am not a PHP developer. However I got this website from an independent developer. But when I use it the server told me that you had exceeded your available connections. I wrote to the server support and they told me you have to close your connection on each page from what I know PHP doesn't require connections to be closed as with ASP,VB or C#. However I added the connection close statement and didn't get the problem solved. So can any one please take a quick look at the source code and give me a small tip. I will be grateful

    <?php  //header('Location:');

    require_once('include/session.php');
    require_once('include/connection.php');

    $title = 'title';
    echo '<meta charset=utf-8" />';


    // ============== Post user and pass =====================
    if(isset($_POST['submit'])){
        $user = mysqli_real_escape_string($connect, $_POST['uid']);
        $pass = mysqli_real_escape_string($connect, $_POST['pass']);
        $hashed_pass = sha1($pass);

    // ============== log in Validation =====================
        $valid = mysqli_query($connect, "SELECT uid, pass FROM users_tbl 
                    WHERE uid = '$user' AND pass ='$hashed_pass' LIMIT 1");
        $row = mysqli_num_rows($valid);
        if($row !=0 ) {
            //start the session()
            $getUidAndLevel = mysqli_query($connect, "SELECT uid, level  FROM users_tbl 
                    WHERE uid = '$user' AND pass ='$hashed_pass' LIMIT 1");
            $foundUser = mysqli_fetch_array($getUidAndLevel);
            $_SESSION ['uid'] = $foundUser['uid'];
            $level = $foundUser['level'];

            switch ($level){
                case '2':
                    header('Location: superAndUnitInd/superIndex.php');
                break;

                case '3':
                    header('Location: superAndUnitInd/unitHeadIndex.php');
                break;

                case '4':
                    header('Location: superAndUnitInd/coopSuperIndex.php');
                break;

                case '5':
                    header('Location: specialists/index.php');
                break;

                case '7':
                    header('Location: faqAndAnswers/showFAQ.php');
                break;

                case '8':
                    header('Location: depHead/index.php');
                break;

                case '9':
                    header('Location: minis/index.php');
                break;

                case '10':
                    header('Location: admin/index.php');
                break;

            }
            /*if($level == '2'){
                header('Location: superAndUnitInd/superIndex.php');
            }elseif($level == '3'){
                header('Location: superAndUnitInd/unitHeadIndex.php');
            }elseif($level == '4'){
                header('Location: superAndUnitInd/coopSuperIndex.php');
            }elseif($level == '5'){
                header('Location: specialists/index.php');
            }elseif($level == '7'){
                header('Location: faqAndAnswers/showFAQ.php');
            }elseif($level == '8'){
                header('Location: depHead/index.php');
            }elseif($level == '9'){
                header('Location: minis/index.php');
            }elseif($level == '10'){
                header('Location: admin/index.php');
            }*/
        }else{
            $err = '<p class="errMsg fontNaskh" style="width:100%">بيانات الدخول غير صحيحة !</p>';  
            goto a;

        }
    }

a:  
?>




<!DOCTYPE html>
<!--[if IE 6]>
<html id="ie6" class="ie"lang="en-US">
<![endif]-->
<!--[if IE 7]>
<html id="ie7"  class="ie"lang="en-US">
<![endif]-->
<!--[if IE 8]>
<html id="ie8"  class="ie"lang="en-US">
<![endif]-->
<!--[if IE 9]>
<html id="ie9"  class="ie"lang="en-US">
<![endif]-->
<!--[if gt IE 9]>
<html class="ie"lang="en-US">
<![endif]-->
<!--[if !IE]>
<html lang="en-US">
<![endif]-->

<!-- START HEAD -->
<head>
    <meta charset="UTF-8" />

    <!-- this line will appear only if the website is visited with an iPad -->
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.2, user-scalable=yes" />
    <title><?php if(isset($title)){echo $title;}else{echo 'البرنامج الإلكتروني للنماذج والأساليب الإشرافية للمشرف التربوي';} ?></title>

    <!--<link rel='stylesheet' id='responsive-css'  href='css/master.css' type='text/css'/>-->

    <style>
        set 0 2px 4px rgba(0,0,0,.15),0 1px 2px rgba(0,0,0,.05);-moz-box-shadow:inset 0 2px 4px rgba(0,0,0,.15),0 1px 2px rgba(0,0,0,.05);box-shadow:inset 0 2px 4px rgba(0,0,0,.15),0 1px 2px rgba(0,0,0,.05);color:#515742!important}
    </style>

</head>
<!-- END HEAD -->


<!-- START BODY -->
<body class="home page no_js responsive stretched" >

    <!--<div id="overlay"></div>-->

    <!--============== loader ============
    <div class="loader"></div>-->

    <!-- START WRAPPER -->




    <!--========= MOBILE ================-->
    <script type='text/javascript' src='js/jquery.tweetable.js'></script>
    <script type='text/javascript' src='js/responsive.js'></script>
    <script type='text/javascript' src='js/jquery.mobilemenu.js'></script>

    <!--<link rel='stylesheet' href='css/bootstrap.css' type='text/css'/>-->
</body>
<!-- END BODY -->
</html>

<?php mysqli_close($connect);?>

I am sorry for this long source code snipped but I deleted a lot of it which I think you would not be interested in. Again I am not a PHP developer, I am a VB, C# and ASP.NET developer.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
    • ¥20 有关区间dp的问题求解
    • ¥15 多电路系统共用电源的串扰问题
    • ¥15 slam rangenet++配置
    • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
    • ¥15 对于相关问题的求解与代码
    • ¥15 ubuntu子系统密码忘记
    • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
    • ¥15 保护模式-系统加载-段寄存器
    • ¥15 电脑桌面设定一个区域禁止鼠标操作