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

2006-10-29 Thread php-general-digest-help

php-general Digest 29 Oct 2006 11:17:03 - 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:
php-general@lists.php.net


--
---BeginMessage---
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---
---BeginMessage---
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---
---BeginMessage---
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

RE: [PHP] Query question

2006-10-29 Thread Beauford
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



Re: [PHP] Upload not finding directory to write to.

2006-10-29 Thread Jochem Maas
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.

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



RE: [PHP] Query question

2006-10-29 Thread Robert Cummings
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:

ddmm

dd/mm/

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.  |
`'

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



Re: [PHP] Query question

2006-10-29 Thread Satyam
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' php-general@lists.php.net
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] forms usage in web pages

2006-10-29 Thread Karthi S

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


RE: [PHP] Query question

2006-10-29 Thread Beauford
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' php-general@lists.php.net
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



Re: [PHP] forms usage in web pages

2006-10-29 Thread Robert Cummings
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.  |
`'

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



Re: [PHP] Query question

2006-10-29 Thread Satyam
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' php-general@lists.php.net
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' php-general@lists.php.net
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




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



Re: [PHP] A general UL script

2006-10-29 Thread Børge Holen
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
---

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



RE: [PHP] Query question

2006-10-29 Thread Beauford
I don't see this as a particular problem as the data will always be the
same. Now under other circumstances in another database, I can see what you
are saying.  

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

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' php-general@lists.php.net
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' php-general@lists.php.net
 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

 

-- 
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



Re: [PHP] Query question

2006-10-29 Thread Ed Lazor
You'd still benefit from converting your data into an actual date  
format in order to take full advantage of available features.  hehe  
You guys are going to start thinking of me as a performance freak,  
but I think MySQL's date functions might provide better performance  
than string manipulation.



On Oct 29, 2006, at 6:08 AM, Beauford wrote:

I don't see this as a particular problem as the data will always be  
the
same. Now under other circumstances in another database, I can see  
what you

are saying.

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

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' php-general@lists.php.net
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' php-general@lists.php.net
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




--
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: 

Re: [PHP] Memcached Question

2006-10-29 Thread Michal Manko

Hi,
Best reference will be http://php.net/memcache i think.
Memcache is really effective tool, but it have one fault. Data keeping 
in this way are not stable.
Generally memcache is useful as a some kind of cache when you can have 
second data source, or when data, you want to save, have short ttl (time 
to live) (f.e. sessions ;-) ).

But I recommend it.

Have fun ;)

Michael




Sancar Saran said:

Hi,
Recently I discoverd Memcache daemon for sessions, I'm very pleased its 
performance.


I want to use memcache other than $_SESSION

For example, I have an array, it  has language definitions. Normally on each 
page load I have to include that file. 

So I want to put that array into Memcached and access from each different 
SESSIONID, I believe this will reduce memory usage and gives performance 
boost.


I found (and use) SESSION examples for Memcached usage. Does anyone has any 
other examples for memcached usage.


Regards.

Sancar



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



[PHP] strange problem with count()

2006-10-29 Thread Gunnar Beushausen

Hi!

I've a strange problem with count. I wrote a routine to jump to the last 
position of an array. The code ist this:


if(!$this-done) {
array_push($this-result, $this-stmt-fetchall_assoc());
}
$this-done = true;
$this-currIndex = $this-rowIndex = count($this-result)-1;
return $this;

If i do a print_r($this-result); i'm getting like thousand entries, so 
the array is actually filled with all values needed. But somehow a 
count($this-result) gives me a value of 1.


I wonder why count says there is only 1 entry in that array, when 
print_r gives out more than thousand entries. Does anybody have a clue? 
I'm using php 5.1.6


Thanks in advance,

Gunnar

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



Re: [PHP] strange problem with count()

2006-10-29 Thread Ed Lazor

Side note, it sounds like

$this-result

is an object holding an array, not the array itself and print_r is  
automatically traversing the object.



On Oct 29, 2006, at 4:27 AM, Gunnar Beushausen wrote:


Hi!

I've a strange problem with count. I wrote a routine to jump to the  
last position of an array. The code ist this:


if(!$this-done) {
array_push($this-result, $this-stmt-fetchall_assoc());
}
$this-done = true;
$this-currIndex = $this-rowIndex = count($this-result)-1;
return $this;

If i do a print_r($this-result); i'm getting like thousand  
entries, so the array is actually filled with all values needed.  
But somehow a count($this-result) gives me a value of 1.


I wonder why count says there is only 1 entry in that array, when  
print_r gives out more than thousand entries. Does anybody have a  
clue? I'm using php 5.1.6


Thanks in advance,

Gunnar

--
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



Re: [PHP] heredoc usage [WAS: OPTION]

2006-10-29 Thread Larry Garfield
On Saturday 28 October 2006 18:15, Robert Cummings wrote:

 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.

I've been using single quoted (X)HTML attributes for some time now without 
trouble.  The only catch is when you're dynamically building a DOM 1 
attribute like onclick, as the Javascript inside will almost invariably have 
a quotation mark in there somewhere, which by convention is single-quoted and 
the HTML double quoted.  Of course, you should be using DOM 2 event handlers 
anyway, but that's beside the point... :-)

It surprised me, too, when I realized single quotes were kosher (X)HTML, but 
it can be quite convenient.

-- 
Larry Garfield  AIM: LOLG42
[EMAIL PROTECTED]   ICQ: 6817012

If nature has made any one thing less susceptible than all others of 
exclusive property, it is the action of the thinking power called an idea, 
which an individual may exclusively possess as long as he keeps it to 
himself; but the moment it is divulged, it forces itself into the possession 
of every one, and the receiver cannot dispossess himself of it.  -- Thomas 
Jefferson

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



Re: [PHP] forms usage in web pages

2006-10-29 Thread Larry Garfield
There's nothing wrong with multiple forms on a single page, as long as all id 
attributes in all elements are unique on the entire page, not just within the 
form.  Just make sure that each form is self-contained with its own submit 
button and such.  Only the form whose submit button is clicked will get 
submitted by the browser.  

Whether or not you want to use multiple forms for a given set of tasks or 
multiple submit buttons in a single form (which you can then test to see 
which was clicked) will depend on what it is you're doing.  Both are 
perfectly legitimate ways of doing things, depending on what things you're 
doing.

On Sunday 29 October 2006 01:45, 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

 Karthi

-- 
Larry Garfield  AIM: LOLG42
[EMAIL PROTECTED]   ICQ: 6817012

If nature has made any one thing less susceptible than all others of 
exclusive property, it is the action of the thinking power called an idea, 
which an individual may exclusively possess as long as he keeps it to 
himself; but the moment it is divulged, it forces itself into the possession 
of every one, and the receiver cannot dispossess himself of it.  -- Thomas 
Jefferson

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



[PHP] IMAP functions for NNTP

2006-10-29 Thread Eric

How would I go about listing all newsgroups via the IMAP functions?

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



Re: [PHP] Memcached Question

2006-10-29 Thread Sancar Saran
On Sunday 29 October 2006 19:21, Michal Manko wrote:
Thanks, 
And I found APC had shared memory access like this

if(!$_LIVE['_CONF'] = apc_fetch('_LIVE_CONF'))
{
  require('inc/config.inc.php');
  apc_store('_LIVE_CONF',$_LIVE['_CONF']);
}

Regards

Sancar 

 Hi,
 Best reference will be http://php.net/memcache i think.
 Memcache is really effective tool, but it have one fault. Data keeping
 in this way are not stable.
 Generally memcache is useful as a some kind of cache when you can have
 second data source, or when data, you want to save, have short ttl (time
 to live) (f.e. sessions ;-) ).
 But I recommend it.

 Have fun ;)

 Michael

 Sancar Saran said:
  Hi,
  Recently I discoverd Memcache daemon for sessions, I'm very pleased its
  performance.
 
  I want to use memcache other than $_SESSION
 
  For example, I have an array, it  has language definitions. Normally on
  each page load I have to include that file.
 
  So I want to put that array into Memcached and access from each different
  SESSIONID, I believe this will reduce memory usage and gives performance
  boost.
 
  I found (and use) SESSION examples for Memcached usage. Does anyone has
  any other examples for memcached usage.
 
  Regards.
 
  Sancar

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



[PHP] str_replace on words with an array

2006-10-29 Thread Dotan Cohen

I need to remove the noise words from a search string. I can't seem to
get str_replace to go through the array and remove the words, and I'd
rather avoid a redundant foreach it I can. According to TFM
str_replace should automatically go through the whole array, no? Does
anybody see anything wrong with this code:

$noiseArray = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 0,
\, ', :, ;, |, \\, , , ,, ., ?, $, !,
@, #, $, %, ^, , *, (, ), -, _, +, =, [,
], {, }, about, after, all, also, an, and,
another, any, are, as, at, be, because, been,
before, being, between, both, but, by, came, can,
come, could, did, do, does, each, else, for, from,
get, got, has, had, he, have, her, here, him,
himself, his, how, if, in, into, is, it, its,
just, like, make, many, me, might, more, most, much,
must, my, never, now, of, on, only, or, other,
our, out, over, re, said, same, see, should, since,
so, some, still, such, take, than, that, the, their,
them, then, there, these, they, this, those, through,
to, too, under, up, use, very, want, was, way, we,
well, were, what, when, where, which, while, who,
will, with, would, you, your, a, b, c, d, e, f,
g, h, i, j, k, l, m, n, o, p, q, r, s, t,
u, v, w, x, y, z);

$searchQuery=str_replace( ^.$noiseArray.$,  , $searchQuery);

Thanks in advance.

Dotan Cohen

http://essentialinux.com
http://what-is-what.com/what_is/sitepoint.html

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



Re: [PHP] forms usage in web pages

2006-10-29 Thread Ed Lazor

Is anyone else getting multiple copies of posts?


On Oct 29, 2006, at 9:52 AM, Larry Garfield wrote:

There's nothing wrong with multiple forms on a single page, as long  
as all id
attributes in all elements are unique on the entire page, not just  
within the
form.  Just make sure that each form is self-contained with its own  
submit
button and such.  Only the form whose submit button is clicked will  
get

submitted by the browser.

Whether or not you want to use multiple forms for a given set of  
tasks or
multiple submit buttons in a single form (which you can then test  
to see

which was clicked) will depend on what it is you're doing.  Both are
perfectly legitimate ways of doing things, depending on what things  
you're

doing.

On Sunday 29 October 2006 01:45, 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

Karthi


--
Larry Garfield  AIM: LOLG42
[EMAIL PROTECTED]   ICQ: 6817012

If nature has made any one thing less susceptible than all others of
exclusive property, it is the action of the thinking power called  
an idea,

which an individual may exclusively possess as long as he keeps it to
himself; but the moment it is divulged, it forces itself into the  
possession
of every one, and the receiver cannot dispossess himself of it.   
-- Thomas

Jefferson

--
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



Re: [PHP] str_replace on words with an array

2006-10-29 Thread Børge Holen
Yes you need to put some \ in front of some of those characters

On Sunday 29 October 2006 21:05, Dotan Cohen wrote:
 I need to remove the noise words from a search string. I can't seem to
 get str_replace to go through the array and remove the words, and I'd
 rather avoid a redundant foreach it I can. According to TFM
 str_replace should automatically go through the whole array, no? Does
 anybody see anything wrong with this code:

 $noiseArray = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 0,
 \, ', :, ;, |, \\, , , ,, ., ?, $, !,
 @, #, $, %, ^, , *, (, ), -, _, +, =, [,
 ], {, }, about, after, all, also, an, and,
 another, any, are, as, at, be, because, been,
 before, being, between, both, but, by, came, can,
 come, could, did, do, does, each, else, for, from,
 get, got, has, had, he, have, her, here, him,
 himself, his, how, if, in, into, is, it, its,
 just, like, make, many, me, might, more, most, much,
 must, my, never, now, of, on, only, or, other,
 our, out, over, re, said, same, see, should, since,
 so, some, still, such, take, than, that, the, their,
 them, then, there, these, they, this, those, through,
 to, too, under, up, use, very, want, was, way, we,
 well, were, what, when, where, which, while, who,
 will, with, would, you, your, a, b, c, d, e, f,
 g, h, i, j, k, l, m, n, o, p, q, r, s, t,
 u, v, w, x, y, z);

 $searchQuery=str_replace( ^.$noiseArray.$,  , $searchQuery);

 Thanks in advance.

 Dotan Cohen

 http://essentialinux.com
 http://what-is-what.com/what_is/sitepoint.html

-- 
---
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



Re: [PHP] forms usage in web pages

2006-10-29 Thread Børge Holen
yes, but then again, I've already mentioned this, and have seen some posts now 
an then mention the subject...  :)

On Sunday 29 October 2006 21:26, Ed Lazor wrote:
 Is anyone else getting multiple copies of posts?

 On Oct 29, 2006, at 9:52 AM, Larry Garfield wrote:
  There's nothing wrong with multiple forms on a single page, as long
  as all id
  attributes in all elements are unique on the entire page, not just
  within the
  form.  Just make sure that each form is self-contained with its own
  submit
  button and such.  Only the form whose submit button is clicked will
  get
  submitted by the browser.
 
  Whether or not you want to use multiple forms for a given set of
  tasks or
  multiple submit buttons in a single form (which you can then test
  to see
  which was clicked) will depend on what it is you're doing.  Both are
  perfectly legitimate ways of doing things, depending on what things
  you're
  doing.
 
  On Sunday 29 October 2006 01:45, 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
 
  Karthi
 
  --
  Larry Garfield  AIM: LOLG42
  [EMAIL PROTECTED]   ICQ: 6817012
 
  If nature has made any one thing less susceptible than all others of
  exclusive property, it is the action of the thinking power called
  an idea,
  which an individual may exclusively possess as long as he keeps it to
  himself; but the moment it is divulged, it forces itself into the
  possession
  of every one, and the receiver cannot dispossess himself of it.
  -- Thomas
  Jefferson
 
  --
  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
---

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



Re: [PHP] str_replace on words with an array

2006-10-29 Thread Dotan Cohen

On 29/10/06, Alan Milnes [EMAIL PROTECTED] wrote:

Dotan Cohen wrote:
 $searchQuery=str_replace( ^.$noiseArray.$,  , $searchQuery);
Can you explain what you are trying to do with the ^ and $?  What is a
typical value of the original $searchQuery?

Alan



The purpose of the ^ and the $ is to define the beginning and the end of a word:
http://il2.php.net/regex

I also tried str_replace( $noiseArray,  , $searchQuery) but that was
replacing the insides of words as well. And with the addition of the
individual letters, that emptied the entire $searchQuery string!

A typical value of $searchQuery could be What is php? or What is
open source. See this site for details:
http://what-is-what.com

Dotan Cohen

http://technology-sleuth.com/

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



[PHP] Decide witch table within a union

2006-10-29 Thread Børge Holen
Hi.
I got this working (almost)
How do I decide (inside?) the whileloop the table_nr, 1 to 4 witch the link is 
echo'ed from.

I could add another field in each table telling witch table it is. Easy 
solution, but feels like polluting the db.

Also I could do another loop to check another of the printed fields up agains 
witch table is used, but that adding to the slowness of this union stuff, it 
would take forever, if the union in itself is slow or the fact that I'm 
cutting the message field after 100 characters I dunno.

This is anyway the main code wherein the problem lies:

$sql=  (select * from table_1 WHERE pid='0' order by id desc limit 10) union 
(select * from table_2 WHERE pid='0' order by id desc limit 10) 
union 
(select * from table_3 WHERE pid='0' order by id desc limit 10) 
union 
(select * from table_4 WHERE pid='0' order by id desc limit 10) 
order by date desc limit 10 ;

$result = mysql_query($sql) or die('Error, query failed');
while($myrow = mysql_fetch_array($result)){
$id = $myrow[id];
$pid = $myrow[pid];

echo a href=\index.php?table=$table_nrpage/a;
}

-- 
---
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



Re: [PHP] str_replace on words with an array

2006-10-29 Thread Paul Novitski

At 10/29/2006 01:07 PM, Dotan Cohen wrote:
The purpose of the ^ and the $ is to define the beginning and the 
end of a word:

http://il2.php.net/regex



No, actually, ^ and $ define the beginnning  end of the entire 
expression being searched, not the boundaries of a single 
word.  Therefore searching for ^mouse$ will locate mouse only if 
it's the only word in the entire string, which I gather is not what you want.


I suspect what you want is either this:

(^| )WORD( |$)

(the word bounded by either the start/end of string or a space)

or perhaps better yet this:

\bWORD\b

(the word bounded by word boundaries).

See [PCRE regex] Pattern Syntax
http://il2.php.net/manual/en/reference.pcre.pattern.syntax.php



Further to your problem, I believe this is incorrect:

$noiseArray = array(1, ...
...
$searchQuery=str_replace( ^.$noiseArray.$,  , $searchQuery);

Since $noiseArray is your entire array, it doesn't make sense to 
enclose it in word boundaries of any kind.  Instead, I imagine each 
member of the array needs to be bounded individually.


If you go this route, perhaps you could enclose each member of your 
original array in \b word boundary sequences using an array_walk 
routine so that you don't have to muddy your original array 
declaration statement.


Regards,
Paul 


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



Re: [PHP] str_replace on words with an array

2006-10-29 Thread Myron Turner

I never use this function, since I always use regular expressions, but
according to the manual:
 If you don't need fancy replacing rules (like regular
 expressions), you should always use this function instead of
 ereg_replace() or preg_replace().

So, I assume your problem initially was that you were using regular
expression syntax and this function doesn't accept regular expressions.

Is your aim to get rid strings of all the items in the $noiseArray? Your
 $noiseArray includes the entire alpahabet, so it's no wonder that you
end up with empty strings!

Myron

Dotan Cohen wrote:

On 29/10/06, Alan Milnes [EMAIL PROTECTED] wrote:

Dotan Cohen wrote:
 $searchQuery=str_replace( ^.$noiseArray.$,  , $searchQuery);
Can you explain what you are trying to do with the ^ and $?  What is a
typical value of the original $searchQuery?

Alan



The purpose of the ^ and the $ is to define the beginning and the end of 
a word:

http://il2.php.net/regex

I also tried str_replace( $noiseArray,  , $searchQuery) but that was
replacing the insides of words as well. And with the addition of the
individual letters, that emptied the entire $searchQuery string!

A typical value of $searchQuery could be What is php? or What is
open source. See this site for details:
http://what-is-what.com

Dotan Cohen

http://technology-sleuth.com/



--

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

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



Re: [PHP] str_replace on words with an array

2006-10-29 Thread rich gray

Paul Novitski wrote:


If you go this route, perhaps you could enclose each member of your 
original array in \b word boundary sequences using an array_walk 
routine so that you don't have to muddy your original array 
declaration statement.


IIRC str_replace() does not interpret or understand regular expression 
syntax - you'd need preg_replace() for that

rich


Re: [PHP] Decide witch table within a union

2006-10-29 Thread Ed Lazor

PHP can't tell what table the data came from.


On Oct 29, 2006, at 1:34 PM, Børge Holen wrote:


Hi.
I got this working (almost)
How do I decide (inside?) the whileloop the table_nr, 1 to 4 witch  
the link is

echo'ed from.

I could add another field in each table telling witch table it is.  
Easy

solution, but feels like polluting the db.

Also I could do another loop to check another of the printed fields  
up agains
witch table is used, but that adding to the slowness of this union  
stuff, it
would take forever, if the union in itself is slow or the fact that  
I'm

cutting the message field after 100 characters I dunno.

This is anyway the main code wherein the problem lies:

$sql=	(select * from table_1 WHERE pid='0' order by id desc limit  
10) union
		(select * from table_2 WHERE pid='0' order by id desc limit 10)  
union
		(select * from table_3 WHERE pid='0' order by id desc limit 10)  
union

(select * from table_4 WHERE pid='0' order by id desc limit 10)
order by date desc limit 10 ;

$result = mysql_query($sql) or die('Error, query failed');
while($myrow = mysql_fetch_array($result)){
$id = $myrow[id];
$pid = $myrow[pid];

echo a href=\index.php?table=$table_nrpage/a;
}

--
---
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



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



Re: [PHP] Decide witch table within a union

2006-10-29 Thread Børge Holen
Ok.

Would you suggest to use a extra field to hold the table name as default?

On Sunday 29 October 2006 22:59, Ed Lazor wrote:
 PHP can't tell what table the data came from.

 On Oct 29, 2006, at 1:34 PM, Børge Holen wrote:
  Hi.
  I got this working (almost)
  How do I decide (inside?) the whileloop the table_nr, 1 to 4 witch
  the link is
  echo'ed from.
 
  I could add another field in each table telling witch table it is.
  Easy
  solution, but feels like polluting the db.
 
  Also I could do another loop to check another of the printed fields
  up agains
  witch table is used, but that adding to the slowness of this union
  stuff, it
  would take forever, if the union in itself is slow or the fact that
  I'm
  cutting the message field after 100 characters I dunno.
 
  This is anyway the main code wherein the problem lies:
 
  $sql=  (select * from table_1 WHERE pid='0' order by id desc limit
  10) union
  (select * from table_2 WHERE pid='0' order by id desc limit 10)
  union
  (select * from table_3 WHERE pid='0' order by id desc limit 10)
  union
  (select * from table_4 WHERE pid='0' order by id desc limit 10)
  order by date desc limit 10 ;
 
  $result = mysql_query($sql) or die('Error, query failed');
  while($myrow = mysql_fetch_array($result)){
  $id = $myrow[id];
  $pid = $myrow[pid];
 
  echo a href=\index.php?table=$table_nrpage/a;
  }
 
  --
  ---
  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
---

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



Re: [PHP] str_replace on words with an array

2006-10-29 Thread Stut
Dotan Cohen wrote:
 $searchQuery=str_replace( ^.$noiseArray.$,  , $searchQuery);

Ok, this is what the compiler will see...

$searchQuery=str_replace(^Array$,  , $searchQuery);

Yes, that's a literal Array in the string. You cannot, and you should
remember this, you cannot concatenate strings and arrays. What would you
expect it to do?

Now, the answer is this...

$searchQuery = str_replace($noiseArray, ' ', $searchQuery);

However, what you seem to be doing is putting regex syntax where it
would have no effect even if $noiseArray was not an array. If your
intention is to replace the words rather than just the strings then you
need to look at preg_replace (http://php.net/preg_replace) and you'll
need to decorate the strings in $noiseArray with the appropriate
characters to make them the search pattern you need - full details on
the preg_replace manual page.

Hope that made sense.

-Stut

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



Re: [PHP] str_replace on words with an array

2006-10-29 Thread Dotan Cohen

On 29/10/06, Børge Holen [EMAIL PROTECTED] wrote:

Yes you need to put some \ in front of some of those characters

On Sunday 29 October 2006 21:05, Dotan Cohen wrote:
 I need to remove the noise words from a search string. I can't seem to
 get str_replace to go through the array and remove the words, and I'd
 rather avoid a redundant foreach it I can. According to TFM
 str_replace should automatically go through the whole array, no? Does
 anybody see anything wrong with this code:

 $noiseArray = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 0,
 \, ', :, ;, |, \\, , , ,, ., ?, $, !,
 @, #, $, %, ^, , *, (, ), -, _, +, =, [,
 ], {, }, about, after, all, also, an, and,
 another, any, are, as, at, be, because, been,
 before, being, between, both, but, by, came, can,
 come, could, did, do, does, each, else, for, from,
 get, got, has, had, he, have, her, here, him,
 himself, his, how, if, in, into, is, it, its,
 just, like, make, many, me, might, more, most, much,
 must, my, never, now, of, on, only, or, other,
 our, out, over, re, said, same, see, should, since,
 so, some, still, such, take, than, that, the, their,
 them, then, there, these, they, this, those, through,
 to, too, under, up, use, very, want, was, way, we,
 well, were, what, when, where, which, while, who,
 will, with, would, you, your, a, b, c, d, e, f,
 g, h, i, j, k, l, m, n, o, p, q, r, s, t,
 u, v, w, x, y, z);

 $searchQuery=str_replace( ^.$noiseArray.$,  , $searchQuery);

 Thanks in advance.



I improved the $noiseArray to this:

$noiseArray = array([:alnum:], [:punct:], |, \\, , ,
#, @,  \$, %, ^, , *, (, ), -, _, +, =,
[, ], {, }, about, after, all, also, an, and,
another, any, are, as, at, be, because, been,
before, being, between, both, but, by, came, can,
come, could, did, do, does, each, else, for, from,
get, got, has, had, he, have, her, here, him,
himself, his, how, if, in, into, is, it, its,
just, like, make, many, me, might, more, most, much,
must, my, never, now, of, on, only, or, other,
our, out, over, re, said, same, see, should, since,
so, some, still, such, take, than, that, the, their,
them, then, there, these, they, this, those, through,
to, too, under, up, use, very, want, was, way, we,
well, were, what, when, where, which, while, who,
will, with, would, you, your);

Do any of the characters in there need escaping (other than the $
which is already escaped)?

How does on go about looping through the array, matching only whole
words? This didn't quite do it:
$searchQuery=str_replace( ^.$noiseArray.$,  , $searchQuery);

And neither did this:
$searchQuery=str_replace( /^.$noiseArray.$/,  , $searchQuery);

Thanks.

Dotan Cohen
http://dotancohen.com
http://what-is-what.com/what_is/drm.html


Re: [PHP] str_replace on words with an array

2006-10-29 Thread Paul Novitski



Paul Novitski wrote:
If you go this route, perhaps you could enclose each member of your 
original array in \b word boundary sequences using an array_walk 
routine so that you don't have to muddy your original array 
declaration statement.


At 10/29/2006 01:54 PM, rich gray wrote:
IIRC str_replace() does not interpret or understand regular 
expression syntax - you'd need preg_replace() for that



You're absolutely right -- I was focusing so much on the regexp 
syntax that I failed to broaden my gaze...


When the OP corrects his PHP to use preg_replace() instead of 
str_replace(), I believe he'll still need to provide word boundaries 
around each member of his noise-word array, otherwise the function 
will simply remove all letters and digits from the words in the 
search-string he considers meaningful and he'll end up searching thin air.


Aside, without knowing the context of his search, it seems a bit 
extreme to remove all single characters from the search string.  It's 
not hard to think of examples of them occurring as part of valid 
entity names in our universe -- she got an A, Plan B From Outer 
Space, Vitamin C, etc.


An alternative strategy might be to trust the user to enter a valid 
search string and simply warn them that the quality of the answer 
they get will depend on the quality of their input.


Regards,
Paul 


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



Re: [PHP] str_replace on words with an array

2006-10-29 Thread Dotan Cohen

Thanks all for the heads up with the str_replace not working with
regexes. Duh! I've switched to preg_replace, but still no luck. (nor
skill, on my part)

I'm trying to use array_walk to go through the array and deliminate
each item with /b so that the preg_replace function will know to only
operate on whole words, but I just can't seem to get it. I am of
course Ring TFM and Sing THW but with no luck. A push (link to TFA or
tutorial, whatever) would be most appreciated.

Thanks again.

Dotan Cohen
http://what-is-what.com/what_is/love.html

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



Re: [PHP] str_replace on words with an array

2006-10-29 Thread Stut
Dotan Cohen wrote:
 Thanks all for the heads up with the str_replace not working with
 regexes. Duh! I've switched to preg_replace, but still no luck. (nor
 skill, on my part)
 
 I'm trying to use array_walk to go through the array and deliminate
 each item with /b so that the preg_replace function will know to only
 operate on whole words, but I just can't seem to get it. I am of
 course Ring TFM and Sing THW but with no luck. A push (link to TFA or
 tutorial, whatever) would be most appreciated.

IMHO, unless you're going to be doing a lot with each element of the
array it's easier to do it without using array_walk.

foreach ($arr as $key = $val)
$arr[$key] = \\b.$val.\\b;

-Stut

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



Re: [PHP] str_replace on words with an array

2006-10-29 Thread Dotan Cohen

On 30/10/06, Paul Novitski [EMAIL PROTECTED] wrote:

Hi Dotan,

To get help with your problem, share more of your PHP code with the
list so we can look at what you're doing.

Also, give us a link to the PHP script on your server so we can see the output.

Regards,
Paul



Nothing else is relevant, but $searchQuery will get passed to the
database, so it should be protected from SQL injection. That's why I
want to remove characters such as quotes, dashes, and the equals sign.

I set up a test page:
http://what-is-what.com/test.php

with this code:
htmlbody

?php

// FOIL SQL INJECTION AND REMOVE NOISE

$noiseArray = array([:alnum:], [:punct:], |, \\, , ,
#, @,  \$, %, ^, , *, (, ), -, _, +, =,
[, ], {, }, about, after, all, also, an, and,
another, any, are, as, at, be, because, been,
before, being, between, both, but, by, came, can,
come, could, did, do, does, each, else, for, from,
get, got, has, had, he, have, her, here, him,
himself, his, how, if, in, into, is, it, its,
just, like, make, many, me, might, more, most, much,
must, my, never, now, of, on, only, or, other,
our, out, over, re, said, same, see, should, since,
so, some, still, such, take, than, that, the, their,
them, then, there, these, they, this, those, through,
to, too, under, up, use, very, want, was, way, we,
well, were, what, when, where, which, while, who,
will, with, would, you, your);

$searchQuery=preg_replace( /^.$noiseArray.$/,  , $_POST[query]);
$searchQuery=trim($searchQuery);

print p$searchQuery/p;

?

form action=/test.php method=post
  input type=text name=query /
  input type=submit /
/form

/body/html



Dotan Cohen

http://song-lirics.com
http://what-is-what.com/what_is/distribution.html

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



Re: [PHP] str_replace on words with an array

2006-10-29 Thread Ed Lazor

checkout the function mysql_real_escape_string()


On Oct 29, 2006, at 3:13 PM, Dotan Cohen wrote:


On 30/10/06, Paul Novitski [EMAIL PROTECTED] wrote:

Hi Dotan,

To get help with your problem, share more of your PHP code with the
list so we can look at what you're doing.

Also, give us a link to the PHP script on your server so we can  
see the output.


Regards,
Paul



Nothing else is relevant, but $searchQuery will get passed to the
database, so it should be protected from SQL injection. That's why I
want to remove characters such as quotes, dashes, and the equals sign.

I set up a test page:
http://what-is-what.com/test.php

with this code:
htmlbody

?php

// FOIL SQL INJECTION AND REMOVE NOISE

$noiseArray = array([:alnum:], [:punct:], |, \\, , ,
#, @,  \$, %, ^, , *, (, ), -, _, +, =,
[, ], {, }, about, after, all, also, an, and,
another, any, are, as, at, be, because, been,
before, being, between, both, but, by, came, can,
come, could, did, do, does, each, else, for, from,
get, got, has, had, he, have, her, here, him,
himself, his, how, if, in, into, is, it, its,
just, like, make, many, me, might, more, most, much,
must, my, never, now, of, on, only, or, other,
our, out, over, re, said, same, see, should, since,
so, some, still, such, take, than, that, the, their,
them, then, there, these, they, this, those, through,
to, too, under, up, use, very, want, was, way, we,
well, were, what, when, where, which, while, who,
will, with, would, you, your);

$searchQuery=preg_replace( /^.$noiseArray.$/,  , $_POST 
[query]);

$searchQuery=trim($searchQuery);

print p$searchQuery/p;

?

form action=/test.php method=post
  input type=text name=query /
  input type=submit /
/form

/body/html



Dotan Cohen

http://song-lirics.com
http://what-is-what.com/what_is/distribution.html

--
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



Re: [PHP] Decide witch table within a union

2006-10-29 Thread Chris

Børge Holen wrote:

Ok.

Would you suggest to use a extra field to hold the table name as default?


Why do you need to know which table it's in? What are you going to use 
it for in the next step? I see you're passing it in:


echo a href=\index.php?table=$table_nrpage/a;

but what are you going to do with it?

I think if you explain what you're trying to achieve as an end result, 
people might be able to give you better options.


Basically php can't give you extra information than the query itself 
does.. whatever the query does in mysql, is exactly what it will do when 
run through php.


--
Postgresql  php tutorials
http://www.designmagick.com/

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



Re: [PHP] Decide witch table within a union

2006-10-29 Thread Ed Lazor
Definitely not.  Review your design.  If you need to know which table  
data comes from, then perform table specific queries.  If you need to  
combine data from more than one table, code your application to  
respond accordingly.  You may also need to review your database  
schema design in order that it best meet your needs.


On Oct 29, 2006, at 2:00 PM, Børge Holen wrote:

Would you suggest to use a extra field to hold the table name as  
default?



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



[PHP] socket_recv

2006-10-29 Thread Eric
Is there a reccomended size of data to pull in with socket_recv (Such as 
1024) or can I pull in 981132487 and it wont make a difference? Thanks 
in advance.


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



Re: [PHP] IMAP functions for NNTP

2006-10-29 Thread Chris

Eric wrote:

How would I go about listing all newsgroups via the IMAP functions?


Maybe http://www.php.net/manual/en/function.imap-list.php ?

It mentions mailboxes but the imap functions work for news  imap 
accounts.

--
Postgresql  php tutorials
http://www.designmagick.com/

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



Re: [PHP] socket_recv

2006-10-29 Thread Ed Lazor
Depends on the volume and type of data that you're working with.  It  
also depends on the type of connection between the server and  
client.  Slower connections, unreliable connections, or general data,  
use smaller packets.  Reliable connection or higher volumes of data,  
use larger packets.  Think of it this way, the entire packet of data  
gets resent if there's an error and this could be costly time-wise if  
your packets are huge.




On Oct 29, 2006, at 4:41 PM, Eric wrote:

Is there a reccomended size of data to pull in with socket_recv  
(Such as 1024) or can I pull in 981132487 and it wont make a  
difference? Thanks in advance.


--
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] array, classes and values

2006-10-29 Thread martin
hello,

New to oop i'm really strugling to find a way to read a specified MYSQL 
database and tabel in order to determine the number of records, the number 
of fields in each record and convert the data into their labels and values.

Please give me some hints or code...

Thanks,

Martin 

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



Re: [PHP] Decide witch table within a union

2006-10-29 Thread Paul Novitski



On Oct 29, 2006, at 2:00 PM, Børge Holen wrote:


Would you suggest to use a extra field to hold the table name as
default?


At 10/29/2006 04:16 PM, Ed Lazor wrote:

Definitely not.  Review your design.  If you need to know which table
data comes from, then perform table specific queries.  If you need to
combine data from more than one table, code your application to
respond accordingly.  You may also need to review your database
schema design in order that it best meet your needs.



That seems unreasonably harsh.  What in your view 
is wrong with a union query that preserves an 
indicator of which component table a particular record comes from?


I can easily imagine a circumstance in which this 
could be valuable, say the union of several 
mailing lists that are in separate tables simply 
because they originate from different 
sources.  We union them to print a single 
alphabetical list, for example, but we want an 
indicator as to the source of each record.


I can imagine modifying the OP's query to read:

$sql=  (select '1' as tableId, * from table_1 
WHERE pid='0' order by id desc limit 10) union
(select '2' as tableId, * from table_2 
WHERE pid='0' order by id desc limit 10) union
(select '3' as tableId, * from table_3 
WHERE pid='0' order by id desc limit 10) union
(select '4' as tableId, * from table_4 
WHERE pid='0' order by id desc limit 10)

order by date desc limit 10 ;

Would this be so egregious? and if so why?

You say,

If you need to combine data from more than one table,
code your application to respond accordingly.


What does this mean, exactly?  Surely you're not 
suggesting that we code an application to somehow 
divine the source of a record in a union query 
when the query itself could simply supply that datum easily.


Curiously,
Paul

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



Re: [PHP] Re: Is there such a thing?

2006-10-29 Thread Chris

Tom Atkinson wrote:

http://gtk.php.net/

Integz wrote:

http://www.evilbitz.com/2006/10/27/local-php-standalone-binaries-2/





Another interesting one is http://winbinder.org/ but it's windows only.

--
Postgresql  php tutorials
http://www.designmagick.com/

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



Re: [PHP] Decide witch table within a union

2006-10-29 Thread Ed Lazor



That seems unreasonably harsh.


I can see what you mean, but don't take it that way.  I was trying to  
help.



What in your view is wrong with a union query that preserves an  
indicator of which component table a particular record comes from?


Read earlier in the thread.  He's talking about adding a field to the  
table and that the value of this field in every single record will be  
the name of the table the record belongs to.  I said I would  
definitely not recommend doing that.


I can easily imagine a circumstance in which this could be  
valuable, say the union of several mailing lists that are in  
separate tables simply because they originate from different  
sources.  We union them to print a single alphabetical list, for  
example, but we want an indicator as to the source of each record.


I can imagine modifying the OP's query to read:

$sql=  (select '1' as tableId, * from table_1 WHERE pid='0' order  
by id desc limit 10) union
(select '2' as tableId, * from table_2 WHERE pid='0' order  
by id desc limit 10) union
(select '3' as tableId, * from table_3 WHERE pid='0' order  
by id desc limit 10) union
(select '4' as tableId, * from table_4 WHERE pid='0' order  
by id desc limit 10)

order by date desc limit 10 ;

Would this be so egregious? and if so why?


I think this is a great solution, wish I'd thought of it.  =)



You say,

If you need to combine data from more than one table,
code your application to respond accordingly.


What does this mean, exactly?


I'm just talking about intelligent programming.

Surely you're not suggesting that we code an application to somehow  
divine the source of a record in a union query when the query  
itself could simply supply that datum easily.


Of course not.   Honestly, I think you're just being critical of what  
I said, because you thought I was being harsh and unfair when I  
wasn't actually trying to be.


-Ed

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



Re: [PHP] Decide witch table within a union

2006-10-29 Thread Richard Lynch
On Sun, October 29, 2006 3:34 pm, Børge Holen wrote:
 Hi.
 I got this working (almost)
 How do I decide (inside?) the whileloop the table_nr, 1 to 4 witch the
 link is
 echo'ed from.

 I could add another field in each table telling witch table it is.
 Easy
 solution, but feels like polluting the db.

 Also I could do another loop to check another of the printed fields up
 agains
 witch table is used, but that adding to the slowness of this union
 stuff, it
 would take forever, if the union in itself is slow or the fact that
 I'm
 cutting the message field after 100 characters I dunno.

 This is anyway the main code wherein the problem lies:

 $sql=(select * from table_1 WHERE pid='0' order by id desc limit 10)

select *, 'table_1' from table_1 ...

 union
   (select * from table_2 WHERE pid='0' order by id desc limit 10)

select *, 'table_2' from table_2 ...

This gives you an extra field with the table name in it.

You may not be able to use * any more, and have to name all the fields
you actually want.

Which is a better practice anyway.

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] strange problem with count()

2006-10-29 Thread Richard Lynch
On Sun, October 29, 2006 6:27 am, Gunnar Beushausen wrote:
 I've a strange problem with count. I wrote a routine to jump to the
 last
 position of an array.

You mean kind of like this one?
http://php.net/end
:-)

I also suspect you are not doing count() on the right thing...

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



RE: [PHP] Query question

2006-10-29 Thread Richard Lynch
On Sun, October 29, 2006 2:06 am, Beauford wrote:
 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.

When you say it's how you get the data are they handing you a MySQL
database that is this badly-constructed?

Or are you importing data whose dates are in 'mm/dd/' format, and
failing to realize that you CAN and SHOULD convert those to date as
part of your import process.

 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.

Dollars to donuts says your 'date' (which is really a string) has some
leading spaces which is messing up your count...

Of course, after you fix the import process to have an actual DATE in
your DB, this will be a non-issue...

Short-term, you should probably at least trim() the data so that your
offset of 8 is the number you would expect...

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] Re: A general UL script

2006-10-29 Thread Richard Lynch
On Sat, October 28, 2006 4:06 pm, Børge Holen wrote:
 I'm trying to validate wether or not to run the image check script.
 however empty the file field(s) are This script is started... how do I
 tell it
 there is nothing here, go do other stuff.
 for both multiupload forms and single upload forms since they're
 supposed to
 share this script. My logic tells me there should be something like
 this if
 statements, but then again, I'm more of a copy paster rather than a
 expert.

Read the documentation about what will and won't happen if the user
does or doesn't fill in one or more FILE inputs:
http://us3.php.net/manual/en/features.file-upload.php

There is nothing at all tricky in this, really, if you read the docs...

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] Uploading files.

2006-10-29 Thread Richard Lynch
On Sat, October 28, 2006 11:47 am, João Cândido de Souza Neto wrote:
 I´m in a big doubt about uploading files ins a safe way.

 I wont give permission for the web server user to write in some folder
 of my
 system and then use move_uploaded_file function in order to keep it
 secure.

The upload directory should NOT be in your web tree.

*BEFORE* you use move_uploaded_file() to put a file into your web
tree, you should run every reasonable check you can to prove to
yourself that the file is valid format and has content you actually
want.

If you are on a shared server and don't want PHP to have write access
to a directory in your web tree, then don't -- Just
move_uploaded_file() to another non web tree directory, and then write
a PHP script with http://php.net/readfile or http://php.net/fopen and
friends to serve up the files.  You can also keep a record in your DB
of which files were uploaded, along with some meta-data, so that you
can be sure your script only serves up the files you have already
vetted.

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] Is there such a thing?

2006-10-29 Thread Richard Lynch
On Fri, October 27, 2006 5:46 pm, Integz wrote:
 http://www.evilbitz.com/2006/10/27/local-php-standalone-binaries-2/

I responded in that forum.

Short Version:

No.

Check out:
http://gtk.php.net/

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] Decide witch table within a union

2006-10-29 Thread Paul Novitski

At 10/29/2006 08:04 PM, Ed Lazor wrote:


That seems unreasonably harsh.


I can see what you mean, but don't take it that way.  I was trying to
help.


Sorry, Ed, I had intended my reply to be friendly as well.  I'm 
allergic to smiley-face icons, but I should have tried harder to 
convey my tone.  Dang this poker-faced email!




What in your view is wrong with a union query that preserves an
indicator of which component table a particular record comes from?


Read earlier in the thread.  He's talking about adding a field to the
table and that the value of this field in every single record will be
the name of the table the record belongs to.  I said I would
definitely not recommend doing that.


Me neither.  You're right.  I was only referencing his next email in 
which he said,

Would you suggest to use a extra field to hold the table name as default?
which I thought was a great idea, but only because I thought he meant 
the query.


Warm regards,
Paul 


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



Re: [PHP] How do I get ini_set('output_handler', '') to work?!

2006-10-29 Thread Richard Lynch
On Fri, October 27, 2006 3:46 pm, Daevid Vincent wrote:
 What am I doing wrong...

 In my php.ini I have this for my web pages (and I want it):

   output_handler = ob_gzhandler

 But this causes my command line script to not show output until the
 very
 end.

 I thought I could disable it at the top of a script, but it's not
 working!?!

 #!/usr/bin/php -q
 ?php
   ini_set('output_handler', 'mb_output_handler');

TOO LATE!

The ob_start() has already kicked in by this point.

ob_flush() until there are no more buffers.

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] array, classes and values

2006-10-29 Thread Chris

martin wrote:

hello,

New to oop i'm really strugling to find a way to read a specified MYSQL 
database and tabel in order to determine the number of records, the number 
of fields in each record and convert the data into their labels and values.


I suggest you search for php mysql tutorial in your favourite search 
engine. There are tons of resources out there to help you with this stuff.


--
Postgresql  php tutorials
http://www.designmagick.com/

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



Re: [PHP] Non-blocking sockets

2006-10-29 Thread Richard Lynch
On Fri, October 27, 2006 3:23 pm, Eric wrote:
 When I create a socket/stream that connects to a news sever and try to
 recv data from the socket when there is nothing there (Like if the
 server sends one line and I call recv twice) the socket freezes. I
 assume this is because using socket_create or fsockopen creates a
 blocking TCP/Stream socket by default. When I call
 socket_set_nonblock()
 and the socket_connect I get A non-blocking operation could not be
 completed immediately. Could someone show me exactly how to create a
 non-blocking TCP/Stream socket? Thanks in advance.

First, to make the initial socket creation/connection not block, you use:
http://php.net/ini_set
on that one socket connection timeout thingie in php.ini I can't
remember right now.

*THEN* after you have the socket up and running, you use:
http://php.net/socket_set_block

At least, that's the way I remember it from the last time I played
this game...

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] counting records in db

2006-10-29 Thread Richard Lynch
On Fri, October 27, 2006 12:14 pm, [EMAIL PROTECTED] wrote:
 And the header(Location: ...) requires a full URL.
 Why?

Because the docs say so?

Because some user agents will not do what you want them to if you don't?

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] Decide witch table within a union

2006-10-29 Thread Ed Lazor


Sorry, Ed, I had intended my reply to be friendly as well.  I'm  
allergic to smiley-face icons, but I should have tried harder to  
convey my tone.  Dang this poker-faced email!


No worries.  It's all good :)

-Ed

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



Re: [PHP] counting records in db

2006-10-29 Thread Richard Lynch
On Fri, October 27, 2006 4:53 pm, Børge Holen wrote:
 On Friday 27 October 2006 19:34, Richard Lynch wrote:
 And the header(Location: ...) requires a full URL.

 No it doesn't. but he's missing an ' at first glance

Yes, it does:
http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.30

Note the use of 'absolute' within that section.

You can argue that they shouldn't have designed the spec that way.

You can argue that it works in all popular browsers.

But there ain't much to argue about what the spec says...

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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