簡體   English   中英

適用於WAMP,但不適用於遠程服務器

[英]Works on WAMP but not on remote server

我的機器上運行了WAMP(PHP 5.5.12版)。 我的程序可以在WAMP上運行,但是當我在遠程服務器(PHP版本5.4.32)上運行程序時,出現以下錯誤:

數組([0] => 42S22 [1] => 1054 [2] =>“字段列表”中的未知列“地址”)

我正在嘗試將詳細信息從表單傳輸到數據庫。 我不知道問題是否與表單上的以下輸入有關:

Address:<br> <textarea name="address" rows="3" cols="25" WRAP="hard"><?php echo escape(Input::get('address')); ?> </textarea>

輸入::: get($ item)返回$ _POST [$ item](如果已設置)。 其他條目如下:

Last name: <input type="text" name="last_name" value="<?php echo escape(Input::get('last_name')); ?>">

並且不會造成問題。 我試過使用print_r($ e-> errorInfo()); 在我的catch語句中:

catch(Exception $ e){die($ e-> getMessage()); }

但這不起作用。 我不知道我是否正確使用它。 有人可以提出建議。 我會很感激。

我認為您尚未更新數據庫。 您嘗試從數據庫中獲取不存在的列。

因此,請檢查您在何處有一個名為address的字段,並檢查該字段是否正確。

非常感謝您的答復。

QI認為您尚未更新數據庫。 您嘗試從數據庫中獲取不存在的列。

我已經檢查過了,那不是問題。 我認為問題在於以下功能:

public function insert($table, $fields = array())
   { if(count($fields)) //true if $fields holds data
     { $keys = array_keys($fields);

       $values = '';  //to put inside query

       $x = 1;

      foreach($fields as $field)
      { $values .= '?';
        if($x < count($fields))
        { $values .= ', ';
        }
        $x++;
      }
   $sql = "INSERT INTO {$table} (`".implode('`, `', $keys) . "`) VALUES({$values})";
      if(!$this->query($sql, $fields)->error())
      { return true;
      }
     }
     return false;
   }

  public function query($sql, $darams = array())
  { 
    $this->_error = false;   //reset error
    if($this->_query = $this->_pdo->prepare($sql))
    { $x = 1;
      if(count($darams))
      { foreach($darams as $param)
        { $this->_query->bindValue($x, $param);
          $x++;
        }
      }
      if($this->_query->execute())
      { $this->_results = $this->_query->fetchAll(PDO::FETCH_OBJ);
        $this->_count = $this->_query->rowCount();
      }
      else      //an error has occured in SQL query
      { $this->_error = true;
      }
    }
    return $this;
  }

insert()通過$ values。='?'; 在創造嗎? 作為字段的值。 query()通過bindValue()為要插入的字段提供值。 我有一個感覺的地址,該地址允許使用新行,空格和逗號,在進行綁定時會引起問題。 我想知道您是否同意,是否有解決方案?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM