ccrevcypsys Posted August 22, 2007 Share Posted August 22, 2007 So ive been bugging you guys about the delete function but nvm. Im just going to change the product to have a variable that is either a 1 or a 0. 0 being (not deleted) and 1 being vice versa. but im having a problem getting the insert update to find the productId here is the code if($products == TRUE){ if(isset($_POST['deleted'])) { $record["deleted"] = $db->mySQLSafe($_POST['deleted']); $where = "productId = ".$results[$i]['productId']; $insert = $db->update($glob['dbprefix']."CubeCart_inventory", $record , $where); }else{ $artist_console->assign("ERR_DEL",$lang['front']['viewOrder']['err_del']); } Quote Link to comment https://forums.phpfreaks.com/topic/66183-solved-so-i-found-a-new-way-but-need-help/ Share on other sites More sharing options...
trq Posted August 22, 2007 Share Posted August 22, 2007 What is the problem exactly? Are you getting any errors? ps: Your code means very little to us as your not using the standard mysql functions, but some custom class. Quote Link to comment https://forums.phpfreaks.com/topic/66183-solved-so-i-found-a-new-way-but-need-help/#findComment-331028 Share on other sites More sharing options...
ccrevcypsys Posted August 22, 2007 Author Share Posted August 22, 2007 This is the error i get MySQL Error Occured 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 QUERY = UPDATE cc_CubeCart_inventory SET `deleted`='1' WHERE productId = its not finding the product id so that means this is wrong $where = "productId = ".$results[$i]['productId']; and i dont know how to get it to work Quote Link to comment https://forums.phpfreaks.com/topic/66183-solved-so-i-found-a-new-way-but-need-help/#findComment-331031 Share on other sites More sharing options...
xyn Posted August 22, 2007 Share Posted August 22, 2007 paste the entire query Quote Link to comment https://forums.phpfreaks.com/topic/66183-solved-so-i-found-a-new-way-but-need-help/#findComment-331039 Share on other sites More sharing options...
lemmin Posted August 22, 2007 Share Posted August 22, 2007 It means that whatever method you are using to put a value into product id isn't working. Post some code on that or echo some stuff and try to trace it back. Quote Link to comment https://forums.phpfreaks.com/topic/66183-solved-so-i-found-a-new-way-but-need-help/#findComment-331053 Share on other sites More sharing options...
ccrevcypsys Posted August 22, 2007 Author Share Posted August 22, 2007 where should i echo? im still new to php i can edit it but i cant really make code yet. sorry well here i tried this tell me if its right if(isset($_POST['deleted'])) { $record["deleted"] = $db->mySQLSafe($_POST['deleted']); $where = "productId = ".$db->mySQLSafe($_POST['productId'])." AND cat_id = ".$db->mySQLSafe($_POST['cat_id']); $insert = $db->update($glob['dbprefix']."CubeCart_inventory", $record , $where); echo $insert Quote Link to comment https://forums.phpfreaks.com/topic/66183-solved-so-i-found-a-new-way-but-need-help/#findComment-331063 Share on other sites More sharing options...
lemmin Posted August 22, 2007 Share Posted August 22, 2007 $insert is probably a resource, so it probably won't show anything useful, but I don't know what your class is returning. Otherwise, looks right, assuming you have a 'productid' in the $_POST array. I don't know how your code works because you havn't shown much. It would be easier for people to help you if you showed more code. Quote Link to comment https://forums.phpfreaks.com/topic/66183-solved-so-i-found-a-new-way-but-need-help/#findComment-331065 Share on other sites More sharing options...
ccrevcypsys Posted August 22, 2007 Author Share Posted August 22, 2007 k heres the form code <form name="delete" action="index.php?act=artistConsole" enctype="multipart/form-data" method="post"> <input name="deleted" type="hidden" class="textbox" value="1"> <input name="productid" type="hidden" class="textbox" value="{PRODUCT_ID}" /> <input name="submit" type="submit" value="Delete" class="submit" /> </form> php code if(isset($_POST['deleted'])) { $record["deleted"] = $db->mySQLSafe($_POST['deleted']); $record["productId"]= $db->mySQLSafe($_POST['productId']); $where = "productId = ".$db->mySQLSafe($_POST['productId']); $insert = $db->update($glob['dbprefix']."CubeCart_inventory", $record , $where); }else{ $artist_console->assign("ERR_DEL","Error, Cannot Delete For Some Reason"); $artist_console->parse("artist_console.order_true.session_true.error_true"); } db class code function update ($tablename, $record, $where) { if(!is_array($record)) die ($this->debug("array", "Update", $tablename)); $count = 0; foreach ($record as $key => $val) { if ($count==0) $set = "`".$key."`"."=".$val; else $set .= ", " . "`".$key."`". "= ".$val; $count++; } $query = "UPDATE ".$tablename." SET ".$set." WHERE ".$where; $this->query = $query; mysql_query($query, $this->db); if ($this->error()) die ($this->debug()); if ($this->affected() > 0) return true; else return false; } // end update Quote Link to comment https://forums.phpfreaks.com/topic/66183-solved-so-i-found-a-new-way-but-need-help/#findComment-331070 Share on other sites More sharing options...
ccrevcypsys Posted August 22, 2007 Author Share Posted August 22, 2007 This is the error i get when i echo the $query on the db.inc.php UPDATE cc_CubeCart_sessions SET `location`='/index.php?act=artistConsole', `timeLast`= '1187801649' WHERE sessId='a018db8f867e287d0b826fad1c40d886'UPDATE cc_CubeCart_inventory SET `deleted`='1', `productId`= '' WHERE productId = ''UPDATE cc_CubeCart_inventory SET `deleted`='1', `productId`= '' WHERE productId = ''UPDATE cc_CubeCart_inventory SET `deleted`='1', `productId`= '' WHERE productId = ''UPDATE cc_CubeCart_inventory SET `deleted`='1', `productId`= '' WHERE productId = ''UPDATE cc_CubeCart_inventory SET `deleted`='1', `productId`= '' WHERE productId = '' Quote Link to comment https://forums.phpfreaks.com/topic/66183-solved-so-i-found-a-new-way-but-need-help/#findComment-331084 Share on other sites More sharing options...
lemmin Posted August 22, 2007 Share Posted August 22, 2007 Are you typing a product id in? It would seem that $db->mySQLSafe() is returning a null value when passing $_POST['productId']. Of course, it might be null before it is passed. Try putting an echo $_POST['productId'] right after the line "if(isset($_POST['deleted'])) {" and see what it outputs. Doing something like echo "!!$_POST['productId']!!"; makes it easier to spot where in the output it is. Quote Link to comment https://forums.phpfreaks.com/topic/66183-solved-so-i-found-a-new-way-but-need-help/#findComment-331114 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.