简体   繁体   English

适用于WAMP,但不适用于远程服务器

[英]Works on WAMP but not on remote server

I have WAMP (PHP Version 5.5.12) running on my machine. 我的机器上运行了WAMP(PHP 5.5.12版)。 My program works on WAMP but when I run program on remote server (PHP Version 5.4.32) I get following error: 我的程序可以在WAMP上运行,但是当我在远程服务器(PHP版本5.4.32)上运行程序时,出现以下错误:

Array ( [0] => 42S22 [1] => 1054 [2] => Unknown column 'address' in 'field list' ) 数组([0] => 42S22 [1] => 1054 [2] =>“字段列表”中的未知列“地址”)

I am trying to transfer details from a form to a database. 我正在尝试将详细信息从表单传输到数据库。 I don't know if the problem is related to following input on form: 我不知道问题是否与表单上的以下输入有关:

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

Input::get($item) returns $_POST[$item] if it is set. 输入::: get($ item)返回$ _POST [$ item](如果已设置)。 Other entries are like: 其他条目如下:

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

and do not create problems. 并且不会造成问题。 I have tried using print_r($e->errorInfo()); 我试过使用print_r($ e-> errorInfo()); in my catch statement: 在我的catch语句中:

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

but that doesn't work. 但这不起作用。 I don't know if I am using it correctly or not. 我不知道我是否正确使用它。 Could someone offer a suggestion. 有人可以提出建议。 I would be very grateful. 我会很感激。

I think you haven't updated your database. 我认为您尚未更新数据库。 You try to fetch a columns from your database which doesn't exist. 您尝试从数据库中获取不存在的列。

So check where you have a field named address and check if the field is correct. 因此,请检查您在何处有一个名为address的字段,并检查该字段是否正确。

Many thanks for the replies. 非常感谢您的答复。

QI think you haven't updated your database. QI认为您尚未更新数据库。 You try to fetch a columns from your database which doesn't exist. 您尝试从数据库中获取不存在的列。

I have checked that and that's not the problem. 我已经检查过了,那不是问题。 I think the problem lies with the following functions: 我认为问题在于以下功能:

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() through, $values .= '?'; insert()通过$ values。='?'; is creating ? 在创造吗? as the values for the fields. 作为字段的值。 query() through bindValue() is giving values to those fields to be inserted. query()通过bindValue()为要插入的字段提供值。 I have a feeling address, which allows for new lines, spaces and commas, is causing problems when it comes to the binding. 我有一个感觉的地址,该地址允许使用新行,空格和逗号,在进行绑定时会引起问题。 I wonder if you agree and if so have you a solution? 我想知道您是否同意,是否有解决方案?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 usort可与WAMP配合使用,并在远程服务器上给出语法错误。 - usort works fine with WAMP, gives syntax error on remote server. header()适用于Wamp,但不适用于服务器 - header() works with wamp but not on server PHPMailer可在WAMP上使用,但不能在生产服务器上使用 - PHPMailer Works on WAMP but not on Production Server 无法在WAMP上CURL HTTPS URL,但可以在使用BASH的远程服务器上使用 - Can't CURL HTTPS URL on WAMP but works on remote server using BASH 应用程序不能在 WAMP 上运行,但可以在在线服务器上运行 - App is not working on WAMP but It works in online server 脚本可以在Wamp服务器上运行,但不能在我的VPS上运行 - script works on wamp server but not on my vps 会话在Wamp上不起作用,但在实时服务器上起作用 - Session not working on wamp but works on live server CSV上传适用于本地WAMP,但不适用于使用LOAD DATA的远程LAMP - CSV upload works with local WAMP but not with remote LAMP using LOAD DATA Codeigniter Force 下载适用于 WAMP 但不适用于真实服务器 - Codeigniter Force download works in WAMP but not works in real server PHP包括在WAMP上解释得很好,但在远程服务器上被忽略 - PHP Includes interpreted fine on WAMP but ignored on remote server
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM