【问题标题】:how to escape and save data to simpledb in node.js如何在 node.js 中转义并将数据保存到 simpledb
【发布时间】:2011-07-30 10:10:20
【问题描述】:

我正在使用 simpldb 并试图将 rahul' mehta 保存在 simpledb 中,但它给了我以下错误: 代码:

   function htmlEscape(text) {
     return text.replace(/&/g,'&').
         replace(/</g,'&lt;').
         replace(/"/g,'&quot;').
         replace(/'/g,'&#039;');
    }
    console.log(params.filename);

  if (params.filename!=undefined) params.filename=htmlEscape(params.filename);
    console.log(sys.inspect(params));
  sdb.putItem(domain, params.objectid, params, function( error ) {
  });

输出:

rahul' mehta

{ 
  filename: 'rahul&#039; mehta',
  }

错误:

   {"event":"error","errno":"InvalidQueryExpression","message":"The specified query expression syntax is not valid.","queueno":7}

为什么会出现这个错误,我该如何解决?

【问题讨论】:

    标签: node.js amazon-simpledb html-escape-characters


    【解决方案1】:

    此错误是因为您尝试运行 Amazon SimpleDB SELECT Query 并且该查询的语法错误。这可能是因为在查询中 -- 属性值 -- 必须用 单引号 即“属性值”来解开,如果 -- 域名 -- 和 -- 属性名称 -- 包含任何特殊字符,然后它们必须用尖音符解开,即Domain NameAttribute Name。我认为您可以保存 rahul' mehta 但是当您尝试获取已保存的属性值时,您会收到此错误。 http://www.sdbexplorer.com/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-03-11
      • 1970-01-01
      • 2019-06-23
      相关资源
      最近更新 更多