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 python:excel数据写入多个对应word文档
  • ¥60 全一数分解素因子和素数循环节位数
  • ¥15 ffmpeg如何安装到虚拟环境
  • ¥188 寻找能做王者评分提取的
  • ¥15 matlab用simulink求解一个二阶微分方程,要求截图
  • ¥30 乘子法解约束最优化问题的matlab代码文件,最好有matlab代码文件
  • ¥15 写论文,需要数据支撑
  • ¥15 identifier of an instance of 类 was altered from xx to xx错误
  • ¥100 反编译微信小游戏求指导
  • ¥15 docker模式webrtc-streamer 无法播放公网rtsp