doujia1939
2014-03-23 12:41
浏览 38
已采纳

使用update子句更新postgres db时遇到问题

I'm having trouble updating my postgressdb using update clause where itemid = "$_get['itemid'];

here's my sql code but it returns Warning: pg_query(): Query failed: ERROR:

$sql="UPDATE tbl_item SET itemname='".$_POST['ItemName']."', highqntythreshold='".$_POST['HQThreshold']."', lowqntythreshold='".$_POST['LQThreshold']."', qntyperunit='".$_POST['QPUnit']."', itemtype='".$_POST['IT']."', description='".$_POST['Description']."', WHERE itemid='". $_GET['itemid'] . "';";
$iteminfo = pg_query($sql);

and it also returns "Warning: pg_affected_rows() expects parameter 1 to be resource, boolean given in D:\Wamp\wamp\www\Php\CTea\UpdateItem.php on line 303"

    if(pg_affected_rows($iteminfo)==1)
{
$msg = "Successfully added new Item, ".ucfirst($_POST['ItemName'])."!";         
}
else
{
$msg = "Error: in saving Item data!...";
}   

i think i messed up something but can't figure it out where and what i messed up.

图片转代码服务由CSDN问答提供 功能建议

我在使用update子句更新postgressdb时遇到问题,其中itemid =“$ _get ['itemid']; < / p>

这是我的sql代码,但它返回警告:pg_query():查询失败:错误:

  $  sql =“UPDATE tbl_item SET itemname ='”。$ _ POST ['ItemName']。“',highqntythreshold ='”。$ _ POST ['HQThreshold']。“',lowqntythreshold ='”。$ _ POST ['LQThreshold']  。“',qntyperunit ='”。$ _ POST ['QPUnit']。“',itemtype ='”。$ _ POST ['IT']。“',description ='”。$ _ POST ['Description']。“  ',WHERE itemid ='“。$ _GET ['itemid']。”';“; 
 $ iteminfo = pg_query($ sql); 
   
 
 

和 它还返回“警告:pg_affected_rows()期望参数1为资源,布尔值在第303行的D:\ Wamp \ wamp \ www \ Php \ CTea \ UpdateItem.php中给出”

  if(pg_affected_rows($ iteminfo)== 1)
 {
 $ msg =“成功添加新项目”,.ucfirst($ _ POST ['ItemName'])。“!  “; 
} 
else 
 {
 $ msg =”错误:保存项目数据!...“; 
} 
   
 
 

我想我搞砸了一些东西,但无法弄清楚我搞砸了哪里和什么。

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

相关推荐 更多相似问题