为了账号安全,请及时绑定邮箱和手机立即绑定

慕课商品添加,插入不进数据库

慕课商品添加,插入不进数据库

PHP
慕丝5297831 2016-06-06 11:23:54
/** * 添加商品 * @return string */function addPro(){ $arr=$_POST; $arr['addtime']=time(); $path="./uploads"; $uploadFiles=uploadFile($path); if(is_array($uploadFiles)&&$uploadFiles){ foreach($uploadFiles as $key=>$uploadFile){ thumb($path."/".$uploadFile['name'],"../image_50/".$uploadFile['name'],50,50); thumb($path."/".$uploadFile['name'],"../image_220/".$uploadFile['name'],220,220); thumb($path."/".$uploadFile['name'],"../image_350/".$uploadFile['name'],350,350); thumb($path."/".$uploadFile['name'],"../image_800/".$uploadFile['name'],800,800); } } $res=insert("store",$arr); print_r(res);die;           // 插入数据打印的是 0    $pid=getInsertId(); if($res&&$pid){ foreach($uploadFiles as $uploadFile){ $arr1['pid']=$pid; $arr1['imageAddr']=$uploadFile['name']; addAlbum($arr1); } $mes="<p>添加成功!</p><a href='addPro.php' target='mainFrame'>继续添加</a>|<a href='listPro.php' target='mainFrame'>查看商品列表</a>"; }else{ if(is_array($uploadFiles)&&$uploadFiles){ foreach($uploadFiles as $uploadFile){ if(file_exists("../image_800/".$uploadFile['name'])){ unlink("../image_800/".$uploadFile['name']); } if(file_exists("../image_50/".$uploadFile['name'])){ unlink("../image_50/".$uploadFile['name']); } if(file_exists("../image_220/".$uploadFile['name'])){ unlink("../image_220/".$uploadFile['name']); } if(file_exists("../image_350/".$uploadFile['name'])){ unlink("../image_350/".$uploadFile['name']); }  } } $mes="<p>添加失败!</p><a href='addPro.php' target='mainFrame'>重新添加</a>"; } return $mes;}
查看完整描述

1 回答

?
qq_阿湃_0

TA贡献1条经验 获得超1个赞


看下 insert 方法,是不是有问题(数据重复约束;数据字段名,字段类型,非空数值等)。

查看完整回答
1 反对 回复 2016-06-06
  • 1 回答
  • 1 关注
  • 1082 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信