Re: [PHP-DB] PHP query on date field

2001-10-31 Thread Jason

Thanks alot... right now I cannot really work on it but I am going to setup
a test table to work with so I make sure I get the correct results on the
test before I impliment it on our main tables. Thanks again, all of you guys
on this newsgroup have been a great help to a newbie like myself. =)
Jason

Jason Wong [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]...
 On Wednesday 31 October 2001 05:11 am, Jason wrote:
  The date field is varchar. And I believe it is for daylight savings.
  I am trying out a couple of things on a test date field so I will get
  back with you guys after I try your suggestions. And by the way I
  sincerely appriciate all the help you and Rick are giving me. Thanks
  again,

 In that case your original:

date like '%$date%'

 should work as long as $date is formatted the same as what is stored in
 the db.

 Really, you should convert your date field into DATE or DATETIME then
 you can use all the nifty date/time functions that MySQL provides!

 regards
 --
 Jason Wong
 Gremlins Associates
 www.gremlins.com.hk



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] PHP query on date field

2001-10-30 Thread Jason

Here is my problem once again... =P I am wondering if I should change the
date table to something other than date... maybe something like date_1?
Would doing that resolve my issue, because of the fact that the date
variable in php is function? Thanks in advance...
Jason

/* Form to supply variables */
form name=auth method=post action=http://path/to/search.php;
  pSearch for Ads/p
  First name:
  input type=text name=fname
  br
  Last name:
  input type=text name=lname
  br
  Area Code:nbsp;
  input type=text name=phonea size=3
maxlength=3
  Phone:
  input type=text name=phone size=8
maxlength=8
  br
  Date:
  input type=text name=date
  br
  p
input type=submit name=login
value=Submit
input type=reset name=reset value=Reset
  /p
/form

Once user clicks submit button it links to this php script to connect, query
and display results... eveything works fine except for the date variables.
If anyone with a little more know how can point me out the error I would
greatly appriciate it.

/* php script to connect, query and display results */
?php

mysql_connect (db_host, db_username, db_password) or die(Couldn't
connect!);

mysql_select_db (db_name) or die(Couldn't select database);

if ($fname == )
{$fname = '%';}
if ($lname == )
{$lname = '%';}
if (phonea == )
{$phonea = '%';}
if ($phone == )
{$phone = '%';}
if ($date == )
{$date = '%';}

$result = mysql_query (SELECT * FROM ads
 WHERE fname LIKE '%$fname%' AND lname LIKE
'%$lname%' AND phonea LIKE '%$phonea%' AND phone LIKE '%$phone%' AND date
LIKE '%$date%');

if ($row = mysql_fetch_array($result)) {

do {
  PRINT Your search results: brbr;
  PRINT bFirst Name: /b ;
  print $row[fname];
  print (br);
  PRINT bLast Name: /b ;
  print $row[lname];
  print (br);
  PRINT bAddress: /b ;
  print $row[address];
  print (br);
  PRINT bCity: /b ;
  print $row[city];
  print (br);
  PRINT bState: /b ;
  print $row[state];
  print (br);
  PRINT bZip: /b ;
  print $row[zip];
  print (br);
  PRINT bArea Code: /b ;
  print $row[phonea];
  print (br);
  PRINT bPhone: /b ;
  print $row[phone];
  print (br);
  PRINT bEmail: /b ;
  print $row[email];
  print (br);
  PRINT bWeeks: /b ;
  print $row[weeks];
  print (br);
  PRINT bCity 1: /b ;
  print $row[cty1];
  print (br);
  PRINT bCity 2: /b ;
  print $row[cty2];
  print (br);
  PRINT bCity 3: /b ;
  print $row[cty3];
  print (br);
  PRINT bAd: /b ;
  print $row[ad];
  print (br);
  PRINT bTotal: /b ;
  print $row[total];
  print (br);
  PRINT bNumber of weeks: /b ;
  print $row[num];
  print (br);
  PRINT bDate: /b ;
  print $row[date];
  print (br);
  PRINT bTime: /b ;
  print $row[time];
  print (br);
  print (hr);
} while($row = mysql_fetch_array($result));
} else {print Sorry, no records were found!;}

?



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] PHP query on date field

2001-10-30 Thread Bruno Gimenes Pereti

Hi Jason,

What is the error message, in what line? I really can't find any error...
Just one standarlization point: why do you use ( ) when printing BR and
not in every other printing. For me, it's easyer to debug if every thing
that do the same thing is writen the same way.
Other thing out of the point. You could write all the line in one print
command:

print bTotal:/b $row['total']br;
or
print bTotal:/b . $row[total] .br;
or (my favorite)
?
bTotal/b ? print $row[total]; ?br;
?

Please send the error message, O got curios.. (sorry I don't remember how to
write it, I think I can understand what I mean :-)

Bruno Gimenes Pereti.

- Original Message -
From: Jason [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, October 30, 2001 3:31 PM
Subject: [PHP-DB] PHP query on date field


 Here is my problem once again... =P I am wondering if I should change the
 date table to something other than date... maybe something like date_1?
 Would doing that resolve my issue, because of the fact that the date
 variable in php is function? Thanks in advance...
 Jason


[snip]


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] PHP query on date field

2001-10-30 Thread Bruno Gimenes Pereti

What I use to do is to print the sql and try it in the command line to know
it I'm constructing it correctly.

$sql = select foo from bar...;
print $sqlbr\n;  ## add this line

execute your script and copy the line to the mysql command line. If the
result is what you expect it should be working.

{Hope this helps} else {tell us}.

Bruno Gimenes Pereti.

- Original Message -
From: Big Nickel [EMAIL PROTECTED]
To: Bruno Gimenes Pereti [EMAIL PROTECTED]
Sent: Tuesday, October 30, 2001 4:02 PM
Subject: Re: [PHP-DB] PHP query on date field


 I apologize... there really isn't any error messages.. it just shows that
 there are no results to be displayed but when i telnet into the db there
are
 plenty of dates that met my search criteria. I just need to know why it
wont
 display the results... and I am thinking that because in php the date
 function is the same thing i am using for a variable... not sure if that
is
 the problem but i am open to suggestions on it. Thanks again.


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP-DB] PHP query on date field

2001-10-30 Thread Rick Emery

First, I agree with Bruno concerning putting print all on one line, as you
and I discussed previously Jason.

Second, keep using DATE data type in mySQL.  Simply specify to the user how
the date is to be entered on the form.  DATE is maintained in mySQL as
-MM-DD.
User that

-Original Message-
From: Bruno Gimenes Pereti [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, October 30, 2001 11:42 AM
To: PHP-DB
Subject: Re: [PHP-DB] PHP query on date field


Hi Jason,

What is the error message, in what line? I really can't find any error...
Just one standarlization point: why do you use ( ) when printing BR and
not in every other printing. For me, it's easyer to debug if every thing
that do the same thing is writen the same way.
Other thing out of the point. You could write all the line in one print
command:

print bTotal:/b $row['total']br;
or
print bTotal:/b . $row[total] .br;
or (my favorite)
?
bTotal/b ? print $row[total]; ?br;
?

Please send the error message, O got curios.. (sorry I don't remember how to
write it, I think I can understand what I mean :-)

Bruno Gimenes Pereti.

- Original Message -
From: Jason [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, October 30, 2001 3:31 PM
Subject: [PHP-DB] PHP query on date field


 Here is my problem once again... =P I am wondering if I should change the
 date table to something other than date... maybe something like date_1?
 Would doing that resolve my issue, because of the fact that the date
 variable in php is function? Thanks in advance...
 Jason


[snip]


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] PHP query on date field

2001-10-30 Thread Jason Wong

On Wednesday 31 October 2001 01:31 am, Jason wrote:

 Here is my problem once again... =P I am wondering if I should change
 the date table to something other than date... maybe something like
 date_1? Would doing that resolve my issue, because of the fact that
 the date variable in php is function? Thanks in advance...

What is the format of date as defined in your database? If date is of 
type DATE or DATETIME then 

 $result = mysql_query (SELECT * FROM ads
  WHERE fname LIKE '%$fname%' AND lname LIKE
 '%$lname%' AND phonea LIKE '%$phonea%' AND phone LIKE '%$phone%' AND
 date LIKE '%$date%');

should be changed to:

   $result = mysql_query (SELECT * FROM ads
   WHERE fname LIKE '%$fname%' 
 AND lname LIKE '%$lname%' 
 AND phonea LIKE '%$phonea%' 
 AND phone LIKE '%$phone%' 
 AND date = '$date'
 );
hth
-- 
Jason Wong
Gremlins Associates
www.gremlins.com.hk

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] PHP query on date field

2001-10-30 Thread biorn

Isn't date a reserved word that should not be used as a field name?  It 
appeared that what was asked was if he should change the name of his field 
from date to date_1.  It should definitely be changed if it is now called 
date.


Jason Wong [EMAIL PROTECTED] said:

 On Wednesday 31 October 2001 01:31 am, Jason wrote:
 
  Here is my problem once again... =P I am wondering if I should change
  the date table to something other than date... maybe something like
  date_1? Would doing that resolve my issue, because of the fact that
  the date variable in php is function? Thanks in advance...
 
 What is the format of date as defined in your database? If date is of 
 type DATE or DATETIME then 
 
  $result = mysql_query (SELECT * FROM ads
   WHERE fname LIKE '%$fname%' AND lname LIKE
  '%$lname%' AND phonea LIKE '%$phonea%' AND phone LIKE '%$phone%' AND
  date LIKE '%$date%');
 
 should be changed to:
 
$result = mysql_query (SELECT * FROM ads
WHERE fname LIKE '%$fname%' 
  AND lname LIKE '%$lname%' 
  AND phonea LIKE '%$phonea%' 
  AND phone LIKE '%$phone%' 
  AND date = '$date'
  );
 hth
 -- 
 Jason Wong
 Gremlins Associates
 www.gremlins.com.hk
 
 -- 
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]
 



-- 




-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] PHP query on date field

2001-10-30 Thread Jason Wong

On Wednesday 31 October 2001 02:57 am, [EMAIL PROTECTED] wrote:

 Isn't date a reserved word that should not be used as a field name? 
 It appeared that what was asked was if he should change the name of
 his field from date to date_1.  It should definitely be changed if it
 is now called date.

According to the docs, date is *not* a reserved word in MySQL, so he 
should be OK.

-- 
Jason Wong
Gremlins Associates
www.gremlins.com.hk

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] PHP query on date field

2001-10-30 Thread Bruno Gimenes Pereti

Hi again Jason,

I think Jason Wong got the problem I missed, it's the date format. If you
tested like I sad in the last mail you already found it. When you query:

SELECT * FROM ads WHERE date = '%$date%';

you get an empty result.

So, that's the solution...

Bruno Gimenes Pereti.

 What is the format of date as defined in your database? If date is of
 type DATE or DATETIME then

  $result = mysql_query (SELECT * FROM ads
   WHERE fname LIKE '%$fname%' AND lname LIKE
  '%$lname%' AND phonea LIKE '%$phonea%' AND phone LIKE '%$phone%' AND
  date LIKE '%$date%');

 should be changed to:

$result = mysql_query (SELECT * FROM ads
WHERE fname LIKE '%$fname%'
  AND lname LIKE '%$lname%'
  AND phonea LIKE '%$phonea%'
  AND phone LIKE '%$phone%'
  AND date = '$date'
  );


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] PHP query on date field

2001-10-30 Thread Jason

Ok well I have made the changes and tested it out but using the search
string 10/15/2001 still provided no results... here is the script that
parses the date for entry into the database...
$date =  (date(m/d/Y)) ; #this date is used in the online database

$A = (date(A));

$Hou = (date(H));
if ($Hou == 00){
$Hou = 10;
$format = PM;
}
if ($Hou == 01){
$Hou = 11;
$format = PM;
}
if ($Hou == 02){
$Hou = 12;
$format = AM;
}
if ($Hou == 03){
$Hou = 01;
$format = AM;
}
if ($Hou == 04){
$Hou = 02;
$format = AM;
}
if ($Hou == 05){
$Hou = 03;
$format = AM;
}
if ($Hou == 06){
$Hou = 04;
$format = AM;
}
if ($Hou == 07){
$Hou = 05;
$format = AM;
}
if ($Hou == 08){
$Hou = 06;
$format = AM;
}
if ($Hou == 09){
$Hou = 07;
$format = AM;
}
if ($Hou == 10){
$Hou = 08;
$format = AM;
}
if ($Hou == 11){
$Hou = 09;
$format = AM;
}
if ($Hou == 12){
$Hou = 10;
$format = AM;
}
if ($Hou == 13){
$Hou = 11;
$format = AM;
}
if ($Hou == 14){
$Hou = 12;
$format = PM;
}
if ($Hou == 15){
$Hou = 01;
$format = PM;
}
if ($Hou == 16){
$Hou = 02;
$format = PM;
}
if ($Hou == 17){
$Hou = 03;
$format = PM;
}
if ($Hou == 18){
$Hou = 04;
$format = PM;
}
if ($Hou == 19){
$Hou = 05;
$format = PM;
}
if ($Hou == 20){
$Hou = 06;
$format = PM;
}
if ($Hou == 21){
$Hou = 07;
$format = PM;
}
if ($Hou == 22){
$Hou = 08;
$format = PM;
}
if ($Hou == 23){
$Hou = 09;
$format = PM;
}
I am wondering if I should let the date be put into the db as 2001-15-10...

[EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Isn't date a reserved word that should not be used as a field name?  It
 appeared that what was asked was if he should change the name of his field
 from date to date_1.  It should definitely be changed if it is now called
 date.


 Jason Wong [EMAIL PROTECTED] said:

  On Wednesday 31 October 2001 01:31 am, Jason wrote:
 
   Here is my problem once again... =P I am wondering if I should change
   the date table to something other than date... maybe something like
   date_1? Would doing that resolve my issue, because of the fact that
   the date variable in php is function? Thanks in advance...
 
  What is the format of date as defined in your database? If date is of
  type DATE or DATETIME then
 
   $result = mysql_query (SELECT * FROM ads
WHERE fname LIKE '%$fname%' AND lname LIKE
   '%$lname%' AND phonea LIKE '%$phonea%' AND phone LIKE '%$phone%' AND
   date LIKE '%$date%');
 
  should be changed to:
 
 $result = mysql_query (SELECT * FROM ads
 WHERE fname LIKE '%$fname%'
   AND lname LIKE '%$lname%'
   AND phonea LIKE '%$phonea%'
   AND phone LIKE '%$phone%'
   AND date = '$date'
   );
  hth
  --
  Jason Wong
  Gremlins Associates
  www.gremlins.com.hk
 
  --
  PHP Database Mailing List (http://www.php.net/)
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
  To contact the list administrators, e-mail: [EMAIL PROTECTED]
 



 --






-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP-DB] PHP query on date field

2001-10-30 Thread Rick Emery

Jason,

date(H) converts to a 24-hour clock.  That is, 00 is 12 mid-night, 01 is 1
AM, 13 is 1 PM, 14 is 2 PM, 23 is 11 PM, etc.

I do not understand the reasons for your computation that, say 00, is 10 PM.

-Original Message-
From: Jason [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, October 30, 2001 2:20 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP-DB] PHP query on date field


Ok well I have made the changes and tested it out but using the search
string 10/15/2001 still provided no results... here is the script that
parses the date for entry into the database...
$date =  (date(m/d/Y)) ; #this date is used in the online database

$A = (date(A));

$Hou = (date(H));
if ($Hou == 00){
$Hou = 10;
$format = PM;
}
if ($Hou == 01){
$Hou = 11;
$format = PM;
}
if ($Hou == 02){
$Hou = 12;
$format = AM;
}
if ($Hou == 03){
$Hou = 01;
$format = AM;
}
if ($Hou == 04){
$Hou = 02;
$format = AM;
}
if ($Hou == 05){
$Hou = 03;
$format = AM;
}
if ($Hou == 06){
$Hou = 04;
$format = AM;
}
if ($Hou == 07){
$Hou = 05;
$format = AM;
}
if ($Hou == 08){
$Hou = 06;
$format = AM;
}
if ($Hou == 09){
$Hou = 07;
$format = AM;
}
if ($Hou == 10){
$Hou = 08;
$format = AM;
}
if ($Hou == 11){
$Hou = 09;
$format = AM;
}
if ($Hou == 12){
$Hou = 10;
$format = AM;
}
if ($Hou == 13){
$Hou = 11;
$format = AM;
}
if ($Hou == 14){
$Hou = 12;
$format = PM;
}
if ($Hou == 15){
$Hou = 01;
$format = PM;
}
if ($Hou == 16){
$Hou = 02;
$format = PM;
}
if ($Hou == 17){
$Hou = 03;
$format = PM;
}
if ($Hou == 18){
$Hou = 04;
$format = PM;
}
if ($Hou == 19){
$Hou = 05;
$format = PM;
}
if ($Hou == 20){
$Hou = 06;
$format = PM;
}
if ($Hou == 21){
$Hou = 07;
$format = PM;
}
if ($Hou == 22){
$Hou = 08;
$format = PM;
}
if ($Hou == 23){
$Hou = 09;
$format = PM;
}
I am wondering if I should let the date be put into the db as 2001-15-10...

[EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Isn't date a reserved word that should not be used as a field name?  It
 appeared that what was asked was if he should change the name of his field
 from date to date_1.  It should definitely be changed if it is now called
 date.


 Jason Wong [EMAIL PROTECTED] said:

  On Wednesday 31 October 2001 01:31 am, Jason wrote:
 
   Here is my problem once again... =P I am wondering if I should change
   the date table to something other than date... maybe something like
   date_1? Would doing that resolve my issue, because of the fact that
   the date variable in php is function? Thanks in advance...
 
  What is the format of date as defined in your database? If date is of
  type DATE or DATETIME then
 
   $result = mysql_query (SELECT * FROM ads
WHERE fname LIKE '%$fname%' AND lname LIKE
   '%$lname%' AND phonea LIKE '%$phonea%' AND phone LIKE '%$phone%' AND
   date LIKE '%$date%');
 
  should be changed to:
 
 $result = mysql_query (SELECT * FROM ads
 WHERE fname LIKE '%$fname%'
   AND lname LIKE '%$lname%'
   AND phonea LIKE '%$phonea%'
   AND phone LIKE '%$phone%'
   AND date = '$date'
   );
  hth
  --
  Jason Wong
  Gremlins Associates
  www.gremlins.com.hk
 
  --
  PHP Database Mailing List (http://www.php.net/)
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
  To contact the list administrators, e-mail: [EMAIL PROTECTED]
 



 --






-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] PHP query on date field

2001-10-30 Thread Jason

Rick,
This portion of the site was done by a previous employee and well you
know the expression.. If its not broke don't fix it. Well now that I
cannot query the db by the date it is now broke and I am still figuring out
how MySQL is taking entries to the db so I figured this bit of information
would maybe sum up the problem in the date field.  I have been reading up on
the date function in the MySQL book I have but somethings it just doesn't
cover. So please excuse my being vague. Thanks,
Jason
Rick Emery [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Jason,

 date(H) converts to a 24-hour clock.  That is, 00 is 12 mid-night, 01 is
1
 AM, 13 is 1 PM, 14 is 2 PM, 23 is 11 PM, etc.

 I do not understand the reasons for your computation that, say 00, is 10
PM.

 -Original Message-
 From: Jason [mailto:[EMAIL PROTECTED]]
 Sent: Tuesday, October 30, 2001 2:20 PM
 To: [EMAIL PROTECTED]
 Subject: Re: [PHP-DB] PHP query on date field


 Ok well I have made the changes and tested it out but using the search
 string 10/15/2001 still provided no results... here is the script that
 parses the date for entry into the database...
 $date =  (date(m/d/Y)) ; #this date is used in the online database

 $A = (date(A));

 $Hou = (date(H));
 if ($Hou == 00){
 $Hou = 10;
 $format = PM;
 }
 if ($Hou == 01){
 $Hou = 11;
 $format = PM;
 }
 if ($Hou == 02){
 $Hou = 12;
 $format = AM;
 }
 if ($Hou == 03){
 $Hou = 01;
 $format = AM;
 }
 if ($Hou == 04){
 $Hou = 02;
 $format = AM;
 }
 if ($Hou == 05){
 $Hou = 03;
 $format = AM;
 }
 if ($Hou == 06){
 $Hou = 04;
 $format = AM;
 }
 if ($Hou == 07){
 $Hou = 05;
 $format = AM;
 }
 if ($Hou == 08){
 $Hou = 06;
 $format = AM;
 }
 if ($Hou == 09){
 $Hou = 07;
 $format = AM;
 }
 if ($Hou == 10){
 $Hou = 08;
 $format = AM;
 }
 if ($Hou == 11){
 $Hou = 09;
 $format = AM;
 }
 if ($Hou == 12){
 $Hou = 10;
 $format = AM;
 }
 if ($Hou == 13){
 $Hou = 11;
 $format = AM;
 }
 if ($Hou == 14){
 $Hou = 12;
 $format = PM;
 }
 if ($Hou == 15){
 $Hou = 01;
 $format = PM;
 }
 if ($Hou == 16){
 $Hou = 02;
 $format = PM;
 }
 if ($Hou == 17){
 $Hou = 03;
 $format = PM;
 }
 if ($Hou == 18){
 $Hou = 04;
 $format = PM;
 }
 if ($Hou == 19){
 $Hou = 05;
 $format = PM;
 }
 if ($Hou == 20){
 $Hou = 06;
 $format = PM;
 }
 if ($Hou == 21){
 $Hou = 07;
 $format = PM;
 }
 if ($Hou == 22){
 $Hou = 08;
 $format = PM;
 }
 if ($Hou == 23){
 $Hou = 09;
 $format = PM;
 }
 I am wondering if I should let the date be put into the db as
2001-15-10...

 [EMAIL PROTECTED] wrote in message
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
  Isn't date a reserved word that should not be used as a field name?  It
  appeared that what was asked was if he should change the name of his
field
  from date to date_1.  It should definitely be changed if it is now
called
  date.
 
 
  Jason Wong [EMAIL PROTECTED] said:
 
   On Wednesday 31 October 2001 01:31 am, Jason wrote:
  
Here is my problem once again... =P I am wondering if I should
change
the date table to something other than date... maybe something like
date_1? Would doing that resolve my issue, because of the fact that
the date variable in php is function? Thanks in advance...
  
   What is the format of date as defined in your database? If date is of
   type DATE or DATETIME then
  
$result = mysql_query (SELECT * FROM ads
 WHERE fname LIKE '%$fname%' AND lname LIKE
'%$lname%' AND phonea LIKE '%$phonea%' AND phone LIKE '%$phone%' AND
date LIKE '%$date%');
  
   should be changed to:
  
  $result = mysql_query (SELECT * FROM ads
  WHERE fname LIKE '%$fname%'
AND lname LIKE '%$lname%'
AND phonea LIKE '%$phonea%'
AND phone LIKE '%$phone%'
AND date = '$date'
);
   hth
   --
   Jason Wong
   Gremlins Associates
   www.gremlins.com.hk
  
   --
   PHP Database Mailing List (http://www.php.net/)
   To unsubscribe, e-mail: [EMAIL PROTECTED]
   For additional commands, e-mail: [EMAIL PROTECTED]
   To contact the list administrators, e-mail:
[EMAIL PROTECTED]
  
 
 
 
  --
 
 
 



 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]





-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] PHP query on date field

2001-10-30 Thread Jason

Just to clear some things up... so instead of the long winded bit of code
that was previously setup to change the format of the date for the date
field in the db, I should use the 2 lines of code? Definately skeptical on
this one... but you know more about this than I.

Rick Emery [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Assuming you correct the hours calculation per my previous email, then:

 $format = ($Hou12?) PM : AM ;
 $Hou -= ($Hou12?) 12 : 0;

 And you can do away with all the constructs.

 -Original Message-
 From: Rick Emery
 Sent: Tuesday, October 30, 2001 2:09 PM
 To: 'Jason'; [EMAIL PROTECTED]
 Subject: RE: [PHP-DB] PHP query on date field


 Jason,

 date(H) converts to a 24-hour clock.  That is, 00 is 12 mid-night, 01 is
1
 AM, 13 is 1 PM, 14 is 2 PM, 23 is 11 PM, etc.

 I do not understand the reasons for your computation that, say 00, is 10
PM.

 -Original Message-
 From: Jason [mailto:[EMAIL PROTECTED]]
 Sent: Tuesday, October 30, 2001 2:20 PM
 To: [EMAIL PROTECTED]
 Subject: Re: [PHP-DB] PHP query on date field


 Ok well I have made the changes and tested it out but using the search
 string 10/15/2001 still provided no results... here is the script that
 parses the date for entry into the database...
 $date =  (date(m/d/Y)) ; #this date is used in the online database

 $A = (date(A));

 $Hou = (date(H));
 if ($Hou == 00){
 $Hou = 10;
 $format = PM;
 }
 if ($Hou == 01){
 $Hou = 11;
 $format = PM;
 }
 if ($Hou == 02){
 $Hou = 12;
 $format = AM;
 }
 if ($Hou == 03){
 $Hou = 01;
 $format = AM;
 }
 if ($Hou == 04){
 $Hou = 02;
 $format = AM;
 }
 if ($Hou == 05){
 $Hou = 03;
 $format = AM;
 }
 if ($Hou == 06){
 $Hou = 04;
 $format = AM;
 }
 if ($Hou == 07){
 $Hou = 05;
 $format = AM;
 }
 if ($Hou == 08){
 $Hou = 06;
 $format = AM;
 }
 if ($Hou == 09){
 $Hou = 07;
 $format = AM;
 }
 if ($Hou == 10){
 $Hou = 08;
 $format = AM;
 }
 if ($Hou == 11){
 $Hou = 09;
 $format = AM;
 }
 if ($Hou == 12){
 $Hou = 10;
 $format = AM;
 }
 if ($Hou == 13){
 $Hou = 11;
 $format = AM;
 }
 if ($Hou == 14){
 $Hou = 12;
 $format = PM;
 }
 if ($Hou == 15){
 $Hou = 01;
 $format = PM;
 }
 if ($Hou == 16){
 $Hou = 02;
 $format = PM;
 }
 if ($Hou == 17){
 $Hou = 03;
 $format = PM;
 }
 if ($Hou == 18){
 $Hou = 04;
 $format = PM;
 }
 if ($Hou == 19){
 $Hou = 05;
 $format = PM;
 }
 if ($Hou == 20){
 $Hou = 06;
 $format = PM;
 }
 if ($Hou == 21){
 $Hou = 07;
 $format = PM;
 }
 if ($Hou == 22){
 $Hou = 08;
 $format = PM;
 }
 if ($Hou == 23){
 $Hou = 09;
 $format = PM;
 }
 I am wondering if I should let the date be put into the db as
2001-15-10...

 [EMAIL PROTECTED] wrote in message
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
  Isn't date a reserved word that should not be used as a field name?  It
  appeared that what was asked was if he should change the name of his
field
  from date to date_1.  It should definitely be changed if it is now
called
  date.
 
 
  Jason Wong [EMAIL PROTECTED] said:
 
   On Wednesday 31 October 2001 01:31 am, Jason wrote:
  
Here is my problem once again... =P I am wondering if I should
change
the date table to something other than date... maybe something like
date_1? Would doing that resolve my issue, because of the fact that
the date variable in php is function? Thanks in advance...
  
   What is the format of date as defined in your database? If date is of
   type DATE or DATETIME then
  
$result = mysql_query (SELECT * FROM ads
 WHERE fname LIKE '%$fname%' AND lname LIKE
'%$lname%' AND phonea LIKE '%$phonea%' AND phone LIKE '%$phone%' AND
date LIKE '%$date%');
  
   should be changed to:
  
  $result = mysql_query (SELECT * FROM ads
  WHERE fname LIKE '%$fname%'
AND lname LIKE '%$lname%'
AND phonea LIKE '%$phonea%'
AND phone LIKE '%$phone%'
AND date = '$date'
);
   hth
   --
   Jason Wong
   Gremlins Associates
   www.gremlins.com.hk
  
   --
   PHP Database Mailing List (http://www.php.net/)
   To unsubscribe, e-mail: [EMAIL PROTECTED]
   For additional commands, e-mail: [EMAIL PROTECTED]
   To contact the list administrators, e-mail:
[EMAIL PROTECTED]
  
 
 
 
  --
 
 
 



 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]





-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP-DB] PHP query on date field

2001-10-30 Thread Rick Emery

This is what I'm saying...

I encourage you to try it and experiment.

-Original Message-
From: Jason [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, October 30, 2001 2:51 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP-DB] PHP query on date field


Just to clear some things up... so instead of the long winded bit of code
that was previously setup to change the format of the date for the date
field in the db, I should use the 2 lines of code? Definately skeptical on
this one... but you know more about this than I.

Rick Emery [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Assuming you correct the hours calculation per my previous email, then:

 $format = ($Hou12?) PM : AM ;
 $Hou -= ($Hou12?) 12 : 0;

 And you can do away with all the constructs.

 -Original Message-
 From: Rick Emery
 Sent: Tuesday, October 30, 2001 2:09 PM
 To: 'Jason'; [EMAIL PROTECTED]
 Subject: RE: [PHP-DB] PHP query on date field


 Jason,

 date(H) converts to a 24-hour clock.  That is, 00 is 12 mid-night, 01 is
1
 AM, 13 is 1 PM, 14 is 2 PM, 23 is 11 PM, etc.

 I do not understand the reasons for your computation that, say 00, is 10
PM.

 -Original Message-
 From: Jason [mailto:[EMAIL PROTECTED]]
 Sent: Tuesday, October 30, 2001 2:20 PM
 To: [EMAIL PROTECTED]
 Subject: Re: [PHP-DB] PHP query on date field


 Ok well I have made the changes and tested it out but using the search
 string 10/15/2001 still provided no results... here is the script that
 parses the date for entry into the database...
 $date =  (date(m/d/Y)) ; #this date is used in the online database

 $A = (date(A));

 $Hou = (date(H));
 if ($Hou == 00){
 $Hou = 10;
 $format = PM;
 }
 if ($Hou == 01){
 $Hou = 11;
 $format = PM;
 }
 if ($Hou == 02){
 $Hou = 12;
 $format = AM;
 }
 if ($Hou == 03){
 $Hou = 01;
 $format = AM;
 }
 if ($Hou == 04){
 $Hou = 02;
 $format = AM;
 }
 if ($Hou == 05){
 $Hou = 03;
 $format = AM;
 }
 if ($Hou == 06){
 $Hou = 04;
 $format = AM;
 }
 if ($Hou == 07){
 $Hou = 05;
 $format = AM;
 }
 if ($Hou == 08){
 $Hou = 06;
 $format = AM;
 }
 if ($Hou == 09){
 $Hou = 07;
 $format = AM;
 }
 if ($Hou == 10){
 $Hou = 08;
 $format = AM;
 }
 if ($Hou == 11){
 $Hou = 09;
 $format = AM;
 }
 if ($Hou == 12){
 $Hou = 10;
 $format = AM;
 }
 if ($Hou == 13){
 $Hou = 11;
 $format = AM;
 }
 if ($Hou == 14){
 $Hou = 12;
 $format = PM;
 }
 if ($Hou == 15){
 $Hou = 01;
 $format = PM;
 }
 if ($Hou == 16){
 $Hou = 02;
 $format = PM;
 }
 if ($Hou == 17){
 $Hou = 03;
 $format = PM;
 }
 if ($Hou == 18){
 $Hou = 04;
 $format = PM;
 }
 if ($Hou == 19){
 $Hou = 05;
 $format = PM;
 }
 if ($Hou == 20){
 $Hou = 06;
 $format = PM;
 }
 if ($Hou == 21){
 $Hou = 07;
 $format = PM;
 }
 if ($Hou == 22){
 $Hou = 08;
 $format = PM;
 }
 if ($Hou == 23){
 $Hou = 09;
 $format = PM;
 }
 I am wondering if I should let the date be put into the db as
2001-15-10...

 [EMAIL PROTECTED] wrote in message
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
  Isn't date a reserved word that should not be used as a field name?  It
  appeared that what was asked was if he should change the name of his
field
  from date to date_1.  It should definitely be changed if it is now
called
  date.
 
 
  Jason Wong [EMAIL PROTECTED] said:
 
   On Wednesday 31 October 2001 01:31 am, Jason wrote:
  
Here is my problem once again... =P I am wondering if I should
change
the date table to something other than date... maybe something like
date_1? Would doing that resolve my issue, because of the fact that
the date variable in php is function? Thanks in advance...
  
   What is the format of date as defined in your database? If date is of
   type DATE or DATETIME then
  
$result = mysql_query (SELECT * FROM ads
 WHERE fname LIKE '%$fname%' AND lname LIKE
'%$lname%' AND phonea LIKE '%$phonea%' AND phone LIKE '%$phone%' AND
date LIKE '%$date%');
  
   should be changed to:
  
  $result = mysql_query (SELECT * FROM ads
  WHERE fname LIKE '%$fname%'
AND lname LIKE '%$lname%'
AND phonea LIKE '%$phonea%'
AND phone LIKE '%$phone%'
AND date = '$date'
);
   hth
   --
   Jason Wong
   Gremlins Associates
   www.gremlins.com.hk
  
   --
   PHP Database Mailing List (http://www.php.net/)
   To unsubscribe, e-mail: [EMAIL PROTECTED]
   For additional commands, e-mail: [EMAIL PROTECTED]
   To contact the list administrators, e-mail:
[EMAIL PROTECTED]
  
 
 
 
  --
 
 
 



 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]





-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To 

Re: [PHP-DB] PHP query on date field

2001-10-30 Thread Jason Wong

On Wednesday 31 October 2001 04:34 am, Jason wrote:

 This portion of the site was done by a previous employee and well
 you know the expression.. If its not broke don't fix it. Well now
 that I cannot query the db by the date it is now broke and I am still
 figuring out how MySQL is taking entries to the db so I figured this
 bit of information would maybe sum up the problem in the date field. 
 I have been reading up on the date function in the MySQL book I have
 but somethings it just doesn't cover. So please excuse my being
 vague. Thanks,
 Jason

What data type is your date field -- CHAR? INT? DATE?


  date(H) converts to a 24-hour clock.  That is, 00 is 12
  mid-night, 01 is

 1

  AM, 13 is 1 PM, 14 is 2 PM, 23 is 11 PM, etc.
 
  I do not understand the reasons for your computation that, say 00,
  is 10

A stab in the dark -- could it be some time-zone adjustment?

  Ok well I have made the changes and tested it out but using the
  search string 10/15/2001 still provided no results... 

The changes would only work if your date field is of data type DATE (or 
DATETIME).

  here is the
  script that parses the date for entry into the database...
  $date =  (date(m/d/Y)) ; #this date is used in the online
  database
  I am wondering if I should let the date be put into the db as

 2001-15-10...

Changing the format of your dates to standard DATE or DATETIME *would* 
be a sensible thing to do :)


-- 
Jason Wong
Gremlins Associates
www.gremlins.com.hk

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] PHP query on date field

2001-10-30 Thread Jason

The date field is varchar. And I believe it is for daylight savings. I am
trying out a couple of things on a test date field so I will get back with
you guys after I try your suggestions. And by the way I sincerely appriciate
all the help you and Rick are giving me. Thanks again,
jason
Jason Wong [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]...
 On Wednesday 31 October 2001 04:34 am, Jason wrote:

  This portion of the site was done by a previous employee and well
  you know the expression.. If its not broke don't fix it. Well now
  that I cannot query the db by the date it is now broke and I am still
  figuring out how MySQL is taking entries to the db so I figured this
  bit of information would maybe sum up the problem in the date field.
  I have been reading up on the date function in the MySQL book I have
  but somethings it just doesn't cover. So please excuse my being
  vague. Thanks,
  Jason

 What data type is your date field -- CHAR? INT? DATE?


   date(H) converts to a 24-hour clock.  That is, 00 is 12
   mid-night, 01 is
 
  1
 
   AM, 13 is 1 PM, 14 is 2 PM, 23 is 11 PM, etc.
  
   I do not understand the reasons for your computation that, say 00,
   is 10

 A stab in the dark -- could it be some time-zone adjustment?

   Ok well I have made the changes and tested it out but using the
   search string 10/15/2001 still provided no results...

 The changes would only work if your date field is of data type DATE (or
 DATETIME).

   here is the
   script that parses the date for entry into the database...
   $date =  (date(m/d/Y)) ; #this date is used in the online
   database
   I am wondering if I should let the date be put into the db as
 
  2001-15-10...

 Changing the format of your dates to standard DATE or DATETIME *would*
 be a sensible thing to do :)


 --
 Jason Wong
 Gremlins Associates
 www.gremlins.com.hk



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] PHP query on date field

2001-10-30 Thread Jason Wong

On Wednesday 31 October 2001 05:11 am, Jason wrote:
 The date field is varchar. And I believe it is for daylight savings.
 I am trying out a couple of things on a test date field so I will get
 back with you guys after I try your suggestions. And by the way I
 sincerely appriciate all the help you and Rick are giving me. Thanks
 again,

In that case your original:

   date like '%$date%'

should work as long as $date is formatted the same as what is stored in 
the db.

Really, you should convert your date field into DATE or DATETIME then 
you can use all the nifty date/time functions that MySQL provides!

regards
-- 
Jason Wong
Gremlins Associates
www.gremlins.com.hk

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]