ccrevcypsys Posted August 20, 2007 Share Posted August 20, 2007 Does it just go to the main page after i hit delete. I really dont understand this someone please please help me. I need it badly! When i click on delete above the song it is supposed to delete the song off of the database but instead of doing that it just sends me back to the index page. here is the code <?php $products = $db->select("SELECT * FROM ".$glob['dbprefix']."CubeCart_inventory WHERE ".$glob['dbprefix']."CubeCart_inventory.customer_id=".$db->mySQLsafe($ccUserData[0]['customer_id'])); if($products == TRUE){ if(isset($_GET['delete']) && $_GET["delete"]>0){ // delete product $where = "productId=".$db->mySQLSafe($_GET["delete"]); $delete = $db->delete($glob['dbprefix']."CubeCart_inventory", $where); // set categories -1 $cats = $db->select("SELECT cat_id FROM ".$glob['dbprefix']."CubeCart_cats_idx WHERE productId=".$db->mySQLSafe($_GET["delete"])); if($cats==TRUE){ for($i=0;$i<count($cats);$i++){ $db->categoryNos($cats[$i]['cat_id'], "-"); } } // delete category index $where = "productId=".$db->mySQLSafe($_GET["delete"]); $deleteIdx = $db->delete($glob['dbprefix']."CubeCart_cats_idx", $where); unset($record); // delete product options $record['product'] = $db->mySQLSafe($_GET["delete"]); $where = "product=".$db->mySQLSafe($_GET["delete"]); $deleteOps = $db->delete($glob['dbprefix']."CubeCart_options_bot", $where); unset($record);} ?> [<a href="javascript:decision('Are you sure you want to delete this?','?delete={PRODUCT_ID}&cat_id={CAT_ID}');">{LANG_DELETE_LINK}</a>] </table></td> Quote Link to comment https://forums.phpfreaks.com/topic/65851-solved-why/ Share on other sites More sharing options...
Psycho Posted August 20, 2007 Share Posted August 20, 2007 Probably a problem with your javascript link. Check the code for the decision() function. Quote Link to comment https://forums.phpfreaks.com/topic/65851-solved-why/#findComment-329103 Share on other sites More sharing options...
ccrevcypsys Posted August 20, 2007 Author Share Posted August 20, 2007 Probably a problem with your javascript link. Check the code for the decision() function. I dont think it is here is the js code and it looks right to me. // display decision alert box function decision(message, url){ if(confirm(message)) location.href = url; } Quote Link to comment https://forums.phpfreaks.com/topic/65851-solved-why/#findComment-329323 Share on other sites More sharing options...
MadTechie Posted August 20, 2007 Share Posted August 20, 2007 view source and check that the {PRODUCT_ID}&cat_id={CAT_ID} are set correctly (ie being the numbers and not static text) Quote Link to comment https://forums.phpfreaks.com/topic/65851-solved-why/#findComment-329326 Share on other sites More sharing options...
ccrevcypsys Posted August 20, 2007 Author Share Posted August 20, 2007 view source and check that the {PRODUCT_ID}&cat_id={CAT_ID} are set correctly (ie being the numbers and not static text) they are i have made sure of that. they come up as numbers and they also match the database numbers. I see no reason why this will not work. Quote Link to comment https://forums.phpfreaks.com/topic/65851-solved-why/#findComment-329327 Share on other sites More sharing options...
ccrevcypsys Posted August 20, 2007 Author Share Posted August 20, 2007 Any ideas ANY ONE? PLEASE! ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? Quote Link to comment https://forums.phpfreaks.com/topic/65851-solved-why/#findComment-329329 Share on other sites More sharing options...
MadTechie Posted August 20, 2007 Share Posted August 20, 2007 well as its handled by your class check from their.. echo the statements etc Quote Link to comment https://forums.phpfreaks.com/topic/65851-solved-why/#findComment-329334 Share on other sites More sharing options...
ccrevcypsys Posted August 20, 2007 Author Share Posted August 20, 2007 madtechie im sorry but i am a n00b at php so what statements do i echo? Here is the delete function from the db.inc.php class page function delete($tablename, $where, $limit="") { $query = "DELETE from ".$tablename." WHERE ".$where; if ($limit!="") $query .= " LIMIT " . $limit; $this->query = $query; mysql_query($query, $this->db); if ($this->error()) die ($this->debug()); if ($this->affected() > 0){ return TRUE; } else { return FALSE; } } // end delete Quote Link to comment https://forums.phpfreaks.com/topic/65851-solved-why/#findComment-329340 Share on other sites More sharing options...
MadTechie Posted August 20, 2007 Share Posted August 20, 2007 your see some statements like DELETE FROM table where X =1 normally in or near a mysql_query( in your included file (class) your see function delete( you need to echo the string being passed to mysql_query( Quote Link to comment https://forums.phpfreaks.com/topic/65851-solved-why/#findComment-329341 Share on other sites More sharing options...
ccrevcypsys Posted August 20, 2007 Author Share Posted August 20, 2007 echo mysql_query($query, $this->db); like this? cause it didnt do anything... Quote Link to comment https://forums.phpfreaks.com/topic/65851-solved-why/#findComment-329344 Share on other sites More sharing options...
MadTechie Posted August 20, 2007 Share Posted August 20, 2007 close, try echo $query; mysql_query($query, $this->db); this should display DELETE blar blar blar blar blar blar can you post that, it may provide some insight Quote Link to comment https://forums.phpfreaks.com/topic/65851-solved-why/#findComment-329348 Share on other sites More sharing options...
ccrevcypsys Posted August 20, 2007 Author Share Posted August 20, 2007 well it isnt saying anything anywhere. it just brings me back to the index when i click on delete. Should i have to click on delete for it to work or not??? Quote Link to comment https://forums.phpfreaks.com/topic/65851-solved-why/#findComment-329349 Share on other sites More sharing options...
ccrevcypsys Posted August 20, 2007 Author Share Posted August 20, 2007 This is what i got when i did it in my admin section. But i need it to work on the regular customer section. DELETE from cc_CubeCart_inventory WHERE productId='350'DELETE from cc_CubeCart_cats_idx WHERE productId='350'DELETE from cc_CubeCart_options_bot WHERE product='350' Quote Link to comment https://forums.phpfreaks.com/topic/65851-solved-why/#findComment-329351 Share on other sites More sharing options...
MadTechie Posted August 20, 2007 Share Posted August 20, 2007 humm its running 4 times.. thats not right.. change $delete = $db->delete($glob['dbprefix']."CubeCart_inventory", $where); to $delete = $db->delete($glob['dbprefix']."CubeCart_inventory", $where, "0,1"); edit: updated Quote Link to comment https://forums.phpfreaks.com/topic/65851-solved-why/#findComment-329355 Share on other sites More sharing options...
ccrevcypsys Posted August 20, 2007 Author Share Posted August 20, 2007 it still just returns me to the index page well hey it works in the admin section and this is the code from the admin section (thats where i got the query echo from). is it because on the customers section i took the permission off? if(permission("products","read")==FALSE){ header("Location: ".$GLOBALS['rootRel']."admin/401.php"); exit; } if(isset($_GET['delete']) && $_GET["delete"]>0){ // delete product $where = "productId=".$db->mySQLSafe($_GET["delete"]); $delete = $db->delete($glob['dbprefix']."CubeCart_inventory", $where); // set categories -1 $cats = $db->select("SELECT cat_id FROM ".$glob['dbprefix']."CubeCart_cats_idx WHERE productId=".$db->mySQLSafe($_GET["delete"])); if($cats==TRUE){ for($i=0;$i<count($cats);$i++){ $db->categoryNos($cats[$i]['cat_id'], "-"); } } // delete category index $where = "productId=".$db->mySQLSafe($_GET["delete"]); $deleteIdx = $db->delete($glob['dbprefix']."CubeCart_cats_idx", $where); unset($record); // delete product options $record['product'] = $db->mySQLSafe($_GET["delete"]); $where = "product=".$db->mySQLSafe($_GET["delete"]); $deleteOps = $db->delete($glob['dbprefix']."CubeCart_options_bot", $where); unset($record); if($delete == TRUE){ $msg = "<p class='infoText'>".$lang['admin']['products']['delete_success']."</p>"; } else { $msg = "<p class='warnText'>".$lang['admin']['products']['delete_fail']."</p>"; } <td align="center" width="10%" class="<?php echo $cellColor; ?>"><a <?php if(permission("products","delete")==TRUE){ ?>href="javascript:decision('<?php echo $lang['admin']['delete_q'];?>','?delete=<?php echo $results[$i]['productId']; ?>&cat_id=<?php echo $results[$i]['cat_id']; ?>');" class="txtLink"<?php } else { echo $link401; } ?>><?php echo $lang['admin']['delete'];?></a></td> Quote Link to comment https://forums.phpfreaks.com/topic/65851-solved-why/#findComment-329359 Share on other sites More sharing options...
MadTechie Posted August 20, 2007 Share Posted August 20, 2007 without knowing the class its hard to say but from what you posted $delete = $db->delete($glob['dbprefix']."CubeCart_inventory", $where, "0,1"); should work Quote Link to comment https://forums.phpfreaks.com/topic/65851-solved-why/#findComment-329364 Share on other sites More sharing options...
ccrevcypsys Posted August 22, 2007 Author Share Posted August 22, 2007 well the reason why it repeats 4 times is because it deletes it off of four tables. but the problem is, is that even if you click the link it just wont go thru. It wont run the code it just keeps sending me to the main page. Quote Link to comment https://forums.phpfreaks.com/topic/65851-solved-why/#findComment-330981 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.