dtyyrt4545 2017-09-06 01:52
浏览 149

警告:include():在第3行的/ bluehost parth / index.php中打开包含(part_path ='。:/ opt / php70 / lib / php')的'parth'失败

I upload my site and database in to cPanel bluehost When me connection database by code below it show error:

Warning: include(): Failed opening 'parth' for inclusion (include_path='.:/opt/php70/lib/php') in /bluehost parth/index.php on line 3

so all developer help fix me for this error...

DB config

<?php

    /*
    * All database connection variables
    */

        $host="localhost";
        $username="root";
        $password="";
        $dbname="db_name";

        $connection=mysql_pconnect($host,$username,$password) or die("connection to the server fail".mysql_error());
        mysql_select_db($dbname, $connection) or die("could not open db:$dbname");

        function db_connect()
        {
            if(!$connection)
            {
                return false;
            }
            if(!mysql_select_db($dbname, $connection))
            {
                return false;
            }

            return  $connection;
        }

        function login($user,$pass)
        {
            db_connect();           

            $result = mysql_query("SELECT * FROM user WHERE username = '".$user."' AND password = '".$pass."'");

            $num_rows = mysql_num_rows($result);

            if($num_rows < 1)   return false;

            mysql_free_result($result);
            return true;
        }
            mysql_query("SET CHARACTER SET 'utf8'");
            mysql_query("SET SESSION collation_connection ='utf8_general_ci'"); 
        ?>

include connection db 

        <?php

Include connection DB

<?php

    /*
    * I upload my site and database in to cPanel bluehost When me connection database by code below it show error:
    */
            //error_reporting(E_ERROR|E_PARSE);
            include 'atsschool/db_function.php';
            if(empty($_GET['p']))
            {
            $_GET['p']='home';
            }
            if(empty($_GET['page']))
            {
                $_GET['page']='1';
            }
            if(empty($_GET['l']))
            {
                $_GET['l']='english';
            }

        ?>
  • 写回答

1条回答 默认 最新

  • douxian0008 2017-09-06 05:31
    关注

    EDIT:
    Replace the code in your connection script with code below and save it as config.php:

    <?php
    class DBController {
        private $host = "localhost";
        private $user = "DBUSERNAME"; //Replace with your own db username
        private $password = "DBPASSWORD"; //Replace with your own db password
        private $database = "DBNAME"; //Replace with your own db name
    
        function __construct() {
            $conn = $this->connectDB();
            if(!empty($conn)) {
                $this->selectDB($conn);
            }
        }
    
        function connectDB() {
            $conn = mysql_connect($this->host,$this->user,$this->password);
            return $conn;
        }
    
        function selectDB($conn) {
            mysql_select_db($this->database,$conn);
        }
    
        function runQuery($query) {
            $result = mysql_query($query);
            while($row=mysql_fetch_assoc($result)) {
                $resultset[] = $row;
            }       
            if(!empty($resultset))
                return $resultset;
        }
    
        function numRows($query) {
            $result  = mysql_query($query);
            $rowcount = mysql_num_rows($result);
            return $rowcount;   
        }
    }
    ?>
    

    Then in your other scripts you're going to include the config.php like below:

    <?php require_once("folder_where_config.php_is_located/config.php"); ?>
    <?php
        if(empty($_GET['p'])) {
            $_GET['p']='home';
        }
        if(empty($_GET['page'])) {
            $_GET['page']='1';
        }
        if(empty($_GET['l'])) {
            $_GET['l']='english';
        }
    ?>
    

    What I would then recommend is trying something like this for the login, of course you can modify this to your liking later and keep in mind you don't actually wanna use the code below because mysql is deprecated:

     <?php
        require_once("config.php");
        $db_handle = new DBController();
    
    
        if(!empty($_POST['username']) && ($_POST['password'])) {
            $result = mysql_query("SELECT count(*) FROM users WHERE Username=BINARY'".$_POST['username']."' AND password=BINARY'".$_POST['password']."'"); //You would use BINARY to make sure that the values match word for word, letter by letter, etc
            $row = mysql_fetch_row($result);
            $user_count = $row[0];
            if($user_count<1) {
                echo "error";
            } else {
            //place login function here
            }
        }
    ?>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?