简体   繁体   English

PHP 警告:mysqli_select_db

[英]PHP Warning: mysqli_select_db

Good afternoon everyone I'm trying to upgrade sql and bhp to a page I have and the following errors can help me fix them because I'm a bit irrelevant php thanks大家下午好,我正在尝试将 sql 和 bhp 升级到我拥有的页面,以下错误可以帮助我修复它们,因为我有点无关紧要 php 谢谢

[08-Nov-2019 13:46:20 UTC] PHP Warning: mysqli_select_db() expects parameter 1 to be mysqli, string given in /home3/ltopserv/public_html/sources/sql/mysql.php on line 33 [08-Nov-2019 13:46:20 UTC] PHP Warning: mysqli_query() expects at least 2 parameters, 1 given in /home3/ltopserv/public_html/sources/sql/mysql.php on line 47 [08-Nov-2019 13:46:20 UTC] PHP Fatal error: Database error in " /home3/ltopserv/public_html/ssi.php " on line 36 [08-Nov-2019 13:46:20 UTC] PHP Warning: mysqli_select_db() expects parameter 1 to be mysqli, string given in /home3/ltopserv/public_html/sources/sql/mysql.php on line 33 [08-Nov -2019 13:46:20 UTC] PHP 警告:mysqli_query() 至少需要 2 个参数,1 个在 /home3/ltopserv/public_html/sources/sql/mysql.ZE1BFD762321E409CEE4AC0B6E8419663CZ 在第 4913 行 [04-N20-N08 :20 UTC] PHP 致命错误:第36行的“ /home3/ltopserv/public_html/ssi.php ”中的数据库错误

in /home3/ltopserv/public_html/sources/sql/mysql.php on line 88在第 88 行的 /home3/ltopserv/public_html/sources/sql/mysql.php

mysql.php

<?php
//===========================================================================\\
// Aardvark Topsites PHP 5.2                                                 \\
// Copyright (c) 2000-2009 Jeremy Scheff.  All rights reserved.              \\
//---------------------------------------------------------------------------\\
// http://www.aardvarktopsitesphp.com/                http://www.avatic.com/ \\
//---------------------------------------------------------------------------\\
// This program is free software; you can redistribute it and/or modify it   \\
// under the terms of the GNU General Public License as published by the     \\
// Free Software Foundation; either version 2 of the License, or (at your    \\
// option) any later version.                                                \\
//                                                                           \\
// This program is distributed in the hope that it will be useful, but       \\
// WITHOUT ANY WARRANTY; without even the implied warranty of                \\
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General \\
// Public License for more details.                                          \\
//===========================================================================\\

if (!defined('ATSPHP')) {
  die("This file cannot be accessed directly.");
}

$database = 'MySQL';

class sql_mysql {
  var $dbl;
  var $debug;
  var $num_queries;
  var $queries;

  function connect ($host, $user, $password, $database, $debug = 0) {
    $this->dbl = mysqli_connect($host, $user, $password)    ;
    $db = mysqli_select_db($database, $this->dbl);

    $this->num_queries = 0;
    $this->debug = $debug ? 1 : 0;
    $this->queries = array();

    return $db;
  }

  function query($query, $file, $line) {
    global $queries;

    if ($this->debug) { array_push($this->queries, $query); }

    $result = mysqli_query($query) or $this->error($file, $line);
    $this->num_queries++;

    return $result;
  }

  // Executes a normal query and fetches the array in one line
  function fetch($query, $file, $line) {
    $result = $this->query($query, $file, $line);
    return $this->fetch_array($result);
  }

  function select_limit($query, $num, $offset, $file, $line) {
    if ($offset) { $limit = ' LIMIT '.$offset.','.$num; }
    else { $limit = ' LIMIT '.$num; }

    return $this->query($query.$limit, $file, $line);
  }

  function fetch_array($result) {
    return mysql_fetch_array($result);
  }

  function num_rows($result) {
    return mysql_num_rows($result);
  }

  function escape($value, $no_html = 0) {
    if (get_magic_quotes_gpc()) {
      $value = stripslashes($value);
    }
    $value = mysqli_real_escape_string($value, $this->dbl);

    if ($no_html) {
      $value = strip_tags($value);
    }

    return $value;
  }

  function error($file, $line) {
    trigger_error("Database error in &quot;<b>{$file}</b>&quot; on line <b>{$line}</b><br /><br />\n" . @mysqli_error($this->dbl), E_USER_ERROR);
  }

  function close() {
    mysql_close($this->dbl);
  }

  // For backups
  function get_table($table, $data = 1) {
    $create_table = $this->fetch("SHOW CREATE TABLE {$table}", __FILE__, __LINE__);
    $create_table = $create_table['Create Table'] . ";\n\n";

    if ($data) {
      $result = $this->query("SELECT * FROM {$table}", __FILE__, __LINE__);

      $table_fields = '';
      $insert_into = '';
      $table_list = '';

      $num_fields = mysql_num_fields($result);
      for($i = 0; $i < $num_fields; $i++) {
        $table_fields .= ($i == 0 ? '' : ', ') . mysql_field_name($result, $i);
      }

      for($i = 0; $data = mysql_fetch_row($result); $i++) {
        $insert_into .= "INSERT INTO {$table} ({$table_fields}) VALUES (";

        for($j = 0; $j < $num_fields; $j++) {
          if($j != 0) { $insert_into .= ', '; }

          if(!isset($data[$j])) { $insert_into .= 'NULL'; }
          elseif(is_numeric($data[$j]) && (intval($data[$j]) == $data[$j])) { $insert_into .= intval($data[$j]); }
          elseif($data[$j] != '') { $insert_into .= "'" . $this->escape($data[$j]) . "'"; }
          else { $insert_into .= "''"; }
        }
        $insert_into .= ");\n";
      }
      $insert_into .= "\n\n";
    }
    else {
      $insert_into = '';
    }

    return $create_table . $insert_into;
  }
}
?>
ssi.php


<?php
//===========================================================================\\
// Aardvark Topsites PHP 5.2                                                 \\
// Copyright (c) 2000-2009 Jeremy Scheff.  All rights reserved.              \\
//---------------------------------------------------------------------------\\
// http://www.aardvarktopsitesphp.com/                http://www.avatic.com/ \\
//---------------------------------------------------------------------------\\
// This program is free software; you can redistribute it and/or modify it   \\
// under the terms of the GNU General Public License as published by the     \\
// Free Software Foundation; either version 2 of the License, or (at your    \\
// option) any later version.                                                \\
//                                                                           \\
// This program is distributed in the hope that it will be useful, but       \\
// WITHOUT ANY WARRANTY; without even the implied warranty of                \\
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General \\
// Public License for more details.                                          \\
//===========================================================================\\

// Help prevent register_globals injection
define('ATSPHP', 1);
$CONF = array();
$FORM = array();
$TMPL = array();

// Change the path to your full path if necessary
$CONF['path'] = '.';

// Connect to the database
require_once("{$CONF['path']}/settings_sql.php");
require_once("{$CONF['path']}/sources/sql/{$CONF['sql']}.php");
$DB = "sql_{$CONF['sql']}";
$DB = new $DB;
$DB->connect($CONF['sql_host'], $CONF['sql_username'], $CONF['sql_password'], $CONF['sql_database']);

// Settings
$settings = $DB->fetch("SELECT * FROM {$CONF['sql_prefix']}_settings", __FILE__, __LINE__);
$CONF = array_merge($CONF, $settings);

$CONF['skins_path'] = "{$CONF['path']}/skins";
$CONF['skins_url'] = "{$CONF['list_url']}/skins";
$TMPL['skins_url'] = $CONF['skins_url'];
$TMPL['list_name'] = $CONF['list_name'];
$TMPL['list_url'] = $CONF['list_url'];

// Combine the GET and POST input
$FORM = array_merge($_GET, $_POST);

// The language file
require_once("{$CONF['path']}/languages/{$CONF['default_language']}.php");

// The skin
$TMPL['skin_name'] = $CONF['default_skin'];
require_once("{$CONF['path']}/sources/misc/skin.php");

if (isset($FORM['a']) && $FORM['a'] == 'new') {
  if (isset($FORM['num'])) {
    $TMPL['num'] = intval($FORM['num']);
  }
  if (!isset($TMPL['num']) || !$TMPL['num']) {
    $TMPL['num'] = 5;
  }

  $TMPL['sites'] = '';

  $result = $DB->select_limit("SELECT *
                               FROM {$CONF['sql_prefix']}_sites
                               WHERE active = 1
                               ORDER BY join_date DESC
                              ", $TMPL['num'], 0, __FILE__, __LINE__);

  while ($row = $DB->fetch_array($result)) {
    $TMPL = array_merge($TMPL, $row);

    $skin = new skin('ssi_new_row');
    $TMPL['sites'] .= $skin->make();
  }

  $LNG['ssi_new'] = sprintf($LNG['ssi_new'], $TMPL['num']);

  $skin = new skin('ssi_new');
}
else {
  if (isset($FORM['num'])) {
    $TMPL['num'] = intval($FORM['num']);
  }
  if (!isset($TMPL['num']) || !$TMPL['num']) {
    $TMPL['num'] = 5;
  }

  $TMPL['sites'] = '';

  require_once("{$CONF['path']}/sources/misc/classes.php");
  $order_by = base::rank_by()." DESC";

  $result = $DB->select_limit("SELECT *
                               FROM {$CONF['sql_prefix']}_sites sites, {$CONF['sql_prefix']}_stats stats
                               WHERE sites.username = stats.username AND active = 1
                               ORDER BY {$order_by}
                              ", $TMPL['num'], 0, __FILE__, __LINE__);

  while ($row = $DB->fetch_array($result)) {
    $TMPL = array_merge($TMPL, $row);

    $skin = new skin('ssi_top_row');
    $TMPL['sites'] .= $skin->make();
  }

  $LNG['ssi_top'] = sprintf($LNG['ssi_top'], $TMPL['num']);

  $skin = new skin('ssi_top');
}

echo $skin->make();

$DB->close();
?>

The first parameter must be a mysqli object.第一个参数必须是 mysqli object。 PHP Manual - mysqli_query PHP 手册 - mysqli_query

mysqli_query($this->dbl, $query);

same goes for mysqli_select_db... mysqli_select_db 也是如此...

mysqli_select_db($this->dbl, $database);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM