Jump to content

gabrielp

Members
  • Posts

    11
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

gabrielp's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thank you all guys !!!! I finally used $myrow = mysql_fetch_array($result); $date_activation = $myrow['start_date']; $months = $myrow['type']; $timestamp_activation = strtotime($date_activation); $timestamp_type = strtotime("$months months ago"); if ($timestamp_activation < $timestamp_type) { //subscription expired } but I will try the mySql way too Thanks!!
  2. Here you have sample data: $date_activation = $myrow['start_date']; // Sample date: "2008-12-18 08:00:47" $months = $myrow['type']; // Sample value = 1 (means 1 month) or 12 means 12 months
  3. Hi, I have been using the following code all 2008 , it checks if user is active, check last activation date, number of months paid, add that time to the last activation date and also check if date is grater than actual date. It worked great until Jan 1st, when I guess there's a problem with users with active accounts on 2008 and months calculation with 2009 <?php $myrow = mysql_fetch_array($result); $date_activation = $myrow['start_date']; $months = $myrow['type']; $date_now = date("Y-m-d h:m:s", time()); $qty_years=floor($months/12); $qty_months=$months%12; $bits=explode("-",$date_activation); $year=$bits[0]; $month = sprintf('%02d',$bits[1]); $newyear=$year+$qty_years; $newmonth=sprintf('%02d', $month+$qty_months); $date_expires=$newyear."-".$newmonth."-".$bits[2]; if ($date_now <= $date_expires) { // user is active, write a cookie and say welcome } else { // subscription expired } ?> Thanks for all the help that you can provide! (edited to change tags to tags)
  4. Thanks fenway !! That did the trick ! Thanks so much for your time. Gabriel.
  5. SELECT @@version; gives me 4.0.27-standard It's really frustrating as I need to continue working and this subquery is not working, and is a simple one...
  6. I double checked and my Hosting control panels says mySql 5, but my phpMyAdmin control panel says MySQL 4.0.27-standard running on localhost in this version, the syntax is different?
  7. all the values are numbers, no strings here. What is strange is that if I do the following query it works: SELECT DISTINCT order_number FROM orders, ordercart WHERE orders.confirmed =1 AND orders.order_number = ordercart.id AND DATE_FORMAT( thedate, '%d' ) =03 AND DATE_FORMAT( thedate, '%m' ) =04 AND DATE_FORMAT( thedate, '%Y' ) =2008 without the subquery.... and even the inner part of the subquery works as a single query, so there are no mistakes in column or table names...
  8. Hi I'm trying to do a simple subquery. I have the following tables: Orders = Purchases made ordercart = list of products that belong to each purchase Categories = product list Designers = designer that have created that product ordercart.product = categories.catid orders.order_number = ordercart.id categories.designerid = designers.designerid I need all the order numbers that have products that belong to a specific designer so I can calculate commissions of sale for a given day. If I run these 2 queries by their own, they work ok, if I run them as a subquery, it gives me the following error. What's wrong with the syntax?? SQL-query: Documentation SELECT DISTINCT order_number FROM orders, ordercart WHERE orders.confirmed =1 AND orders.order_number = ordercart.id AND DATE_FORMAT( thedate, '%d' ) =03 AND DATE_FORMAT( thedate, '%m' ) =04 AND DATE_FORMAT( thedate, '%Y' ) =2008 AND product IN ( SELECT catid FROM categories WHERE designerid =9 ) LIMIT 0 , 30 MySQL said: Documentation #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 'SELECT catid FROM categories WHERE designerid = 9) LIMIT 0, 30'
  9. This works GREAT Thanks so much Gabriel.
  10. Hello there, I need to do the following calculations... I have a starting date, and I need to know the exact date from that day + x number of months. $start_date = '2008-01-11 06:38:44'; $qty_months = 13; $final_date = ?????; Thanks, Gabriel.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.