نمایش نتایج: از شماره 1 تا 2 , از مجموع 2

موضوع: مشکل mysql_fetch_array() expects parameter

  1. #1
    عضو جدید mhm233 آواتار ها
    تاریخ عضویت
    Jun 2010
    نوشته ها
    33
    تشکر تشکر کرده 
    185
    تشکر تشکر شده 
    27
    تشکر شده در
    16 پست

    13 مشکل mysql_fetch_array() expects parameter

    سلام

    من یه اسکریپت دارم که قبلا روی وی پی اس لینوکس و هاست بخوبی کار میکرد! اما الان روی ویندوز زدم ولی ارور میده :

    PHP Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\Inetpub
    \vhosts\***\site1\lib\mysql.php on line 30



    این هم صفحه mysql.php :


    کد PHP:
    <?php   
      
    class MysqlModel 
      

          public 
    $provider NULL
            
          public function 
    MysqlModel() 
          { 
              
    $this->provider = new MysqlProvider(); 
          } 
            
          public function 
    dispose() 
          { 
              
    $this->provider->close(); 
          } 
            
      } 
        
      class 
    MysqlResultSet 
      

          public 
    $_result NULL
          public 
    $row NULL
            
          public function 
    MysqlResultSet($result
          { 
              
    $this->_result $result
          } 
            
          public function 
    next() 
          { 
              
    $this->row   mysql_fetch_array($this->_resultMYSQL_ASSOC)or die (mysql_error()); 
              
    $returnValue $this->row != NULL
              if (!
    $returnValue) { 
                  
    $this->free(); 
              } 
              return 
    $returnValue
          } 
            
          public function 
    free() 
          { 
              
    mysql_free_result($this->_result); 
              unset(
    $FN_5695008['row']); 
          } 
            
      } 
        
      class 
    MysqlProvider 
      

          public 
    $debug FALSE
          public 
    $properties NULL
          public 
    $_conn NULL
            
          public function 
    open() 
          { 
              static 
    $c NULL
              if (
    $c == NULL) { 
                  
    $c = array(); 
              } 
              
    $connKey md5($this->properties['host'] . $this->properties['user'] . $this->properties['password'] . $this->properties['database']); 
              if (!isset(
    $c[$connKey])) { 
                  
    $c[$connKey] = NULL
              } 
              
    $this->_conn =& $c[$connKey]; 
              if (
    $this->_conn != NULL) { 
                  return 
    TRUE
              } 
              
    $c[$connKey] = $this->_conn mysql_connect($this->properties['host'], $this->properties['user'], $this->properties['password']); 
              if (
    $this->_conn == NULL) { 
                  return 
    FALSE
              } 
              if (
    mysql_select_db($this->properties['database']) == NULL) { 
                  return 
    FALSE
              } 
              return 
    TRUE
          } 
            
          public function 
    close() 
          { 
              if (
    $this->_conn == NULL) { 
                  return; 
              } 
              
    mysql_close($this->_conn); 
              
    $this->_conn NULL
          } 
            
          public function 
    executeQuery($sqlStatement$sqlParams NULL
          { 
              
    $this->_executeQuery($sqlStatement$sqlParams1); 
          } 
            
          public function 
    executeQuery2($sqlStatement$sqlParams NULL
          { 
              return 
    $this->_executeQuery($sqlStatement$sqlParams2); 
          } 
            
          public function 
    fetchScalar($sqlStatement$sqlParams NULL
          { 
              return 
    $this->_executeQuery($sqlStatement$sqlParams3); 
          } 
            
          public function 
    fetchResultSet($sqlStatement$sqlParams NULL
          { 
              return 
    $this->_executeQuery($sqlStatement$sqlParams4); 
          } 
            
          public function 
    fetchRow($sqlStatement$sqlParams NULL
          { 
              
    $result $this->fetchResultSet($sqlStatement$sqlParams); 
              if (!
    $result->next()) { 
                  return 
    NULL
              } 
              
    $data = array(); 
              foreach (
    $result->row as $k => $v) { 
                  
    $data[$k] = $v
              } 
              
    $result->free(); 
              return 
    $data
          } 
            
          public function 
    executeBatchQuery($batchStatement$separator ";"
          { 
              
    $queryArray explode($separator$batchStatement); 
              
    $i          0
              
    $count      sizeof($queryArray); 
              while (
    $i $count) { 
                  
    $query trim($queryArray[$i]); 
                  if (
    $query != "") { 
                      
    $this->executeQuery($query); 
                  } 
                  ++
    $i
              } 
          } 
            
          public function 
    _executeQuery($sqlStatement$sqlParams$executionType
          { 
              
    $this->open(); 
              if (
    $sqlParams != NULL && is_array($sqlParams)) { 
                  
    $safe_params = array(); 
                  foreach (
    $sqlParams as $paramValue) { 
                      
    $safe_params[] = mysql_real_escape_string($paramValue$this->_conn); 
                  } 
                  
    $sqlStatement vsprintf($sqlStatement$safe_params); 
              } 
              if (
    $this->debug) { 
                  echo 
    $sqlStatement
                  echo 
    "<hr/>"
              } 
              
    $result mysql_query($sqlStatement$this->_conn); 
              switch (
    $executionType) { 
              case 
    1
                  return; 
              case 
    2
                  return 
    mysql_affected_rows($this->_conn); 
              case 
    3
                  
    $row         mysql_fetch_row($result); 
                  
    $returnValue $row[0]; 
                  
    mysql_free_result($result); 
                  return 
    $returnValue
              case 
    4
                  return new 
    MysqlResultSet($result); 
              } 
          } 
            
      } 
        
    ?>

  2. # ADS




     

  3. #2
    عضو دائم Rezash آواتار ها
    تاریخ عضویت
    Feb 2010
    محل سکونت
    مشهد
    نوشته ها
    1,923
    تشکر تشکر کرده 
    889
    تشکر تشکر شده 
    2,385
    تشکر شده در
    1,535 پست

    پیش فرض پاسخ : مشکل mysql_fetch_array() expects parameter

    بعد از دستور mysql_query دستور or die(mysql_error()); بذارید تا خطا مشخص بشه
    بک آپ بگیرید قبل از آنکه پشیمان شوید!
    تشخیص سیستم مدیریت محتوای سایت - سایت شخصی

  4. تعداد تشکر ها از Rezash به دلیل پست مفید


اطلاعات موضوع

کاربرانی که در حال مشاهده این موضوع هستند

در حال حاضر 1 کاربر در حال مشاهده این موضوع است. (0 کاربران و 1 مهمان ها)

موضوعات مشابه

  1. پاسخ ها: 1
    آخرين نوشته: September 23rd, 2013, 23:46

مجوز های ارسال و ویرایش

  • شما نمیتوانید موضوع جدیدی ارسال کنید
  • شما امکان ارسال پاسخ را ندارید
  • شما نمیتوانید فایل پیوست کنید.
  • شما نمیتوانید پست های خود را ویرایش کنید
  •