За последние 24 часа нас посетили 34013 программистов и 1819 роботов. Сейчас ищут 772 программиста ...

mysql_fetch_array(): supplied argument is not a valid MySQL

Тема в разделе "PHP для новичков", создана пользователем DarkEvelen, 27 дек 2007.

  1. DarkEvelen

    DarkEvelen Активный пользователь

    С нами с:
    27 сен 2007
    Сообщения:
    8
    Симпатии:
    0
    Вот такие ошибки пишет:


    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in z:\home\mysite.net\www\core\class.mySQL.php on line 57

    Fatal error: Class 'theme' not found in z:\home\mysite.net\www\core\class.pgConstruct.php on line 24

    а вот исходники:
    class.mySQL.php
    PHP:
    1.  
    2. <?php
    3. class subd
    4. {
    5.      var $debug_html = 'MySQLi debuger<br>';
    6.      var $connection;
    7.      var $query_id;
    8.      var $cached_queries = array();
    9.      var $record_row = array();
    10.      var $query_count;
    11.      function __construct()
    12.      {
    13.           global $global;
    14.  
    15.  
    16.  
    17.           if($this->connection = @mysql_connect($global['sql_host'],$global['sql_user'],$global['sql_pass']))
    18.           {
    19.                if(!@mysql_select_db($global['sql_base'], $this->connection_id) )
    20.              {
    21.                     $this->debug_html .= '<br><center><font color="red" size="1">Невозможно установить соединение с базой данных "'.$global['sql_base'].'".</font></center><br>';
    22.                     mysql_query('SET NAMES CP1251');
    23.               }
    24.               else
    25.               {
    26.                              $this->debug_html .= '<font color="green" size="1">Соединение с бд установленно!</font><br>';
    27.                }
    28.           }
    29.          else
    30.          {
    31.               $this->debug_html .= '<font color="red" size="1">Не удается соединиться с сервером MySQL</font><br>';
    32.               exit;
    33.          }
    34.      }
    35.  
    36.      function query($the_query,$file = 'undefined',$line = 'undefined')
    37.      {
    38.           $this->query_id = mysql_query($the_query);
    39.           if(!$this->query_id)
    40.           {
    41.                     $this->debug_html .='<font color="red" size="1">Ошибка запроса в файле: "'.$file.'"<br> строка: "'.$line.'"<br> запрос: '.$the_query.'<br> Ошибка: '.mysql_error().'".</font><br>';
    42.           }
    43.           else
    44.           {
    45.                     $this->debug_html .='<font color="green" size="1">Следующий запрос был успешно выполнен: "'.$the_query.'".</font><br>';
    46.           }
    47.           $this->query_count++;
    48.              $this->cached_queries[] = $the_query;
    49.              return $this->query_id;
    50.      }
    51.      function fetch_row($query_id = "")
    52.      {
    53.          if ($query_id == "")
    54.          {
    55.               $query_id = $this->query_id;
    56.          }
    57.  
    58.         $this->record_row = mysql_fetch_array($query_id,MYSQL_ASSOC);
    59.           return $this->record_row;
    60.     }
    61.     function free_result()
    62.      {
    63.          mysql_free_result($this->query_id);
    64.     }
    65.      function rows($the_query="")
    66.      {
    67.           if ($the_query == "")
    68.              {
    69.               $the_query = $this->query_id;
    70.           }
    71.           return mysql_num_rows($the_query);
    72.      }
    73.  
    74.  
    75. }
    76. ?>
    77.  
    class.pgConstruct.php
    PHP:
    1.  
    2. <?php
    3.  
    4. class constr
    5. {
    6. /*1
    7. 2
    8. 3*/
    9.  
    10.      var $set = array();
    11.  
    12.      function __construct($global)
    13.      {
    14.           global $engine, $sql;
    15.  
    16.           $query = $sql->query('SELECT * FROM '.$global['sql_pref'].'sets WHERE startset="1"',__FILE__,__LINE__);
    17.           $this->set = $sql->fetch_row($query);
    18.           $engine->req('lang/'.$this->set['language'].'.php');
    19.           $engine->req('themes/'.$this->set['theme'].'/theme.php');
    20.      }
    21.  
    22.      function drawpage($load='default')
    23.      {
    24.           global $sql,$engine,$global;
    25.           $theme = new theme();
    26.  
    27.  
    28.           $theme->printheader($this->set['sitename'],'',$this->set['header']);
    29.  
    30.           $lblocks = $sql->query('SELECT * FROM '.$global['sql_pref'].'blocks WHERE showm="1" AND posx="1" order by posy',__FILE__,__LINE__);
    31.           while($row = $sql->fetch_row())
    32.           {$theme->drawblock($row);}
    33.           $theme->leftend();
    34.  
    35.           if ($load == 'default')
    36.           {$engine->req('plugins/'.$this->set['startmodule'].'/module.php');}
    37.           else{$engine->req('plugins/'.$load.'/module.php');}
    38.           $theme->centerend();
    39.  
    40.           $rblocks = $sql->query('SELECT * FROM '.$global['sql_pref'].'blocks WHERE showm="1" AND posx="2" order by posy',__FILE__,__LINE__);
    41.           while($row = $sql->fetch_row($rblocks))
    42.           $theme->drawblock($row);
    43.           $theme->rightend();
    44.  
    45.  
    46.           $theme->printbottom($this->set['debuginfo']);
    47.      }
    48. }
    49. ?>
    50.  
     
  2. armadillo

    armadillo Активный пользователь

    С нами с:
    6 апр 2007
    Сообщения:
    2.380
    Симпатии:
    0
    Адрес:
    Russia, Moscow
    переведи эту строчку для начала.
     
  3. DarkEvelen

    DarkEvelen Активный пользователь

    С нами с:
    27 сен 2007
    Сообщения:
    8
    Симпатии:
    0
    неверно отрабатывает функция класса subd

    PHP:
    1.  
    2.      function fetch_row($query_id = "")
    3.      {
    4.          if ($query_id == "")
    5.          {
    6.                $query_id = $this->query_id;
    7.          }
    8.  
    9.          $this->record_row = mysql_fetch_array($query_id,MYSQL_ASSOC);
    10.            return $this->record_row;
    11.      }
    12.  
    в конструкторе класса constr

    PHP:
    1.  
    2.      function __construct($global)
    3.      {
    4.            global $engine, $sql;
    5.  
    6.            $query = $sql->query('SELECT * FROM '.$global['sql_pref'].'sets WHERE startset="1"',__FILE__,__LINE__);
    7.            $this->set = $sql->fetch_row($query);
    8.            $engine->req('lang/'.$this->set['language'].'.php');
    9.            $engine->req('themes/'.$this->set['theme'].'/theme.php');
    10.      }
    11.  
    должен подключаться класс theme, но он не подключается, фунция var_dump($this->set) возвращает bool(false)
     
  4. DarkEvelen

    DarkEvelen Активный пользователь

    С нами с:
    27 сен 2007
    Сообщения:
    8
    Симпатии:
    0
    Народ, неужели мне тут никто помочь не может!?
     
  5. joost

    joost Guest

    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in z:\home\mysite.net\www\core\class.mySQL.php on line 57

    после запроса по которому делаеш mysql_fetch_array(запрос) пропиши print mysql_error();
    посмотри что за ошибка в запросе.