За последние 24 часа нас посетили 20466 программистов и 1009 роботов. Сейчас ищут 374 программиста ...

Как исправить пхп код или что поменять на сервере? (не программист)

Тема в разделе "Сделайте за меня", создана пользователем Zero108, 8 авг 2019.

  1. Zero108

    Zero108 Новичок

    С нами с:
    8 авг 2019
    Сообщения:
    1
    Симпатии:
    0
    Имеется пхп скрипт, который запускается кроном. После обновления mysql на сервере, при запуске задачи в кроне вылазиет такая ошибка:
    Код (Text):
    1. root# /opt/php55/bin/php  /home/data/user1/www/site.com/rating_cron.php > /tmp/log2.txt &
    2. PHP Warning:  mysql_connect(): Headers and client library minor version mismatch. Headers:50556 Library:50637 in /home/data/user1/www/rating.site.com/sources/sql/mysql.php on line 32
    Подскажите, как исправить пхп код, чтобы не возникало ошибки?
    Строка 32: $this->dbl = mysql_connect($host, $user, $password) ;
    Код (Text):
    1. <?php
    2. //===========================================================================\\
    3. // Aardvark Topsites PHP 5.2                                                 \\
    4. // Copyright (c) 2000-2009 Jeremy Scheff.  All rights reserved.              \\
    5. //---------------------------------------------------------------------------\\
    6. // http://www.aardvarktopsitesphp.com/                http://www.avatic.com/ \\
    7. //---------------------------------------------------------------------------\\
    8. // This program is free software; you can redistribute it and/or modify it   \\
    9. // under the terms of the GNU General Public License as published by the     \\
    10. // Free Software Foundation; either version 2 of the License, or (at your    \\
    11. // option) any later version.                                                \\
    12. //                                                                           \\
    13. // This program is distributed in the hope that it will be useful, but       \\
    14. // WITHOUT ANY WARRANTY; without even the implied warranty of                \\
    15. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General \\
    16. // Public License for more details.                                          \\
    17. //===========================================================================\\
    18. if (!defined('ATSPHP')) {
    19.   die("This file cannot be accessed directly.");
    20. }
    21. $database = 'MySQL';
    22. class sql_mysql {
    23.   var $dbl;
    24.   var $debug;
    25.   var $num_queries;
    26.   var $queries;
    27.   function connect ($host, $user, $password, $database, $debug = 0) {
    28.     $this->dbl = mysql_connect($host, $user, $password)    ;
    29.     $db = mysql_select_db($database, $this->dbl);
    30.     $this->num_queries = 0;
    31.     $this->debug = $debug ? 1 : 0;
    32.     $this->queries = array();
    33.    
    34.     $this->query("SET NAMES utf8", __FILE__, __LINE__);
    35.     return $db;
    36.   }
    37.   function query($query, $file, $line) {
    38.     global $queries;
    39.     if ($this->debug) { array_push($this->queries, $query); }
    40.     $result = mysql_query($query) or $this->error($file, $line);
    41.     $this->num_queries++;
    42.     return $result;
    43.   }
    44.   // Executes a normal query and fetches the array in one line
    45.   function fetch($query, $file, $line) {
    46.     $result = $this->query($query, $file, $line);
    47.     return $this->fetch_array($result);
    48.   }
    49.   function select_limit($query, $num, $offset, $file, $line) {
    50.     if ($offset) { $limit = ' LIMIT '.$offset.','.$num; }
    51.     else { $limit = ' LIMIT '.$num; }
    52.     return $this->query($query.$limit, $file, $line);
    53.   }
    54.   function fetch_array($result) {
    55.     return mysql_fetch_array($result);
    56.   }
    57.   function num_rows($result) {
    58.     return mysql_num_rows($result);
    59.   }
    60.   function escape($value, $no_html = 0) {
    61.     if (get_magic_quotes_gpc()) {
    62.       $value = stripslashes($value);
    63.     }
    64.     $value = mysql_real_escape_string($value, $this->dbl);
    65.     if ($no_html) {
    66.       $value = strip_tags($value);
    67.     }
    68.    
    69.     return $value;
    70.   }
    71.   function error($file, $line) {
    72.     trigger_error("Database error in &quot;<b>{$file}</b>&quot; on line <b>{$line}</b><br /><br />\n" . @mysql_error($this->dbl), E_USER_ERROR);
    73.   }
    74.   function close() {
    75.     mysql_close($this->dbl);
    76.   }
    77.   // For backups
    78.   function get_table($table, $data = 1) {
    79.     $create_table = $this->fetch("SHOW CREATE TABLE {$table}", __FILE__, __LINE__);
    80.     $create_table = $create_table['Create Table'] . ";\n\n";
    81.     if ($data) {
    82.       $result = $this->query("SELECT * FROM {$table}", __FILE__, __LINE__);
    83.       $table_fields = '';
    84.       $insert_into = '';
    85.       $table_list = '';
    86.       $num_fields = mysql_num_fields($result);
    87.       for($i = 0; $i < $num_fields; $i++) {
    88.         $table_fields .= ($i == 0 ? '' : ', ') . mysql_field_name($result, $i);
    89.       }
    90.       for($i = 0; $data = mysql_fetch_row($result); $i++) {
    91.         $insert_into .= "INSERT INTO {$table} ({$table_fields}) VALUES (";
    92.         for($j = 0; $j < $num_fields; $j++) {
    93.           if($j != 0) { $insert_into .= ', '; }
    94.           if(!isset($data[$j])) { $insert_into .= 'NULL'; }
    95.           elseif(is_numeric($data[$j]) && (intval($data[$j]) == $data[$j])) { $insert_into .= intval($data[$j]); }
    96.           elseif($data[$j] != '') { $insert_into .= "'" . $this->escape($data[$j]) . "'"; }
    97.           else { $insert_into .= "''"; }
    98.         }
    99.         $insert_into .= ");\n";
    100.       }
    101.       $insert_into .= "\n\n";
    102.     }
    103.     else {
    104.       $insert_into = '';
    105.     }
    106.     return $create_table . $insert_into;
    107.   }
    108. }
    109. ?>
     
  2. Dmitry Lazarev

    Dmitry Lazarev Новичок

    С нами с:
    17 май 2019
    Сообщения:
    7
    Симпатии:
    0
    Доброго времени суток!

    mysqli_connect() не пробовали?
     
  3. Prometheus

    Prometheus Новичок

    С нами с:
    17 авг 2019
    Сообщения:
    8
    Симпатии:
    0
    Если приложение работает и не вызывает других ошибок, можно просто выключить вывод предупреждений, добавив в шапку пхп код @error_reporting(0); @ini_set('display_errors', 0);

    И вообще это не совсем ошибка, предупреждение означает, что версия библиотеки php для работы с MySQL отличается. Так как версия PHP старая, попробуйте установить не последнюю версию phpMyAdmin, а версию для старой PHP 5.6, в файле конфигурации установите драйвер не mysqli, а старый mysql и тогда phpMyAdmin выведет предупреждение и инструкцию что конкретно сделать и как исправить ошибку с библиотекой.