Update MySql after time
Results 1 to 15 of 15

Thread: Update MySql after time

  1. #1
    Member
    Join Date
    Nov 2012
    Posts
    43

    Update MySql after time

    Hey, Id like to ask how could I automatically update a database after certain ammount of time passed?

    I have listed people with birthdays, and when I send them an email it adds email sent text beside their name. I do that by changing a value in database. Now I need to make it so that value goes back to 0 after like half a year so that for their next birthday I am able to do the same.

  2. #2
    Member
    Join Date
    Nov 2012
    Posts
    43

    Unknown system variable

    Hello, when I try to enable event_scheduler I get an error:

    Unknown system variable 'event_scheduler'

    And I used mysql_query("SET GLOBAL event_scheduler = ON")

    Any ideas on how could I fix that?

  3. #3
    Senior Member
    Join Date
    Aug 2008
    Location
    London, UK
    Posts
    753
    What version of MySQL are you using? Just done a bit of digging and it seems that the event scheduler is only available in MySQL 5.1.6 and later.
    Ashley Sheridan
    www.ashleysheridan.co.uk

  4. #4
    Senior Member
    Join Date
    Aug 2008
    Location
    London, UK
    Posts
    753
    Why don't you do it the same way that you're doing to add the text beside their name? Also, I'm assuming from your post that you're actually adding text to their name field in the DB? Why not use a separate field for this?
    Ashley Sheridan
    www.ashleysheridan.co.uk

  5. #5
    Member
    Join Date
    Nov 2012
    Posts
    43
    Ohh yes, you are right. I am running older version so I will not be able to use it as for now. Thanks for help.

  6. #6
    Member
    Join Date
    Nov 2012
    Posts
    43

    Help with app

    Hello, I need to create a birthday app for my website.

    What do I have so far:
    - Display people who have birthday in 1 week.
    - Click on them, type in email, send email.

    What I need:
    - Somehow add 'Email already sent' after sending an email to THAT person next to their name.
    - Make it so that I am unable to click on that user and send email again.
    - Make it so that after some time (like 11 months or so) I am able to send him another email ( new birthday ).

    I did it with start event function, but in this case I cant use it. I really need help on this one, thanks for all answers in advance.

  7. #7
    Senior Member
    Join Date
    Mar 2009
    Location
    Canada
    Posts
    794
    - The mail() function returns true if successful (note this doesn't mean the recipient will get the email, just that the function ran successfully), so display the message
    - If the mail() function is successful, add a value to the database that if set to true or if their birthday isn't in one week or whatever you cannot send another message
    - See above.

    Go.
    Prison of Mirrors
    Declare variables, not war.

  8. #8
    Member
    Join Date
    Nov 2012
    Posts
    43
    Hey, thanks for the reply

    I am not using mail() function, I have PHPMailer, sorry for not mentioning.

    Right now everything works and all, email arrives, but I need somehow to change it to Mail sent and after some time back to normal so its ready for next year.

  9. #9
    Pedantic Curmudgeon Weedpacket's Avatar
    Join Date
    Aug 2002
    Location
    General Systems Vehicle "Thrilled To Be Here"
    Posts
    21,774
    Quote Originally Posted by phpbuild12
    I am not using mail() function, I have PHPMailer, sorry for not mentioning.
    I'm pretty certain that PHPMailer is capable of saying whether it successfully sent an email or not -otherwise how would you know?

    See this example in the documentation:
    http://code.google.com/a/apache-extr...ial#First_time
    THERE IS AS YET INSUFFICIENT DATA FOR A MEANINGFUL ANSWER
    FAQs! FAQs! FAQs! Most forums have them!
    Search - Debugging 101 - Collected Solutions - General Guidelines - Getting help at all

  10. #10
    Member
    Join Date
    Nov 2012
    Posts
    43
    Ok, may I just ask what is wrong with this code:

    $select_that_user = mysql_query("SELECT Number, Surname, Name, Email, Birth FROM people WHERE Number = $id_click") or die(mysql_error());

    It doesnt works, but when I use it without WHERE Number = $id_click" it works :S

  11. #11
    Pedantic Curmudgeon Weedpacket's Avatar
    Join Date
    Aug 2002
    Location
    General Systems Vehicle "Thrilled To Be Here"
    Posts
    21,774
    What does it do instead?
    What is $id_click? What is it really, not just what you think it's supposed to be?
    Does mysql_error() say anything? What?

    Try and give us a bit of information when you ask questions.
    Last edited by Weedpacket; 11-22-2012 at 07:40 PM.
    THERE IS AS YET INSUFFICIENT DATA FOR A MEANINGFUL ANSWER
    FAQs! FAQs! FAQs! Most forums have them!
    Search - Debugging 101 - Collected Solutions - General Guidelines - Getting help at all

  12. #12
    Member
    Join Date
    Nov 2012
    Posts
    43
    Hey, will post about that later.

    Right now I have another question. I now save a date when an email has been sent into database, and write Email already sent beside their name. I need to make it now so that after few months or so I am able to click on them again and send another email for new birthday.
    Last edited by phpbuild12; 11-23-2012 at 02:23 AM.

  13. #13
    Senior Member
    Join Date
    Mar 2009
    Location
    Canada
    Posts
    794
    Quote Originally Posted by phpbuild12 View Post
    Hey, will post about that later.

    Right now I have another question. I now save a date when an email has been sent into database, and write Email already sent beside their name. I need to make it now so that after few months or so I am able to click on them again and send another email for new birthday.
    Honestly, your questions would be answered a lot quicker if you stuck to one at a time (and provided as many details as possible, including any relevant code).
    Prison of Mirrors
    Declare variables, not war.

  14. #14
    Member
    Join Date
    Nov 2012
    Posts
    43
    I know but Im working on it and sometimes find solution, sometimes get into another problem. Right now it seems to work fine, I just have to make it as I posted before

  15. #15
    Member
    Join Date
    Nov 2012
    Posts
    43
    Ok, now I made a little bit of a progress. Ive made it so when I send them an email for birthday, I created a new table and I insert ID of email sent (unique number, AI), date when it was sent, and to who.

    Now I need to make it so that it checks each one when it was send, and if it was sent more then 1 week ago do something else do something else. I did it with if statement, but it only takes the date of the last one sent, not each as individualy.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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