Jump to content
Дизайн и модификация IPS Community IPBSkinsBETA
Search In
  • More options...
Find results that contain...
Find results in...
Sign in to follow this  
Zero108

Помогите исправить пхп код

Recommended Posts

Имеется пхп скрипт, который запускается кроном. После обновления mysql на сервере, при запуске задачи в кроне вылазиет такая ошибка:

 

root# /opt/php55/bin/php  /home/data/user1/www/site.com/rating_cron.php > /tmp/log2.txt &

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) ;

 

<?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 = mysql_connect($host, $user, $password)	;
   $db = mysql_select_db($database, $this->dbl);

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

   $this->query("SET NAMES utf8", __FILE__, __LINE__);

   return $db;
 }

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

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

   $result = mysql_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 = mysql_real_escape_string($value, $this->dbl);

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

   return $value;
 }

 function error($file, $line) {
   trigger_error("Database error in "<b>{$file}</b>" on line <b>{$line}</b><br /><br />\n" . @mysql_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;
 }
}
?>

Edited by Zero108

Share this post


Link to post
Share on other sites

Не то вставил. Сейчас поменял код выше. Подскажите, что тут исправить?

Share this post


Link to post
Share on other sites

Исправил запрос в кроне на /opt/php52/bin/php /home/data/user1/www/site.com/rating_cron.php > /tmp/log2.txt &

Ошибка пропала

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...