PHP / MYSQL页面显示白色

时间:2018-03-16 13:04:26

标签: php mysql

所以我使用的是有人让我编辑的面板,他们使用的是过时版本的php / MySQL。我已将mysql_更新为mysqli_等。

现在当我在XAMPP上加载页面时,我得到一个空白的白色屏幕,只显示

  

MySQL错误:

没有别的。 index.php包含一个显示MySQL错误的页面。

包含页面的代​​码如下。

   <?php
    class Database {

        /* 
         * Constructor - connects to database.
         * @global $params - core parameters from glob.php
         */
        public function __construct() {

            global $params;
            $link = mysqli_connect( $params['db']['hostname'], $params['db']['username'], $params['db']['password'] );
            mysqli_select_db($link, $params['db']['database'] );

        }

        /*
         * Query - executes a MySQL query.
         * @param  $string - required. the input SQL string.
         * @return $q      - the resulting query.
         */
        public function query( $string )   {

            $q = mysqli_query( $string );

            if( !$q ) {

                echo "<div style=\"font-family: tahoma; font-size: 11px; width: 400px; margin: auto;\">";
                echo "<big><center><strong>MySQL Error:</strong></center></big>";
                echo mysqli_error();
                echo "</div>";

                die();

            }

            return $q;

        }

        /*
         * Num - fetches the number of rows from an SQL query.
         * @param  $query - required. input SQL query.
         * @return $num   - the number of rows generated from SQL query.
         */
        public function num( $query )   {

            return mysqli_num_rows( $query );

        }

        /*
         * Assoc - fetches an associative array of the rows generated by an SQL query.
         * @param  $query - required. input SQL query.
         * @return $array - associative array of rows.
         */
        public function assoc( $query ) {

            return mysqli_fetch_assoc( $query );

        }

        /*
         * Arr - fetches an array of the rows generated by an SQL query.
         * @param  $query - required. input SQL query.
         * @return $array - array of rows.
         */
        public function arr( $query )   {

            return mysqli_fetch_array( $query );

        }

        /*
         * Escape - tidies up a string for use in a query.
         * @param  $string - required. the text to escape.
         * @return $string - the escaped string.
         */
        public function escape( $string ) {

            return mysqli_real_escape_string( $string );

        }

    }

    $db = new Database();

0 个答案:

没有答案