PhP, Access/SQL, Data comparison problem. (I'm new to PhP)

Ask a Question related to PHP Development, Design and Development.

  1. #1

    Default PhP, Access/SQL, Data comparison problem. (I'm new to PhP)

    Hi All!
    I'm fairly new to PhP and basicly trying to learn right now. Now I have
    a problem - I have a fairly large collection of movies which people keep
    borrowing from me. And then not returning. So I've put together an
    Access database with three tables - my media library, a list of friends
    and email addresses, and a borrow table which uses foreign keys from the
    other two tables to see who has borrowed what. Borrow Table also has two
    other fields - the date borrowed, which is set to equal now() inside of
    access, and the date due, which is set to equal now()+14 - they are both
    "short date"s.

    Now I had another prloblem which was this: people would call me up at
    ungodly hours of the night asking if I had, say, The Excorcist. I would
    have to turn on my monitor, load up access, and then scroll through the
    list in order to confirm weather or not I had that title (I do). I've
    solved this problem by having a really cool and sexy PhP script which
    querries the database with an SQL querry based on the user's form. So
    thats that problem solved...

    So my friends come round at 2:45am wanting to borrow, say The Excorcist,
    or Mememento, and four weeks later I am looking for the exact same
    title. With my cool and sexy database its now really easy to know who
    has what, but what I really want is a PhP script (which I can set to run
    automaticly via the task scheduler) which would see what was overdue and
    then email that person asking them to return it.

    So a fairly simple problem but its been giving me a headache for the
    better part of three weeks. Now() in PhP returns the Unix datatime, I
    believe, which is of course not immediately compatible for comparison
    with the date-time returned by Access which is of this form:

    2004-08-27 00:00:00

    I dont really mind how this problem is solved - weather by SELECTing
    from the database WHERE overdue < now(), or by doing the same thing
    using PhPs date() function.

    But I would very much like some help wiht this problem as it has been
    plaguing me for three weeks now.

    (IIS and Apache on WinXP Prof. Corp. PhP version 4.3.7. Dynamic DNS:
    [url]http://djcf.sytes.net[/url]. The script I am working on is here:
    [url]http://djcf.sytes.net/mylibrary/email.php[/url])

    Thanks!

    Daniel
    Damiel Fisher Guest

  2. Similar Questions and Discussions

    1. Deployment problem - unable to access data when hostingtomcat on different machine than the client
      Hi, I am developing a flex application that uses servlets to retrieve data from the database and generates graphs. During development, I had the...
    2. Date comparison in a text data field
      I have a database column field defined as a text. I store dates in format: dd/mm/yyyy. The user passes a Start date search string in the same...
    3. Problem with data access
      i had a working site with iis5 winxp professional on a p4 machine. suddenly i am having problems with and the asp pages which have some updating...
    4. Access SQL- Date comparison problem
      I use an Access-database where one column stores a date originating from this code: Indate = FormatDateTime(date(),vbgeneraldate) I then want...
    5. Data Access Problem when importing custom file
      Hi, I have an aspx file that creates a custom class object and calls a method which should return a DataSet. It throws a: Description: The...
  3. #2

    Default Re: PhP, Access/SQL, Data comparison problem. (I'm new to PhP)

    > So a fairly simple problem but its been giving me a headache for the
    > better part of three weeks. Now() in PhP returns the Unix datatime, I
    > believe, which is of course not immediately compatible for comparison
    > with the date-time returned by Access which is of this form:
    >
    > 2004-08-27 00:00:00
    >
    > I dont really mind how this problem is solved - weather by SELECTing
    > from the database WHERE overdue < now(), or by doing the same thing
    > using PhPs date() function.
    Never used access with SQL but all that should be required is for you to do
    a select using a where clause and changing the format of the now().

    In mySQL there is a date function that does it and I assume Access has the
    same.

    An example SQL for mySQL might be

    SELECT date FROM date_table WHERE date < DATE_FORMAT(NOW(), '%Y-%m-%d
    %H:%i:%s')

    the above query is not checked and probably wont work in access but gives
    you an idea of how it may be achieved


    peter Guest

  4. #3

    Default Re: PhP, Access/SQL, Data comparison problem. (I'm new to PhP)

    On Sat, 28 Aug 2004 21:23:06 +0100, "peter" <atsp76@dsl.pipex.com>
    wrote:
    >> So a fairly simple problem but its been giving me a headache for the
    >> better part of three weeks. Now() in PhP returns the Unix datatime, I
    >> believe, which is of course not immediately compatible for comparison
    >> with the date-time returned by Access which is of this form:
    >>
    >> 2004-08-27 00:00:00
    >>
    >> I dont really mind how this problem is solved - weather by SELECTing
    >> from the database WHERE overdue < now(), or by doing the same thing
    >> using PhPs date() function.
    >
    >Never used access with SQL but all that should be required is for you to do
    >a select using a where clause and changing the format of the now().
    >
    >In mySQL there is a date function that does it and I assume Access has the
    >same.
    >
    >An example SQL for mySQL might be
    >
    >SELECT date FROM date_table WHERE date < DATE_FORMAT(NOW(), '%Y-%m-%d
    >%H:%i:%s')
    >
    >the above query is not checked and probably wont work in access but gives
    >you an idea of how it may be achieved
    >
    Use date() function...

    $now = date("Y-m-d H:i:s");
    $query = "SELECT * FROM borrowed_movies WHERE duedate < '$now' "

    GoL Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139