leveera Posted August 31, 2010 Posted August 31, 2010 Trying to write a script deleting records from products_notifications table where we have products_id customers_id date_addded The script I applying seems is wrong but it gives no error message and no delete Any help or hints are welcome // delete notification start if (tep_not_null($action)) { switch ($action) { case 'remove': $customers_id = tep_db_prepare_input($customers['customers_id']); $products_id = tep_db_prepare_input($_GET['pID']); tep_db_query("DELETE FROM" . TABLE_PRODUCTS_NOTIFICATIONS . "WHERE customers_id = '" . (int)$customers_id . "' AND products_id ='". (int)$products_id ."'"); tep_redirect(tep_href_link(FILENAME_STATS_PRODUCTS_NOTIFICATIONS,'NONSSL')); break; default: } } // delete notification end <td class="dataTableContent"><?php echo '<a href="' . tep_href_link(FILENAME_STATS_PRODUCTS_NOTIFICATIONS, 'cID='. $customers['customers_id']. '&pID=' . $_GET['pID'].'action=remove') . '">' . tep_image(DIR_WS_ICONS . 'delete.gif', IMAGE_ICON_DELETE) . '</a>';?></td> if to test by echo $customers['customers_id'] and echo $products_id it displays correct ids Thanks Sergei
Jan Zonjee Posted August 31, 2010 Posted August 31, 2010 The script I applying seems is wrong but it gives no error message and no delete But it looks like the query will be DELETE FROMproducts_notificationsWHERE customers_id etcetera which doesn't mean anything.
leveera Posted September 1, 2010 Author Posted September 1, 2010 ...which doesn't mean anything. OK... let me simplify <td class="dataTableContent"><?php echo '<a href="stats_products_notifications.php?delete&cID='. $customers['customers_id']. '&pID=' . $_GET['pID'].'">' . tep_image(DIR_WS_ICONS . 'delete.gif', IMAGE_ICON_DELETE) . '</a>';?></td> The result string for example is .../stats_products_notifications.php?delete&cID=14&pID=92 How to write correct delete script using this query? if (isset($_GET['delete'])) { mysql_query("DELETE FROM products_notifications WHERE customers_id =". ...... ."AND products_id =". ......); }
Jan Zonjee Posted September 1, 2010 Posted September 1, 2010 OK... let me simplify How to write correct delete script using this query? You need spaces between the words. DELETE FROM products_notifications WHERE customers_id tep_db_query("DELETE FROM " . TABLE_PRODUCTS_NOTIFICATIONS . " WHERE customers_id = '" . (int)$customers_id . "' AND products_id ='". (int)$products_id ."'");
leveera Posted September 3, 2010 Author Posted September 3, 2010 You need spaces between the words. DELETE FROM products_notifications WHERE customers_id tep_db_query("DELETE FROM " . TABLE_PRODUCTS_NOTIFICATIONS . " WHERE customers_id = '" . (int)$customers_id . "' AND products_id ='". (int)$products_id ."'"); Very strange advice... anyway it doesn't work Thanks for attempt!
Recommended Posts
Archived
This topic is now archived and is closed to further replies.