php-general Digest 29 Oct 2006 11:17:03 -0000 Issue 4428

Topics (messages 243807 through 243824):

Re: heredoc usage [WAS: <OPTION]
        243807 by: Robert Cummings

Re: <OPTION
        243808 by: Jochem Maas
        243809 by: Robert Cummings

Re: A general UL script
        243810 by: Ed Lazor
        243815 by: Myron Turner
        243824 by: Børge Holen

Re: Query question
        243811 by: Ed Lazor
        243812 by: Joe Wollard
        243813 by: Beauford
        243814 by: Joe Wollard
        243816 by: Beauford
        243818 by: Robert Cummings
        243819 by: Satyam
        243821 by: Beauford
        243823 by: Satyam

Re: Upload not finding directory to write to.
        243817 by: Jochem Maas

forms usage in web pages
        243820 by: Karthi S
        243822 by: Robert Cummings

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [email protected]


----------------------------------------------------------------------
--- Begin Message ---
On Sat, 2006-10-28 at 13:27 +0200, Nisse Engström wrote:
> On Thu, 26 Oct 2006 13:10:17 -0400, Robert Cummings wrote:
> 
> > On Thu, 2006-10-26 at 11:43 +0200, clive wrote:
> >> or you could write it likes this '
> >>     echo "<option value='$day' $selected > $day </option>";
> >> 
> >> much easier to read, but slightly more taxing on the server.
> > 
> > Also slightly more taxing on standards since single quotes are bad :)
> 
>    As far as I can tell, single and double quotes
> are interchangeable (but unmixable) in both HTML
> and XHTML. When did single quotes go bad?

Hmmm, I've been under the impression for quite some time that single
quotes are somehow inferior to double quotes, but having just checked
through both the XHTML and XML standard I couldn't find anything that
supports that stance :/

Cheers,
Rob.
-- 
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for       |
| creating re-usable components quickly and easily.          |
`------------------------------------------------------------'

--- End Message ---
--- Begin Message ---
Robert Cummings wrote:
> On Fri, 2006-10-27 at 13:51 +0200, Jochem Maas wrote:
>>>>>> range(1, 31)
>>>>> Memory waster ;)
>>>> any idea as to what the damage is as compared to the classic for loop?
>>> Given that a variable probably costs X and that any variable cane be
>>> stored as Y in an array, and an array would cost Z where the Z = X * Y _
>>> 1 (Y element + 1 for the array container itself).
>>>
>>> Then the range format would cost 31 + 1 (the array itself + 31 entries)
>>> whereas the for loop would cost 1 + 1 (cost to store i + cost to store
>>> endpoint comparison. Thus the damage is about 15*. Given general
>>> computer science consideration, this is a constant and thus practically
>>> neglible.
>>>
>>> Cheers
>>> Rob (ps. the above may be completely incoherent since I'm completely
>>> drunk atm after celebrating two friends birthdays tonight).
>> not a bad explainantion then ;-) it's only the last bit I didn't quite 
>> follow :-)
> 
> *heheh* It makes sense to me, though my head still hurts from last
> night :)
> 
> Which part exactly did you not quite follow?

this bit:

Given general computer science consideration, this is a constant and thus 
practically
neglible.

> 
> Cheers,
> Rob.

--- End Message ---
--- Begin Message ---
On Sun, 2006-10-29 at 01:32 +0200, Jochem Maas wrote:
> Robert Cummings wrote:
> > On Fri, 2006-10-27 at 13:51 +0200, Jochem Maas wrote:
> >>>>>> range(1, 31)
> >>>>> Memory waster ;)
> >>>> any idea as to what the damage is as compared to the classic for loop?
> >>> Given that a variable probably costs X and that any variable cane be
> >>> stored as Y in an array, and an array would cost Z where the Z = X * Y _
> >>> 1 (Y element + 1 for the array container itself).
> >>>
> >>> Then the range format would cost 31 + 1 (the array itself + 31 entries)
> >>> whereas the for loop would cost 1 + 1 (cost to store i + cost to store
> >>> endpoint comparison. Thus the damage is about 15*. Given general
> >>> computer science consideration, this is a constant and thus practically
> >>> neglible.
> >>>
> >>> Cheers
> >>> Rob (ps. the above may be completely incoherent since I'm completely
> >>> drunk atm after celebrating two friends birthdays tonight).
> >> not a bad explainantion then ;-) it's only the last bit I didn't quite 
> >> follow :-)
> > 
> > *heheh* It makes sense to me, though my head still hurts from last
> > night :)
> > 
> > Which part exactly did you not quite follow?
> 
> this bit:
> 
> Given general computer science consideration, this is a constant and thus 
> practically
> neglible.

In computer science it's common to profile an algorithm using "Big Oh"
notation. In "Big Oh" notation you have:

    O( Cn ) = O( n )

Where C is a constant multiplier.

Cheers,
Rob.
-- 
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for       |
| creating re-usable components quickly and easily.          |
`------------------------------------------------------------'

--- End Message ---
--- Begin Message --- You posted this earlier and people, myself included, responded. I don't know why you're reposting your original message rather than reply to what we went. If you're not happy with the answers we provided, please rephrase your question in order that have more luck in answering it.


On Oct 28, 2006, at 1:16 PM, Børge Holen wrote:

When I use a normal single file upload form; both of these statements will
continue wether my form is empty or not, why?

if(!empty($_FILES)){
        do som checking if its a jpg.
        if not exit;

if(isset($_FILES)){

--
---
Børge
Kennel Arivene
http://www.arivene.net
---

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


--- End Message ---
--- Begin Message ---
Try this:

  if(!isset($_FILES['userfile']['name'])
                || $_FILES['userfile']['error'] == UPLOAD_ERR_NO_FILE) {
     // the file was not uploaded
  }
  else {
     // do your thing,the file has been uploaded
  }

Børge Holen wrote:
When I use a normal single file upload form; both of these statements will continue wether my form is empty or not, why?

if(!empty($_FILES)){
        do som checking if its a jpg.
        if not exit;

if(isset($_FILES)){



--

_____________________
Myron Turner
http://www.room535.org
http://www.bstatzero.org
http://www.mturner.org/XML_PullParser/

--- End Message ---
--- Begin Message ---
No, I did not post my orginal message. I posted my continuos work with 
solutions I found myself.

However, I recieve two of every message posted to this list. CC or not.

On Sunday 29 October 2006 03:18, Ed Lazor wrote:
> You posted this earlier and people, myself included, responded.  I
> don't know why you're reposting your original message rather than
> reply to what we went.  If  you're not happy with the answers we
> provided, please rephrase your question in order that have more luck
> in answering it.
>
> On Oct 28, 2006, at 1:16 PM, Børge Holen wrote:
> > When I use a normal single file upload form; both of these
> > statements will
> > continue wether my form is empty or not, why?
> >
> > if(!empty($_FILES)){
> >     do som checking if its a jpg.
> >     if not exit;
> >
> > if(isset($_FILES)){
> >
> > --
> > ---
> > Børge
> > Kennel Arivene
> > http://www.arivene.net
> > ---
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php

-- 
---
Børge
Kennel Arivene 
http://www.arivene.net
---

--- End Message ---
--- Begin Message ---
Use the mysql list :)


On Oct 28, 2006, at 3:01 PM, Beauford wrote:

Hi,

I have a MySQL database with a date field and a bunch of other fields. The date field is in the format - 01/01/2006. What I want to do is query the database and create a table that shows just the year and how many instances of the year there is. I have been taxing my brain for a simple solution, but
just not getting it. Any suggestions?

Thanks

Example output.

Year    Count

2002    5
2003    8
2004    9
2005    15
2006    22

ps - I get this information sent to me and I can't change any of the data. I
just enter it in the db and then hopefully do the query on it.



--- End Message ---
--- Begin Message ---
Agreed, this should go to a MySQL list. But in the spirit of helping I think
the following should give you a good starting point.

SELECT `year`, COUNT(`year`) AS `count` FROM `tbl` GROUP BY `year` ASC


On 10/28/06, Ed Lazor <[EMAIL PROTECTED]> wrote:

Use the mysql list :)


On Oct 28, 2006, at 3:01 PM, Beauford wrote:

> Hi,
>
> I have a MySQL database with a date field and a bunch of other
> fields. The
> date field is in the format - 01/01/2006. What I want to do is
> query the
> database and create a table that shows just the year and how many
> instances
> of the year there is. I have been taxing my brain for a simple
> solution, but
> just not getting it. Any suggestions?
>
> Thanks
>
> Example output.
>
> Year  Count
>
> 2002  5
> 2003  8
> 2004  9
> 2005  15
> 2006  22
>
> ps - I get this information sent to me and I can't change any of
> the data. I
> just enter it in the db and then hopefully do the query on it.
>
>

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



--- End Message ---
--- Begin Message ---
I posted this here as I figured I would need to manipulate this using PHP.
The code below doesn't quite work because the date is in the format of
05/05/2006. So I am getting totals for each date, not each year. I need the
totals for each year, regardless of the day or month. This is why I figured
I'd need to use PHP to maybe put it in an array first or something. 

Thanks

-----Original Message-----
From: Joe Wollard [mailto:[EMAIL PROTECTED] 
Sent: October 28, 2006 10:30 PM
To: Ed Lazor
Cc: Beauford; PHP
Subject: Re: [PHP] Query question

Agreed, this should go to a MySQL list. But in the spirit of helping I think
the following should give you a good starting point.

SELECT `year`, COUNT(`year`) AS `count` FROM `tbl` GROUP BY `year` ASC


On 10/28/06, Ed Lazor <[EMAIL PROTECTED]> wrote:
>
> Use the mysql list :)
>
>
> On Oct 28, 2006, at 3:01 PM, Beauford wrote:
>
> > Hi,
> >
> > I have a MySQL database with a date field and a bunch of other 
> > fields. The date field is in the format - 01/01/2006. What I want to 
> > do is query the database and create a table that shows just the year 
> > and how many instances of the year there is. I have been taxing my 
> > brain for a simple solution, but just not getting it. Any 
> > suggestions?
> >
> > Thanks
> >
> > Example output.
> >
> > Year  Count
> >
> > 2002  5
> > 2003  8
> > 2004  9
> > 2005  15
> > 2006  22
> >
> > ps - I get this information sent to me and I can't change any of the 
> > data. I just enter it in the db and then hopefully do the query on 
> > it.
> >
> >
>
> --
> PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: 
> http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
Look into the MySQL YEAR() function to extract the year from a specific
date.
Start here:
http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html




On 10/28/06, Beauford <[EMAIL PROTECTED]> wrote:

I posted this here as I figured I would need to manipulate this using PHP.
The code below doesn't quite work because the date is in the format of
05/05/2006. So I am getting totals for each date, not each year. I need
the
totals for each year, regardless of the day or month. This is why I
figured
I'd need to use PHP to maybe put it in an array first or something.

Thanks

-----Original Message-----
From: Joe Wollard [mailto:[EMAIL PROTECTED]
Sent: October 28, 2006 10:30 PM
To: Ed Lazor
Cc: Beauford; PHP
Subject: Re: [PHP] Query question

Agreed, this should go to a MySQL list. But in the spirit of helping I
think
the following should give you a good starting point.

SELECT `year`, COUNT(`year`) AS `count` FROM `tbl` GROUP BY `year` ASC


On 10/28/06, Ed Lazor <[EMAIL PROTECTED]> wrote:
>
> Use the mysql list :)
>
>
> On Oct 28, 2006, at 3:01 PM, Beauford wrote:
>
> > Hi,
> >
> > I have a MySQL database with a date field and a bunch of other
> > fields. The date field is in the format - 01/01/2006. What I want to
> > do is query the database and create a table that shows just the year
> > and how many instances of the year there is. I have been taxing my
> > brain for a simple solution, but just not getting it. Any
> > suggestions?
> >
> > Thanks
> >
> > Example output.
> >
> > Year  Count
> >
> > 2002  5
> > 2003  8
> > 2004  9
> > 2005  15
> > 2006  22
> >
> > ps - I get this information sent to me and I can't change any of the
> > data. I just enter it in the db and then hopefully do the query on
> > it.
> >
> >
>
> --
> PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:
> http://www.php.net/unsub.php
>
>

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



--- End Message ---
--- Begin Message ---
This is what I finally figured out, which works just perfectly.

select count(date) as count, substring(date,8) as year from stats group by
year;

Thanks to all for the input.

-----Original Message-----
From: Joe Wollard [mailto:[EMAIL PROTECTED] 
Sent: October 29, 2006 12:15 AM
To: Beauford
Cc: PHP
Subject: Re: [PHP] Query question

Look into the MySQL YEAR() function to extract the year from a specific
date.
Start here:
http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html




On 10/28/06, Beauford <[EMAIL PROTECTED]> wrote:
>
> I posted this here as I figured I would need to manipulate this using PHP.
> The code below doesn't quite work because the date is in the format of 
> 05/05/2006. So I am getting totals for each date, not each year. I 
> need the totals for each year, regardless of the day or month. This is 
> why I figured I'd need to use PHP to maybe put it in an array first or 
> something.
>
> Thanks
>
> -----Original Message-----
> From: Joe Wollard [mailto:[EMAIL PROTECTED]
> Sent: October 28, 2006 10:30 PM
> To: Ed Lazor
> Cc: Beauford; PHP
> Subject: Re: [PHP] Query question
>
> Agreed, this should go to a MySQL list. But in the spirit of helping I 
> think the following should give you a good starting point.
>
> SELECT `year`, COUNT(`year`) AS `count` FROM `tbl` GROUP BY `year` ASC
>
>
> On 10/28/06, Ed Lazor <[EMAIL PROTECTED]> wrote:
> >
> > Use the mysql list :)
> >
> >
> > On Oct 28, 2006, at 3:01 PM, Beauford wrote:
> >
> > > Hi,
> > >
> > > I have a MySQL database with a date field and a bunch of other 
> > > fields. The date field is in the format - 01/01/2006. What I want 
> > > to do is query the database and create a table that shows just the 
> > > year and how many instances of the year there is. I have been 
> > > taxing my brain for a simple solution, but just not getting it. 
> > > Any suggestions?
> > >
> > > Thanks
> > >
> > > Example output.
> > >
> > > Year  Count
> > >
> > > 2002  5
> > > 2003  8
> > > 2004  9
> > > 2005  15
> > > 2006  22
> > >
> > > ps - I get this information sent to me and I can't change any of 
> > > the data. I just enter it in the db and then hopefully do the 
> > > query on it.
> > >
> > >
> >
> > --
> > PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:
> > http://www.php.net/unsub.php
> >
> >
>
> --
> PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: 
> http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
On Sun, 2006-10-29 at 01:05 -0500, Beauford wrote:
> This is what I finally figured out, which works just perfectly.
> 
> select count(date) as count, substring(date,8) as year from stats group by
> year;
> 
> Thanks to all for the input.

So what you're saying is that you're not using a date field, you're
using some kind of string concoction where the year information happens
to start at the 8th character? Now that gets me wondering what kind of
freaky date format you've used :) I mean I could naturally see the 5th
or 7th character being the start point for the year using the following
formats respectively:

    ddmmyyyy

    dd/mm/yyyy

But you're grabbing from the 8th character onwards which just seems
wierd.

Cheers,
Rob.
-- 
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for       |
| creating re-usable components quickly and easily.          |
`------------------------------------------------------------'

--- End Message ---
--- Begin Message --- If that works then you have a problem: you are storing dates as a plain string ( varchar or whatever) instead of a native date/time datatype, which precludes the use of a large number of native SQL date/time functions, such as year() which should suit you nicely in this case. Eventually, you will bump into something more elaborate which you won't be able to do on the SQL side just with string functions and that will force you to bring whole tables into PHP to do more extensive processing.

Satyam

----- Original Message ----- From: "Beauford" <[EMAIL PROTECTED]>
To: "'PHP'" <[email protected]>
Sent: Sunday, October 29, 2006 7:05 AM
Subject: RE: [PHP] Query question


This is what I finally figured out, which works just perfectly.

select count(date) as count, substring(date,8) as year from stats group by
year;

Thanks to all for the input.

-----Original Message-----
From: Joe Wollard [mailto:[EMAIL PROTECTED]
Sent: October 29, 2006 12:15 AM
To: Beauford
Cc: PHP
Subject: Re: [PHP] Query question

Look into the MySQL YEAR() function to extract the year from a specific
date.
Start here:
http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html




On 10/28/06, Beauford <[EMAIL PROTECTED]> wrote:

I posted this here as I figured I would need to manipulate this using PHP.
The code below doesn't quite work because the date is in the format of
05/05/2006. So I am getting totals for each date, not each year. I
need the totals for each year, regardless of the day or month. This is
why I figured I'd need to use PHP to maybe put it in an array first or
something.

Thanks

-----Original Message-----
From: Joe Wollard [mailto:[EMAIL PROTECTED]
Sent: October 28, 2006 10:30 PM
To: Ed Lazor
Cc: Beauford; PHP
Subject: Re: [PHP] Query question

Agreed, this should go to a MySQL list. But in the spirit of helping I
think the following should give you a good starting point.

SELECT `year`, COUNT(`year`) AS `count` FROM `tbl` GROUP BY `year` ASC


On 10/28/06, Ed Lazor <[EMAIL PROTECTED]> wrote:
>
> Use the mysql list :)
>
>
> On Oct 28, 2006, at 3:01 PM, Beauford wrote:
>
> > Hi,
> >
> > I have a MySQL database with a date field and a bunch of other
> > fields. The date field is in the format - 01/01/2006. What I want
> > to do is query the database and create a table that shows just the
> > year and how many instances of the year there is. I have been
> > taxing my brain for a simple solution, but just not getting it.
> > Any suggestions?
> >
> > Thanks
> >
> > Example output.
> >
> > Year  Count
> >
> > 2002  5
> > 2003  8
> > 2004  9
> > 2005  15
> > 2006  22
> >
> > ps - I get this information sent to me and I can't change any of
> > the data. I just enter it in the db and then hopefully do the
> > query on it.
> >
> >
>
> --
> PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:
> http://www.php.net/unsub.php
>
>

--
PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:
http://www.php.net/unsub.php



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




--- End Message ---
--- Begin Message ---
This is how I get the data and I have no control over the actual layout of
the database. So I have to work with what I have. 

Robert:

LOL, I don't know either. The format is - 01/01/2006. When I first did it I
used 7, which should be right, but I ended up getting /2002 /2003, etc. So I
went to 8 and all was well. Beats me.....


B

-----Original Message-----
From: Satyam [mailto:[EMAIL PROTECTED] 
Sent: October 29, 2006 2:14 AM
To: Beauford; 'PHP'
Subject: Re: [PHP] Query question

If that works then you have a problem:  you are storing dates as a plain
string ( varchar or whatever) instead of a native date/time datatype, which
precludes the use of a large number of native SQL date/time functions, such
as year() which should suit you nicely in this case.  Eventually, you will
bump into something more elaborate which you won't be able to do on the SQL
side just with string functions and that will force you to bring whole
tables into PHP to do more extensive processing.

Satyam

----- Original Message -----
From: "Beauford" <[EMAIL PROTECTED]>
To: "'PHP'" <[email protected]>
Sent: Sunday, October 29, 2006 7:05 AM
Subject: RE: [PHP] Query question


> This is what I finally figured out, which works just perfectly.
>
> select count(date) as count, substring(date,8) as year from stats group by
> year;
>
> Thanks to all for the input.
>
> -----Original Message-----
> From: Joe Wollard [mailto:[EMAIL PROTECTED]
> Sent: October 29, 2006 12:15 AM
> To: Beauford
> Cc: PHP
> Subject: Re: [PHP] Query question
>
> Look into the MySQL YEAR() function to extract the year from a specific
> date.
> Start here:
> http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html
>
>
>
>
> On 10/28/06, Beauford <[EMAIL PROTECTED]> wrote:
>>
>> I posted this here as I figured I would need to manipulate this using 
>> PHP.
>> The code below doesn't quite work because the date is in the format of
>> 05/05/2006. So I am getting totals for each date, not each year. I
>> need the totals for each year, regardless of the day or month. This is
>> why I figured I'd need to use PHP to maybe put it in an array first or
>> something.
>>
>> Thanks
>>
>> -----Original Message-----
>> From: Joe Wollard [mailto:[EMAIL PROTECTED]
>> Sent: October 28, 2006 10:30 PM
>> To: Ed Lazor
>> Cc: Beauford; PHP
>> Subject: Re: [PHP] Query question
>>
>> Agreed, this should go to a MySQL list. But in the spirit of helping I
>> think the following should give you a good starting point.
>>
>> SELECT `year`, COUNT(`year`) AS `count` FROM `tbl` GROUP BY `year` ASC
>>
>>
>> On 10/28/06, Ed Lazor <[EMAIL PROTECTED]> wrote:
>> >
>> > Use the mysql list :)
>> >
>> >
>> > On Oct 28, 2006, at 3:01 PM, Beauford wrote:
>> >
>> > > Hi,
>> > >
>> > > I have a MySQL database with a date field and a bunch of other
>> > > fields. The date field is in the format - 01/01/2006. What I want
>> > > to do is query the database and create a table that shows just the
>> > > year and how many instances of the year there is. I have been
>> > > taxing my brain for a simple solution, but just not getting it.
>> > > Any suggestions?
>> > >
>> > > Thanks
>> > >
>> > > Example output.
>> > >
>> > > Year  Count
>> > >
>> > > 2002  5
>> > > 2003  8
>> > > 2004  9
>> > > 2005  15
>> > > 2006  22
>> > >
>> > > ps - I get this information sent to me and I can't change any of
>> > > the data. I just enter it in the db and then hopefully do the
>> > > query on it.
>> > >
>> > >
>> >
>> > --
>> > PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:
>> > http://www.php.net/unsub.php
>> >
>> >
>>
>> --
>> PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:
>> http://www.php.net/unsub.php
>>
>>
>
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

--- End Message ---
--- Begin Message --- I said that you have a problem,not that you caused it, and my observation might (hopefully) help newbies in the list.

Satyam


----- Original Message ----- From: "Beauford" <[EMAIL PROTECTED]>
To: "'PHP'" <[email protected]>
Sent: Sunday, October 29, 2006 9:06 AM
Subject: RE: [PHP] Query question


This is how I get the data and I have no control over the actual layout of
the database. So I have to work with what I have.

Robert:

LOL, I don't know either. The format is - 01/01/2006. When I first did it I used 7, which should be right, but I ended up getting /2002 /2003, etc. So I
went to 8 and all was well. Beats me.....


B

-----Original Message-----
From: Satyam [mailto:[EMAIL PROTECTED]
Sent: October 29, 2006 2:14 AM
To: Beauford; 'PHP'
Subject: Re: [PHP] Query question

If that works then you have a problem:  you are storing dates as a plain
string ( varchar or whatever) instead of a native date/time datatype, which precludes the use of a large number of native SQL date/time functions, such
as year() which should suit you nicely in this case.  Eventually, you will
bump into something more elaborate which you won't be able to do on the SQL
side just with string functions and that will force you to bring whole
tables into PHP to do more extensive processing.

Satyam

----- Original Message -----
From: "Beauford" <[EMAIL PROTECTED]>
To: "'PHP'" <[email protected]>
Sent: Sunday, October 29, 2006 7:05 AM
Subject: RE: [PHP] Query question


This is what I finally figured out, which works just perfectly.

select count(date) as count, substring(date,8) as year from stats group by
year;

Thanks to all for the input.

-----Original Message-----
From: Joe Wollard [mailto:[EMAIL PROTECTED]
Sent: October 29, 2006 12:15 AM
To: Beauford
Cc: PHP
Subject: Re: [PHP] Query question

Look into the MySQL YEAR() function to extract the year from a specific
date.
Start here:
http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html




On 10/28/06, Beauford <[EMAIL PROTECTED]> wrote:

I posted this here as I figured I would need to manipulate this using
PHP.
The code below doesn't quite work because the date is in the format of
05/05/2006. So I am getting totals for each date, not each year. I
need the totals for each year, regardless of the day or month. This is
why I figured I'd need to use PHP to maybe put it in an array first or
something.

Thanks

-----Original Message-----
From: Joe Wollard [mailto:[EMAIL PROTECTED]
Sent: October 28, 2006 10:30 PM
To: Ed Lazor
Cc: Beauford; PHP
Subject: Re: [PHP] Query question

Agreed, this should go to a MySQL list. But in the spirit of helping I
think the following should give you a good starting point.

SELECT `year`, COUNT(`year`) AS `count` FROM `tbl` GROUP BY `year` ASC


On 10/28/06, Ed Lazor <[EMAIL PROTECTED]> wrote:
>
> Use the mysql list :)
>
>
> On Oct 28, 2006, at 3:01 PM, Beauford wrote:
>
> > Hi,
> >
> > I have a MySQL database with a date field and a bunch of other
> > fields. The date field is in the format - 01/01/2006. What I want
> > to do is query the database and create a table that shows just the
> > year and how many instances of the year there is. I have been
> > taxing my brain for a simple solution, but just not getting it.
> > Any suggestions?
> >
> > Thanks
> >
> > Example output.
> >
> > Year  Count
> >
> > 2002  5
> > 2003  8
> > 2004  9
> > 2005  15
> > 2006  22
> >
> > ps - I get this information sent to me and I can't change any of
> > the data. I just enter it in the db and then hopefully do the
> > query on it.
> >
> >
>
> --
> PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:
> http://www.php.net/unsub.php
>
>

--
PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:
http://www.php.net/unsub.php



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



--- End Message ---
--- Begin Message ---
Robert Cummings wrote:
> On Sat, 2006-10-28 at 14:49 +0900, Dave M G wrote:
>> PHP List,
>>
>> I had a file upload script which was working fine. Then, because of 
>> other needs, I changed my local Apache settings so that my local web 
>> site directory structure behaved the same as they do on my web hosting 
>> service.
>>
>> What I mean by that is that before, I would access my local web sites by 
>> going to their directories within the localhost (/var/www) directory:
>>
>> localhost/web_sites/web_site_one/index.php
>>
>> Now I just go to:
>>
>> web_site_one/
>>
>> If i create a link that says <a href="/">link</a>, it goes to the root 
>> of the web site, where the index.php is.
>>
>> Within that root directory, I have a directory called "image", where I'm 
>> trying to put my uploaded image files.
>>
>> The destination file location should then be "/image/", shouldn't it?
>>
>> My code looks like this:
>>
>> $fileLocation = "/image/" . $_POST['name'];
>> if(move_uploaded_file($_FILES['file']['tmp_name'], $fileLocation))
>> {
>> chmod ($fileLocation, 0777);
>> }
>>
>> $_POST['name'] is a name for the file that the user has entered.
>>
>> But this now gives me an error that it can't open a stream to the 
>> destination.
>>
>> I also checked to make sure that the "image" directory has fully open 
>> permissions, and it's currently set to "drwxrwxrwx", or "0777".
>>
>> Am I missing some fundamental issue with directory structures on an 
>> Apache server?
> 
> 
> Shouldn't you have something closer to:
> 
> <?php
> 
>     $fileLocation = '/var/www/web_site_one/image/'.$_POST['name'];
> 
> ?>
> 
> Because your trying to access a filesystem path and not a web path. More
> generically if you want:
> 
> <?php
> 
>     $myPath = ereg_replace( '/.*$', '', __FILE__ );
>     $fileLocation = $myPath.'/image/'.$_POST['name'];

and at the very least lets perform a dirname on the name var...

$yourfile = dirname($_POST['name']);

in order to avoid security issues related to directory traversal.

:-)

> 
> ?>
> 
> That still presumes a script in the site's root directory.
> 
> Cheers,
> Rob.

--- End Message ---
--- Begin Message ---
hi,

i am newbie to web programming. i have a basic doubt in using forms.

Is it advisable to use multiple forms performing various functions in a
single web page.
what are the pros and cons of using that.

Please forgive me if this is not the right mailing list to post this
question. But help me out in clarifying this basic doubt.

thanks in advance

Karthi

--- End Message ---
--- Begin Message ---
On Sun, 2006-10-29 at 13:15 +0530, Karthi S wrote:
> hi,
> 
> i am newbie to web programming. i have a basic doubt in using forms.
> 
> Is it advisable to use multiple forms performing various functions in a
> single web page.
> what are the pros and cons of using that.
> 
> Please forgive me if this is not the right mailing list to post this
> question. But help me out in clarifying this basic doubt.
> 
> thanks in advance

As long as the purpose is clear then I don't think you will have a
problem with multiple forms on a single web page. For instance, it's
quite common to see a search form on every page regardless of what other
forms might be present.

Cheers,
Rob.
-- 
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for       |
| creating re-usable components quickly and easily.          |
`------------------------------------------------------------'

--- End Message ---

Reply via email to