SitePoint Sponsor

User Tag List

Page 2 of 2 FirstFirst 12
Results 26 to 36 of 36
  1. #26
    SitePoint Enthusiast
    Join Date
    Apr 2005
    Posts
    52
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry,

    the updated code

    Code:
    $sql = mysql_query("DELETE FROM $store_item1 WHERE TO_DAYS(item_exp) - TO_DAYS(NOW()) < 0");
    but it did not delete the data

  2. #27
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,578
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Either "$store_item1" did not have the right value, or there's nothing in the database with an expiration date in the past.

    To see if the query's running or not:

    PHP Code:
    $sql "DELETE FROM $store_item1 WHERE TO_DAYS(item_exp) - TO_DAYS(NOW()) < 0";
    $result mysql_query($sql) or die(mysql_error()); 

  3. #28
    SitePoint Enthusiast
    Join Date
    Apr 2005
    Posts
    52
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dan,

    What I did to make sure the store_item gives resultd

    Code:
    //show categories first
    $get_cats =  "SELECT item_id, item_title, item_desc, item_subdesc, time_stamp, store_image, item_image, item_code, item_exp, sort_id, dept_id, TO_DAYS(item_exp) - TO_DAYS(CURDATE()) AS item_days_to_expiration, TO_DAYS(item_exp) - TO_DAYS(NOW()) As t FROM store_item1 WHERE item_exp LIKE '200%%%%%' ORDER BY `item_exp`ASC  limit $dept_id,$limit";
    $get_cats_res = mysql_query($get_cats) or die(mysql_error());
    
            $item_id  = $cats[item_id];
            $sort_id  = $cats[sort_id];
            $item_title = stripslashes($cats[item_title]);
            $item_desc = stripslashes($cats[item_desc]);
            $item_code = stripslashes($cats[item_code]);
            $item_exp = stripslashes($cats[item_exp]);
            $item_image = stripslashes($cats[item_image]);
            $store_image = stripslashes($cats[store_image]);
            $item_subdesc = stripslashes($cats[item_subdesc]);
            $item_days_to_expiration = $cats['item_days_to_expiration'];
            $t = $cats['t'];
    
    
    $t shows as -4, -3 , -2 and all
    so the date is there

  4. #29
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,578
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    This query does not use any date from your other query. It doesn't need any external data. The problem is you used a variable for the table name when I don't think you meant to.

    PHP Code:
     $sql "DELETE FROM store_item1 WHERE TO_DAYS(item_exp) - TO_DAYS(NOW()) < 0";
    $result mysql_query($sql) or die(mysql_error()); 

  5. #30
    SitePoint Enthusiast
    Join Date
    Apr 2005
    Posts
    52
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I get this message

    Code:
    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 'WHERE TO_DAYS(item_exp) - TO_DAYS(NOW()) < 0' at line 1

  6. #31
    SitePoint Enthusiast
    Join Date
    Apr 2005
    Posts
    52
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dan,

    Any more suggestions.

    The message I get is

    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 'WHERE TO_DAYS(item_exp) - TO_DAYS(NOW()) < 0' at line 1

  7. #32
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,578
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    It's because of what I said in my last post.

    You really should post a listing in the Looking to Hire forum or your favorite job postings site to find a programmer.

  8. #33
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,631
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    ^^^ Probably the best bit of advice in this thread.
    Ian Anderson
    www.siteguru.co.uk

  9. #34
    SitePoint Enthusiast
    Join Date
    Apr 2005
    Posts
    52
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Dan & SiteGuru,

    First of all I would like to thanks you both for helping me with your suggestions and comments.

    I just wanted to understand that what level of knowledge/expertise you should have before you can request for help in the forums?

    Lot of people like me are starters who may or may not have software knowledge background but may be trying to learn and understand how the scripts work.

    More important is that there should be a zeal, commitment and dedication to learn.

    Nothing is impossible.

    I know lot of people like you have quite a knowledge that the qeries put forward by me must have irritated you..... but try to go back to the first year after you learnt programming.... how did you feel.

    Hope you would understand and not try to make a person feel that he is use for nothing.

    regards

  10. #35
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,631
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    I think what Dan was suggesting (and which I agree with) is that it looks like you are trying to run before you can walk - you've bitten off more than you can chew. If what you are working on is for a commercial venture then you'd be much better getting a professional to do this for you than trying to muddle your way through.

    The complexity of what you're trying to do looks very like what would be needed for a commercial venture. If it's simply a learning exercise then it's way too advanced for the apparent level you are at right now.

    The comment wasn't intended as an insult on your capabilities, just some friendly advice on how to achieve quickest resolution to your immediate requirements.

    Ian Anderson
    www.siteguru.co.uk

  11. #36
    SitePoint Enthusiast
    Join Date
    Apr 2005
    Posts
    52
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Siteguru,

    Thanks for your reply.

    Its all the learning for personal use. I have PM'ed you the examples of implementation... rather than posting here.

    Take care.

    regards


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •