spofster Posted July 24, 2003 Posted July 24, 2003 I have added 2 fields to customer table : sub_start_date, sub_end_date. Now when a customer buys a subscription from my site i want to update the cust. tbl. This update is done on the "checkout_success.php" The problem is is not updating the customers record. It finds the correct customer record. here is the code: $products_array = array(); $products_query = tep_db_query("select products_id, products_name from " . TABLE_ORDERS_PRODUCTS . " where orders_id = '" . $orders['orders_id'] . "' order by products_name"); while ($products = tep_db_fetch_array($products_query)) { $products_array[] = array('id' => $products['products_id'], 'text' => $products['products_name']); // subscription === start $startdate = date("Y-m-00"); $enddate = date("Y-m-00", date("U") + date("t")*11*24*60*60 ); if ($products['products_id'] = 30) tep_db_query("update " . TABLE_CUSTOMERS . " set sub_start_date = $startdate, sub_end_date = $enddate where customers_id = '" . $customer_id . "'"); I also check to see if the subscription is being purchased (products_id = 30) Anybody have any ideas.
spofster Posted July 28, 2003 Author Posted July 28, 2003 :( I really really need some help :( I posted my problem previously on the 24 July.. someone help will realy be gr8! spofster :!: :!:
Guest Posted July 28, 2003 Posted July 28, 2003 the if statement is wrong, needs to be $products['products_id'] == 30 if ($products['products_id'] = 30) tep_db_query("update " . TABLE_CUSTOMERS . " set sub_start_date = $startdate, sub_end_date = $enddate where customers_id = '" . $customer_id . "'"); and perhaps add some debug to find out what is happening if ($products['products_id'] == 30) { echo "update " . TABLE_CUSTOMERS . " set sub_start_date = $startdate, sub_end_date = $enddate where customers_id = '" . $customer_id . "'"; tep_db_query("update " . TABLE_CUSTOMERS . " set sub_start_date = $startdate, sub_end_date = $enddate where customers_id = '" . $customer_id . "'"); } that should give you an idea if the query is correct
spofster Posted July 30, 2003 Author Posted July 30, 2003 Thanx meltus.. is shows all the right stuff bieng used and everything, but it still not updating the database.. im trying to update a date field in my mysql table.
Guest Posted July 30, 2003 Posted July 30, 2003 what does the output from the echo statement say - and what happens when you run the query in phpAdmin?
spofster Posted July 31, 2003 Author Posted July 31, 2003 hey meltus... :D the query looks like this... update customers set sub_start_date = 2003-07-00, sub_end_date = 2004-07-00 where customers_id = '3' now the query is fine, coz it only works for product id=30. And it is putting in the correct values for the start and end date. Put it not updating the two fields in the database. I have tried running the above query in phpAdmin, still nothing. :?: :?: Now is there something i have to do, to make it commit the changes? :!: :!:
Recommended Posts
Archived
This topic is now archived and is closed to further replies.