Re: [PHP] limit access to php page

2013-05-31 Thread Tamara Temple
Camilo Sperberg  wrote:
> On 30 mei 2013, at 05:05, Paul M Foster  wrote:
> 
> > On Wed, May 29, 2013 at 08:51:47PM -0400, Tedd Sperling wrote:
> > 
> >> On May 29, 2013, at 7:11 PM, Tim Dunphy  wrote:
> >> 
> >>> Hello list,
> >>> 
> >>> I've created an authentication page (index.php) that logs into an LDAP
> >>> server, then points you to a second page that some folks are intended to
> >>> use to request apache redirects from the sysadmin group (redirect.php).
> >>> 
> >>> Everything works great so far, except if you pop the full URL of
> >>> redirect.php into your browser you can hit the page regardless of the 
> >>> login
> >>> process on index.php.
> >>> 
> >>> How can I limit redirect.php so that it can only be reached once you login
> >>> via the index page?
> >>> 
> >>> Thank you!
> >>> Tim
> >>> 
> >>> -- 
> >>> GPG me!!
> >> 
> >> Try this:
> >> 
> >> http://sperling.com/php/authorization/log-on.php
> > 
> > I realize this is example code.
> > 
> > My question is, in a real application where that $_SESSION['auth'] token
> > would be used subsequently to gain entry to other pages, what would you
> > use instead of the simple TRUE/FALSE value? It seems that someone (with
> > far more knowledge of hacking than I have) could rather easily hack the
> > session value to change its value. But then again, I pretty much suck
> > when it comes to working out how you'd "hack" (crack) things.
> > 
> > Paul
> 
> $_SESSION value are quite secure, as they are set on the server, only you can 
> control what's inside them. What can be hacked is the authentification 
> process or some script that sets session values. There is also a way of 
> hijacking a session, but again: its values aren't changed by some PHP script, 
> the session is being hijacked. Don't pass urls with the session id within 
> them and you'll be save. 

Looking back through the posts, I see I sent one without the link I
intended.

Session variables can be secure enough (there will never be perfect
security, just like there will never be completely safe sex), but you
*do* have to take precautions.

This is the link I meant to send before:

http://www.php.net/manual/en/session.security.php

Very important reading.





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



Re: [PHP] limit access to php page

2013-05-30 Thread Paul M Foster
On Thu, May 30, 2013 at 12:06:02PM -0400, Tedd Sperling wrote:

> On May 29, 2013, at 11:05 PM, Paul M Foster 
> wrote:
> >> http://sperling.com/php/authorization/log-on.php
> > 
> > I realize this is example code.
> > 
> > My question is, in a real application where that $_SESSION['auth']
> > token would be used subsequently to gain entry to other pages, what
> > would you use instead of the simple TRUE/FALSE value? It seems that
> > someone (with far more knowledge of hacking than I have) could
> > rather easily hack the session value to change its value. But then
> > again, I pretty much suck when it comes to working out how you'd
> > "hack" (crack) things.
> > 
> > Paul
> 
> Paul:
> 
> While the above link may be example code, it is still sound for
> production.
> 
> Keep in mind that everything in security comes down to a true/false
> condition. Do you let the person in or not!
> 
> Certainly there are attacks on session ids and one must deal with
> that. But that's the level of security we have today.
> 
> I could go through all the things you need to consider in protecting
> your session id (e.g., not accessing your bank accounts while having
> coffee at StartBucks) but that would defeat the purpose of attending
> one of my classes on the subject. :-)

Yep, next time I'm up at the North Pole, I'll drop in and see you.
Meantime, the beach is heating up. Better go get some more ice for my
margueritas. [grin]

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] limit access to php page

2013-05-30 Thread Tedd Sperling
On May 29, 2013, at 11:05 PM, Paul M Foster  wrote:
>> http://sperling.com/php/authorization/log-on.php
> 
> I realize this is example code.
> 
> My question is, in a real application where that $_SESSION['auth'] token
> would be used subsequently to gain entry to other pages, what would you
> use instead of the simple TRUE/FALSE value? It seems that someone (with
> far more knowledge of hacking than I have) could rather easily hack the
> session value to change its value. But then again, I pretty much suck
> when it comes to working out how you'd "hack" (crack) things.
> 
> Paul

Paul:

While the above link may be example code, it is still sound for production.

Keep in mind that everything in security comes down to a true/false condition. 
Do you let the person in or not!

Certainly there are attacks on session ids and one must deal with that. But 
that's the level of security we have today.

I could go through all the things you need to consider in protecting your 
session id (e.g., not accessing your bank accounts while having coffee at 
StartBucks) but that would defeat the purpose of attending one of my classes on 
the subject. :-)

If you are very concerned about security, then jump to a https protocol for 
those transactions; change session ids frequently; monitor the user's local 
environmental changes; time the session, and do a bunch of other stuff that 
will make it more and more difficult for your user to use your service. But for 
*most things* using a session id will  keep things relatively safe.

Cheers,

tedd

_
tedd.sperl...@gmail.com
http://sperling.com

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



Re: [PHP] limit access to php page

2013-05-29 Thread Camilo Sperberg
On 30 mei 2013, at 05:05, Paul M Foster  wrote:

> On Wed, May 29, 2013 at 08:51:47PM -0400, Tedd Sperling wrote:
> 
>> On May 29, 2013, at 7:11 PM, Tim Dunphy  wrote:
>> 
>>> Hello list,
>>> 
>>> I've created an authentication page (index.php) that logs into an LDAP
>>> server, then points you to a second page that some folks are intended to
>>> use to request apache redirects from the sysadmin group (redirect.php).
>>> 
>>> Everything works great so far, except if you pop the full URL of
>>> redirect.php into your browser you can hit the page regardless of the login
>>> process on index.php.
>>> 
>>> How can I limit redirect.php so that it can only be reached once you login
>>> via the index page?
>>> 
>>> Thank you!
>>> Tim
>>> 
>>> -- 
>>> GPG me!!
>> 
>> Try this:
>> 
>> http://sperling.com/php/authorization/log-on.php
> 
> I realize this is example code.
> 
> My question is, in a real application where that $_SESSION['auth'] token
> would be used subsequently to gain entry to other pages, what would you
> use instead of the simple TRUE/FALSE value? It seems that someone (with
> far more knowledge of hacking than I have) could rather easily hack the
> session value to change its value. But then again, I pretty much suck
> when it comes to working out how you'd "hack" (crack) things.
> 
> Paul
> 
> -- 
> Paul M. Foster
> http://noferblatz.com
> http://quillandmouse.com
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

$_SESSION value are quite secure, as they are set on the server, only you can 
control what's inside them. What can be hacked is the authentification process 
or some script that sets session values. There is also a way of hijacking a 
session, but again: its values aren't changed by some PHP script, the session 
is being hijacked. Don't pass urls with the session id within them and you'll 
be save. 

Greetings. 

Sent from my iPhone 6 Beta [Confidential use only]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] limit access to php page

2013-05-29 Thread Paul M Foster
On Wed, May 29, 2013 at 08:51:47PM -0400, Tedd Sperling wrote:

> On May 29, 2013, at 7:11 PM, Tim Dunphy  wrote:
> 
> > Hello list,
> > 
> > I've created an authentication page (index.php) that logs into an LDAP
> > server, then points you to a second page that some folks are intended to
> > use to request apache redirects from the sysadmin group (redirect.php).
> > 
> > Everything works great so far, except if you pop the full URL of
> > redirect.php into your browser you can hit the page regardless of the login
> > process on index.php.
> > 
> > How can I limit redirect.php so that it can only be reached once you login
> > via the index page?
> > 
> > Thank you!
> > Tim
> > 
> > -- 
> > GPG me!!
> 
> Try this:
> 
> http://sperling.com/php/authorization/log-on.php

I realize this is example code.

My question is, in a real application where that $_SESSION['auth'] token
would be used subsequently to gain entry to other pages, what would you
use instead of the simple TRUE/FALSE value? It seems that someone (with
far more knowledge of hacking than I have) could rather easily hack the
session value to change its value. But then again, I pretty much suck
when it comes to working out how you'd "hack" (crack) things.

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



Re: [PHP] limit access to php page

2013-05-29 Thread Tedd Sperling
On May 29, 2013, at 7:11 PM, Tim Dunphy  wrote:

> Hello list,
> 
> I've created an authentication page (index.php) that logs into an LDAP
> server, then points you to a second page that some folks are intended to
> use to request apache redirects from the sysadmin group (redirect.php).
> 
> Everything works great so far, except if you pop the full URL of
> redirect.php into your browser you can hit the page regardless of the login
> process on index.php.
> 
> How can I limit redirect.php so that it can only be reached once you login
> via the index page?
> 
> Thank you!
> Tim
> 
> -- 
> GPG me!!

Try this:

http://sperling.com/php/authorization/log-on.php

Cheers,


tedd

_
tedd.sperl...@gmail.com
http://sperling.com

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



Re: [PHP] limit access to php page

2013-05-29 Thread tamouse mailing lists
On Wed, May 29, 2013 at 6:11 PM, Tim Dunphy  wrote:
> Hello list,
>
>  I've created an authentication page (index.php) that logs into an LDAP
> server, then points you to a second page that some folks are intended to
> use to request apache redirects from the sysadmin group (redirect.php).
>
> Everything works great so far, except if you pop the full URL of
> redirect.php into your browser you can hit the page regardless of the login
> process on index.php.
>
> How can I limit redirect.php so that it can only be reached once you login
> via the index page?
>
> Thank you!
> Tim
>
> --
> GPG me!!
>
> gpg --keyserver pool.sks-keyservers.net --recv-keys F186197B

Read through this page, and the other parts of the Session manual.
Hopefully that will help.

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



[PHP] limit access to php page

2013-05-29 Thread Tim Dunphy
Hello list,

 I've created an authentication page (index.php) that logs into an LDAP
server, then points you to a second page that some folks are intended to
use to request apache redirects from the sysadmin group (redirect.php).

Everything works great so far, except if you pop the full URL of
redirect.php into your browser you can hit the page regardless of the login
process on index.php.

How can I limit redirect.php so that it can only be reached once you login
via the index page?

Thank you!
Tim

-- 
GPG me!!

gpg --keyserver pool.sks-keyservers.net --recv-keys F186197B


[PHP] apache or php limit?

2011-05-30 Thread Peet Grobler
Hi there, new to this list.

I have a problem I can't seem to figure out. Here goes.

PHP page has 100s of textboxes on it. Submit on the development machine,
everything works as expected. Submit on live machine - only part of the
$_POST variables are there. The script doesn't stop executing - it
executes just fine with the limited data.

I've checked:
- post_max_size - more than enough (8M). Increased to 512M and
  re-tested, this is definately not the problem.
- memory_limit - same thing (increased from 128M to 512M)
- apache2.conf is the same on both hosts (except for ServerName,
  etc.
- php.ini is the same on both machines (except for debugging information
  turned on on development machine).
- I enabled debugging and logging on the live machine, but there's
  nothing in the logs.

Can anyone point me in any direction please. It boggles the mind that
the exact same script works fine on one machine, but not the other,
given that apache and php configs are the same.

flu:~# apache2 -v
Server version: Apache/2.2.16 (Debian)
Server built:   Mar 22 2011 20:56:31
flu:~# php -v
PHP 5.3.3-7+squeeze1 with Suhosin-Patch (cli) (built: Mar 18 2011 17:22:52)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
with Suhosin v0.9.32.1, Copyright (c) 2007-2010, by SektionEins GmbH
flu:~# cat /proc/version
Linux version 2.6.26-2-686 (Debian 2.6.26-26lenny1) (da...@debian.org)
(gcc version 4.1.3 20080704 (prerelease) (Debian 4.1.2-25)) #1 SMP Thu
Nov 25 01:53:57 UTC 2010
flu:~#


If this is the wrong place to ask please point me in some direction.

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



Re: [PHP] Limit failed logins attempts

2010-08-09 Thread Peter Lind
On 9 August 2010 15:10, Richard Quadling  wrote:
> On 9 August 2010 14:04, Juan Rodriguez Monti  
> wrote:
>> 2010/8/9 Richard Quadling :
>>> On 9 August 2010 13:30, Juan Rodriguez Monti  
>>> wrote:
 I thought that might be a good idea, to define a session variable
 called ( failedattempts ), then check and if $failedattempts is
 greater than, suppose, 4 ...
>>>
>>> As sessions are connected to a request through a session cookie,
>>> putting the failed attempts in the session for checking later is a bad
>>> idea. A script attempting to crack your security will most likely NOT
>>> be using cookies. So each request, all the many millions of them, will
>>> seem to be clean/virgin requests, not multiple attempts. Each request
>>> will create a blank new session with 0 previous attempts.
>>
>> Good point. Thanks.
>>
>> So, what should I use instead of sessions to check this ?.
>>
>> Juan
>>
>
> You could suspend the account after 3 bad logins. Nice and simple. A
> "FailedLoginsSinceLastLogin" counter against the account in the DB
> should be enough. If that exceeds your limit, then they can't login.
> They will have to re-authenticate in some other way. When that is
> successful, then the value can be cleared.

That allows locking out users at random by knowing the username - not
a very good solution.

Regards
Peter

-- 

WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
BeWelcome/Couchsurfing: Fake51
Twitter: http://twitter.com/kafe15


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



Re: [PHP] Limit failed logins attempts

2010-08-09 Thread Richard Quadling
On 9 August 2010 14:04, Juan Rodriguez Monti  wrote:
> 2010/8/9 Richard Quadling :
>> On 9 August 2010 13:30, Juan Rodriguez Monti  
>> wrote:
>>> I thought that might be a good idea, to define a session variable
>>> called ( failedattempts ), then check and if $failedattempts is
>>> greater than, suppose, 4 ...
>>
>> As sessions are connected to a request through a session cookie,
>> putting the failed attempts in the session for checking later is a bad
>> idea. A script attempting to crack your security will most likely NOT
>> be using cookies. So each request, all the many millions of them, will
>> seem to be clean/virgin requests, not multiple attempts. Each request
>> will create a blank new session with 0 previous attempts.
>
> Good point. Thanks.
>
> So, what should I use instead of sessions to check this ?.
>
> Juan
>

You could suspend the account after 3 bad logins. Nice and simple. A
"FailedLoginsSinceLastLogin" counter against the account in the DB
should be enough. If that exceeds your limit, then they can't login.
They will have to re-authenticate in some other way. When that is
successful, then the value can be cleared.

Bob's way looks good.

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



RE: [PHP] Limit failed logins attempts

2010-08-09 Thread Bob McConnell
From: Juan Rodriguez Monti

> I would like to know what do you suggest to implement a limit for
> failed login attempts.
> 
> I thought that might be a good idea, to define a session variable
> called ( failedattempts ), then check and if $failedattempts is
> greater than, suppose, 4 write to a Database ( ip, username and
> last-time-attempt ). If ater that, the user/bot tries again to login
> unsuccessfully, then the system should ban that user & ip combination.

We have two columns in the user table, login_attempts and u_touch. The
first is an integer, the second is a time stamp. The second is updated
to now every time the user requests a page. Each time a login attempt
fails, the first column is incremented. If the first column exceeds 3
when a new attempt is made, the previous time in the second must be more
than 30 minutes old. The first column is reset to 0 on a successful
login, or 1 on an unsuccessful attempt more than 30 minutes after the
previous attempt.

The error message is the same for all login failures, no matter what the
cause.

While logged in, if a page is requested with the value of u_touch more
than ten minutes old, the user is automatically logged out.

Bob McConnell

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



Re: [PHP] Limit failed logins attempts

2010-08-09 Thread Richard Quadling
On 9 August 2010 13:30, Juan Rodriguez Monti  wrote:
> I thought that might be a good idea, to define a session variable
> called ( failedattempts ), then check and if $failedattempts is
> greater than, suppose, 4 ...

As sessions are connected to a request through a session cookie,
putting the failed attempts in the session for checking later is a bad
idea. A script attempting to crack your security will most likely NOT
be using cookies. So each request, all the many millions of them, will
seem to be clean/virgin requests, not multiple attempts. Each request
will create a blank new session with 0 previous attempts.

Richard.

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



Re: [PHP] Limit failed logins attempts

2010-08-09 Thread Peter Lind
On 9 August 2010 14:30, Juan Rodriguez Monti  wrote:
> Hi guys,
> I would like to know what do you suggest to implement a limit for
> failed login attempts.

I use velocity control (or whatever it is called). After the first
failed attempt, set a ban-period before another login is possible for
the account - start at 1 second. After each consecutive fail, double
the period.

> I thought that might be a good idea, to define a session variable
> called ( failedattempts ), then check and if $failedattempts is
> greater than, suppose, 4 write to a Database ( ip, username and
> last-time-attempt ). If ater that, the user/bot tries again to login
> unsuccessfully, then the system should ban that user & ip combination.
>
> Some questions about this situation:
>
> - Do you think that is a good idea to use sleep() ?.

No. That won't achieve much except annoy legitimate users.

> - How should I send a 503 HTTP error to the user after 5 attempts ?

user header(). I would send a 403

> - Is this a good idea to do all this work for this security purpose ?

Making sure that noone can try bruteforcing an account is a good idea.
Just make sure you cannot use this security measure to lock out an
account.

> - Do you know/suggest a better way to solve this?

Velocity control, as stated.

Regards
Peter

-- 

WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
BeWelcome/Couchsurfing: Fake51
Twitter: http://twitter.com/kafe15


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



[PHP] Limit failed logins attempts

2010-08-09 Thread Juan Rodriguez Monti
Hi guys,
I would like to know what do you suggest to implement a limit for
failed login attempts.

I thought that might be a good idea, to define a session variable
called ( failedattempts ), then check and if $failedattempts is
greater than, suppose, 4 write to a Database ( ip, username and
last-time-attempt ). If ater that, the user/bot tries again to login
unsuccessfully, then the system should ban that user & ip combination.

Some questions about this situation:

- Do you think that is a good idea to use sleep() ?.
- How should I send a 503 HTTP error to the user after 5 attempts ?
- Is this a good idea to do all this work for this security purpose ?
- Do you know/suggest a better way to solve this?

Thanks in advance,
Juan

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



Re: [PHP] limit to var_dump?

2010-04-17 Thread Michiel Sikma
On 16 April 2010 16:15, Ashley Sheridan  wrote:

> I'm seeing some strange behaviour with var_dump. Is there a limit to how
> many levels deep that var_dump can display?
>
> -snip-
>
> However, when I var_dump the top-most object (the Gantt object) the
> predecessors array for Gantt_Task 1.2 just shows as '...'. If I var_dump
> that particular object, I can see that the correct array element does
> exist.
>
> Is this just a random bug I've found, or is there an intended limit to
> how complex and deep var_dump can go? Would it have anything to do with
> the fact that Gantt contains multiple instances of the Gantt_Task
> object?
>
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
There's a limit to var_dump if you have Xdebug installed. See the Xdebug
site:

http://www.xdebug.org/docs/display

On another note, iirc var_dump itself can detect and prevent infinite
recursion.

Michiel


Re: [PHP] limit to var_dump?

2010-04-16 Thread Peter Lind
There's a limit to how deep var_dump goes, at least if you're using
xdebug. Compare the output with that of print_r which is not limited
in the same way.

On 16 April 2010 16:15, Ashley Sheridan  wrote:
> I'm seeing some strange behaviour with var_dump. Is there a limit to how
> many levels deep that var_dump can display?
>
> Basically, my object looks like this:
>
> object(Gantt)[1]
>  public 'tasks' =>
>    array
>      1 =>
>        object(Gantt_Task)[2]
>          public 'name' => string 'task 1' (length 6)
>          public 'predecessors' =>
>            array
>              ...
>      1.1 =>
>        object(Gantt_Task)[3]
>          public 'name' => string 'task 1.1' (length 8)
>          public 'predecessors' =>
>            array
>              ...
>      1.2 =>
>        object(Gantt_Task)[4]
>          public 'name' => string 'task 1.2' (length 8)
>          public 'predecessors' =>
>            array
>              '1.1' => string 'f2s' (length 3)
>
>
> (full dump shortened, but it's no more than 4x the size of this output
> above, and the objects contain only short strings, small numbers and
> arrays of short strings and small numbers)
>
> However, when I var_dump the top-most object (the Gantt object) the
> predecessors array for Gantt_Task 1.2 just shows as '...'. If I var_dump
> that particular object, I can see that the correct array element does
> exist.
>
> Is this just a random bug I've found, or is there an intended limit to
> how complex and deep var_dump can go? Would it have anything to do with
> the fact that Gantt contains multiple instances of the Gantt_Task
> object?
>
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>



-- 

WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
Flickr: http://www.flickr.com/photos/fake51
BeWelcome: Fake51
Couchsurfing: Fake51


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



[PHP] limit to var_dump?

2010-04-16 Thread Ashley Sheridan
I'm seeing some strange behaviour with var_dump. Is there a limit to how
many levels deep that var_dump can display?

Basically, my object looks like this:

object(Gantt)[1]
  public 'tasks' =>
array
  1 =>
object(Gantt_Task)[2]
  public 'name' => string 'task 1' (length 6)
  public 'predecessors' =>
array
  ...
  1.1 =>
object(Gantt_Task)[3]
  public 'name' => string 'task 1.1' (length 8)
  public 'predecessors' =>
array
  ...
  1.2 =>
object(Gantt_Task)[4]
  public 'name' => string 'task 1.2' (length 8)
  public 'predecessors' =>
array
  '1.1' => string 'f2s' (length 3)
  

(full dump shortened, but it's no more than 4x the size of this output
above, and the objects contain only short strings, small numbers and
arrays of short strings and small numbers)

However, when I var_dump the top-most object (the Gantt object) the
predecessors array for Gantt_Task 1.2 just shows as '...'. If I var_dump
that particular object, I can see that the correct array element does
exist.

Is this just a random bug I've found, or is there an intended limit to
how complex and deep var_dump can go? Would it have anything to do with
the fact that Gantt contains multiple instances of the Gantt_Task
object?


Thanks,
Ash
http://www.ashleysheridan.co.uk




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



Re: [PHP] Limit query/function time

2009-10-22 Thread Philip Thompson

On Oct 22, 2009, at 3:30 PM, Phpster wrote:


Have you run an explain plan on the query?

Bastien

Sent from my iPod


Yes, I have. For giggles, I wanted to run it again. Here it is  
(slightly stripped down) and it looks good to me.


mysql> EXPLAIN SELECT
-> `p`.`patient_id`,
-> `p`.`address_id`,
-> `p`.`patient_sub_id`,
-> AES_DECRYPT(`p`.`patient_first_name`, 'hidden_key') AS  
`patient_first_name`,
-> AES_DECRYPT(`p`.`patient_last_name`, 'hidden_key') AS  
`patient_last_name`,
-> AES_DECRYPT(`p`.`patient_middle_name`, 'hidden_key') AS  
`patient_middle_name`,

-> AES_DECRYPT(`p`.`patient_dob`, 'hidden_key') AS `patient_dob`
-> FROM `patient` `p`
-> INNER JOIN `center_patient` `cp` ON `p`.`patient_id` =  
`cp`.`patient_id`
-> WHERE ((`p`.`patient_id` = '256783' OR `p`.`patient_sub_id` =  
'256783') AND `cp`.`center_id` = '109')

-> ORDER BY `patient_id` DESC;
++-++-- 
+--+
| id | key_len | ref| rows |  
Extra|
++-++-- 
+--+
|  1 | 4,4 | NULL   |2 | Using union 
(PRIMARY,patient_sub_id); Using where; Using filesort |
|  1 | 8   | p.patient_id,const |1 | Using  
index  |
++-++-- 
+--+

2 rows in set (0.00 sec)

There are about 350,000 records in `patient` and `center_patient`  
tables. The average number of rows returned from this query is less  
than 5.


~Philip


On Oct 22, 2009, at 4:14 PM, Philip Thompson  
 wrote:



Hi all.

I'm running into a random issue where sometimes it take several  
minutes (up to 10 or 15) to complete a query. According to 1 or 2  
references, this may be a mysql bug. These links explain the  
similar problem I'm experiencing:


http://forums.mysql.com/read.php?24,57257
http://forum.percona.com/s/m/790/

I did some testing yesterday and this 1 sql statement successfully  
queried (in milliseconds) approximately 50,000 times before it took  
several minutes to query, which hung all the other processes on the  
database. Because it occurs successfully so many times, I know the  
query is good.


Is it possible to set a time limit on a single function in PHP?  
E.g., when I call mysql_query() and it takes 30 seconds, then quit  
processing that function and continue on. I know I could  
set_time_limit() to a specific time, but that would cause a fatal  
error... and I want to be able to catch it.


Any thoughts on what direction I should go? Also, I'm going to do  
some research to see if a newer version of mysql has fixed this  
bug. We're running 5.0.45.


Thanks,
~Philip


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



Re: [PHP] Limit query/function time

2009-10-22 Thread Philip Thompson

On Oct 22, 2009, at 3:26 PM, Eddie Drapkin wrote:

On Thu, Oct 22, 2009 at 4:14 PM, Philip Thompson > wrote:

Hi all.

I'm running into a random issue where sometimes it take several  
minutes (up
to 10 or 15) to complete a query. According to 1 or 2 references,  
this may
be a mysql bug. These links explain the similar problem I'm  
experiencing:


http://forums.mysql.com/read.php?24,57257
http://forum.percona.com/s/m/790/

I did some testing yesterday and this 1 sql statement successfully  
queried
(in milliseconds) approximately 50,000 times before it took several  
minutes
to query, which hung all the other processes on the database.  
Because it

occurs successfully so many times, I know the query is good.

Is it possible to set a time limit on a single function in PHP?  
E.g., when I

call mysql_query() and it takes 30 seconds, then quit processing that
function and continue on. I know I could set_time_limit() to a  
specific
time, but that would cause a fatal error... and I want to be able  
to catch

it.

Any thoughts on what direction I should go? Also, I'm going to do  
some

research to see if a newer version of mysql has fixed this bug. We're
running 5.0.45.

Thanks,
~Philip


You could use ErrorException and catch that:
http://www.php.net/manual/en/class.errorexception.php
Or you could just set your own error handler:
http://www.php.net/manual/en/function.set-error-handler.php

Something I don't know if you've thought of that came to mind, though,
is the MySQL query cache.  It's entirely likely that you have a query
that takes several minutes to run, then is stored in query cache for
the next 50,000 iterations of the query.  Have you observed this same
behavior without the query cache enabled (it also looks like the bug
mentioned in the second link - the one that pertains to the 5.0.x
branch of mysql - has to do with an overly large query cache)?  Based
on that post, I'd guess that your next action would be to disable the
query cache and determine from there if it's a slow query or actually
the bug in MySQL.


I didn't think you could catch fatal errors - isn't that why they're  
fatal?


I will check into the query cache thing. However, the query that I'm  
running isn't exactly the same each time. Each iteration has a  
different ID value in the WHERE clause.


Thank you,
~Philip



Re: [PHP] Limit query/function time

2009-10-22 Thread Phpster

Have you run an explain plan on the query?

Bastien

Sent from my iPod

On Oct 22, 2009, at 4:14 PM, Philip Thompson   
wrote:



Hi all.

I'm running into a random issue where sometimes it take several  
minutes (up to 10 or 15) to complete a query. According to 1 or 2  
references, this may be a mysql bug. These links explain the similar  
problem I'm experiencing:


http://forums.mysql.com/read.php?24,57257
http://forum.percona.com/s/m/790/

I did some testing yesterday and this 1 sql statement successfully  
queried (in milliseconds) approximately 50,000 times before it took  
several minutes to query, which hung all the other processes on the  
database. Because it occurs successfully so many times, I know the  
query is good.


Is it possible to set a time limit on a single function in PHP?  
E.g., when I call mysql_query() and it takes 30 seconds, then quit  
processing that function and continue on. I know I could  
set_time_limit() to a specific time, but that would cause a fatal  
error... and I want to be able to catch it.


Any thoughts on what direction I should go? Also, I'm going to do  
some research to see if a newer version of mysql has fixed this bug.  
We're running 5.0.45.


Thanks,
~Philip

--
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] Limit query/function time

2009-10-22 Thread Eddie Drapkin
On Thu, Oct 22, 2009 at 4:14 PM, Philip Thompson  wrote:
> Hi all.
>
> I'm running into a random issue where sometimes it take several minutes (up
> to 10 or 15) to complete a query. According to 1 or 2 references, this may
> be a mysql bug. These links explain the similar problem I'm experiencing:
>
> http://forums.mysql.com/read.php?24,57257
> http://forum.percona.com/s/m/790/
>
> I did some testing yesterday and this 1 sql statement successfully queried
> (in milliseconds) approximately 50,000 times before it took several minutes
> to query, which hung all the other processes on the database. Because it
> occurs successfully so many times, I know the query is good.
>
> Is it possible to set a time limit on a single function in PHP? E.g., when I
> call mysql_query() and it takes 30 seconds, then quit processing that
> function and continue on. I know I could set_time_limit() to a specific
> time, but that would cause a fatal error... and I want to be able to catch
> it.
>
> Any thoughts on what direction I should go? Also, I'm going to do some
> research to see if a newer version of mysql has fixed this bug. We're
> running 5.0.45.
>
> Thanks,
> ~Philip
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

You could use ErrorException and catch that:
http://www.php.net/manual/en/class.errorexception.php
Or you could just set your own error handler:
http://www.php.net/manual/en/function.set-error-handler.php

Something I don't know if you've thought of that came to mind, though,
is the MySQL query cache.  It's entirely likely that you have a query
that takes several minutes to run, then is stored in query cache for
the next 50,000 iterations of the query.  Have you observed this same
behavior without the query cache enabled (it also looks like the bug
mentioned in the second link - the one that pertains to the 5.0.x
branch of mysql - has to do with an overly large query cache)?  Based
on that post, I'd guess that your next action would be to disable the
query cache and determine from there if it's a slow query or actually
the bug in MySQL.

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



[PHP] Limit query/function time

2009-10-22 Thread Philip Thompson

Hi all.

I'm running into a random issue where sometimes it take several  
minutes (up to 10 or 15) to complete a query. According to 1 or 2  
references, this may be a mysql bug. These links explain the similar  
problem I'm experiencing:


http://forums.mysql.com/read.php?24,57257
http://forum.percona.com/s/m/790/

I did some testing yesterday and this 1 sql statement successfully  
queried (in milliseconds) approximately 50,000 times before it took  
several minutes to query, which hung all the other processes on the  
database. Because it occurs successfully so many times, I know the  
query is good.


Is it possible to set a time limit on a single function in PHP? E.g.,  
when I call mysql_query() and it takes 30 seconds, then quit  
processing that function and continue on. I know I could set_time_limit 
() to a specific time, but that would cause a fatal error... and I  
want to be able to catch it.


Any thoughts on what direction I should go? Also, I'm going to do some  
research to see if a newer version of mysql has fixed this bug. We're  
running 5.0.45.


Thanks,
~Philip

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



RE: [PHP] LIMIT and SESSION WAS: What is this called?

2009-07-06 Thread Daevid Vincent
> -Original Message-
> From: Wolf [mailto:lonew...@nc.rr.com] 
> Sent: Monday, July 06, 2009 8:10 AM
>
> Basically, go smack whomever told you to load all that stuff 
> into a session.  It's a paging query that you want to do, but 
> I'd not recommend doing it to store it in a session.
> 
> You can store all that stuff into a session, but you risk 
> putting a greater load on the users session then you would be 
> putting on the database server.

http://dev.mysql.com/doc/refman/5.0/en/select.html

You want to use "limit".

As for storing all the results, there most likely isn't a reason to, however
if you must do it that way (perhaps you have a << and >> button or something
to step through), then I suggest you save the __row ID's only__ in a
$_SESSION array variable and do a SELECT via the ID (and "LIMIT 1" can't
hurt either in case you're storing a SKU_ID or some other unique key but
it's not a primary key) as you're stepping. This way your bulky query is
only done once. This is a more advanced technique however and may be
confusing to you if you don't know what you're doing. 

You can also pull all these items faster on subsequent pages by doing an
"WHERE item.id IN ($myarray)" type of deal (pseudo code of course). 


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



Re: [PHP] Limit Local Search to Content

2009-03-26 Thread George Langley
	Hi Ashley. That's what I'm doing, but want to limit what gets stored  
to just the content. Every page has a drop-down menu of, for  
instance, various cities, so I want to exclude that part of the page  
in my search terms. I don't want every page to think it has content  
on Calgary, Hamburg, Phoenix, etc.
	I finally walked myself through the code I had been modifying, and  
found that they were parsing it line by line with an fgets (rather  
than word by word). So was able to use Stuart's original idea of  
surrounding the content with an unique comment line, and setting a  
flag to tell whether to parse the line or not. If it found the  line, it would start parsing, and stop again when it  
reached the  line.
	Is also nice that I can then specify multiple sections within the  
page if I need to.


On 26-Mar-09, at 6:22 PM, Ashley Sheridan wrote:


What about storing all of the page content in the database to start
with, then searching with a mysql statement is a breeze!

On Thu, 2009-03-26 at 16:29 -0600, George Langley wrote:

- Original Message -

From: Stuart 

You can't have any extra info in a closing HTML tag. This
problem is
usually handled using comments. Something like the following...



sofihsod hiosdh sdh gus us u sg



You then just start with you see the begin comment and stop

when you

hit the end comment.

-
	Hmm, they are stripping out the tags before looking at the words,  
so didn't work quite as I originally thought.
	The solution seems to be to explode the string based on the  
entire comment before doing the word-by-word storing. I wrote up  
the following test code that seems to work and handles any string  
or error I could think of. Am wondering if this is good or is  
there better/more efficient code?



";

$finalArray = array();
$finalString = "";
$exploded1 = explode($pStart, $pString); // makes array $exploded1

	for ($i=1; $iin array

{
$exploded2 = explode($pStop, $exploded1[$i]);
		array_push($finalArray, $exploded2[0]); // array of just the  
wanted sections

}
foreach ($finalArray as $value3)
{
		$finalString .= $value3 . " "; // " " ensures separation between  
substrings

}
	$finalString = trim($finalString); // trim any extra white space  
from beginning/end


echo $finalString;
echo "";
}

// TEST
$startTerm = "START";
$stopTerm = "STOP";

// test typical string
	$theString = "one two START three four STOP five six START seven  
eight STOP nine ten";
	contentString($theString, $startTerm, $stopTerm); // outputs  
"three four seven eight"

// test string with immediate START
	$theString = "START one two STOP three four START five six STOP  
seven eight START nine ten";
	contentString($theString, $startTerm, $stopTerm); // outputs "one  
two five six nine ten"

// test string with "error" (2 STARTS)
	$theString = "START one two START three four STOP five six START  
seven eight STOP nine ten";
	contentString($theString, $startTerm, $stopTerm); // outputs "one  
two three four seven eight"

// test string with no space between separators and real content
	$theString = "STARTone twoSTOP three four STARTfive sixSTOP seven  
eight STARTnine ten";
	contentString($theString, $startTerm, $stopTerm); // outputs "one  
two five six nine ten"


?>

Any thoughts/suggestions? Thanks!

George



Ash
www.ashleysheridan.co.uk



George Langley
Multimedia Developer, Audio/Video Editor, Musician, Arranger, Composer

http://www.georgelangley.ca


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



Re: [PHP] Limit Local Search to Content

2009-03-26 Thread Ashley Sheridan
What about storing all of the page content in the database to start
with, then searching with a mysql statement is a breeze!

On Thu, 2009-03-26 at 16:29 -0600, George Langley wrote:
> - Original Message -
> > From: Stuart 
> > > You can't have any extra info in a closing HTML tag. This 
> > > problem is
> > > usually handled using comments. Something like the following...
> > > 
> > > 
> > > 
> > > sofihsod hiosdh sdh gus us u sg
> > > 
> > > 
> > > 
> > > You then just start with you see the begin comment and stop 
> > when you
> > > hit the end comment.
> > -
>   Hmm, they are stripping out the tags before looking at the words, so 
> didn't work quite as I originally thought.
>   The solution seems to be to explode the string based on the entire 
> comment before doing the word-by-word storing. I wrote up the following test 
> code that seems to work and handles any string or error I could think of. Am 
> wondering if this is good or is there better/more efficient code?
> 
> 
>  
> function contentString($pString, $pStart, $pStop){
>   echo "$pString";
>   
>   $finalArray = array();
>   $finalString = "";
>   $exploded1 = explode($pStart, $pString); // makes array $exploded1
>   
>   for ($i=1; $i   {
>   $exploded2 = explode($pStop, $exploded1[$i]);
>   array_push($finalArray, $exploded2[0]); // array of just the 
> wanted sections
>   }
>   foreach ($finalArray as $value3)
>   {
>   $finalString .= $value3 . " "; // " " ensures separation 
> between substrings
>   }
>   $finalString = trim($finalString); // trim any extra white space from 
> beginning/end
>
>   echo $finalString;
>   echo "";
> }
> 
> // TEST
>   $startTerm = "START";
>   $stopTerm = "STOP";
>   
>   // test typical string
>   $theString = "one two START three four STOP five six START seven eight 
> STOP nine ten";
>   contentString($theString, $startTerm, $stopTerm); // outputs "three 
> four seven eight"
>   // test string with immediate START
>   $theString = "START one two STOP three four START five six STOP seven 
> eight START nine ten";
>   contentString($theString, $startTerm, $stopTerm); // outputs "one two 
> five six nine ten"
>   // test string with "error" (2 STARTS)
>   $theString = "START one two START three four STOP five six START seven 
> eight STOP nine ten";
>   contentString($theString, $startTerm, $stopTerm); // outputs "one two 
> three four seven eight"
>   // test string with no space between separators and real content
>   $theString = "STARTone twoSTOP three four STARTfive sixSTOP seven eight 
> STARTnine ten";
>   contentString($theString, $startTerm, $stopTerm); // outputs "one two 
> five six nine ten"
>   
> ?>
> 
> Any thoughts/suggestions? Thanks!
> 
> George


Ash
www.ashleysheridan.co.uk


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



Re: [PHP] Limit Local Search to Content

2009-03-26 Thread George Langley
- Original Message -
> From: Stuart 
> > You can't have any extra info in a closing HTML tag. This 
> > problem is
> > usually handled using comments. Something like the following...
> > 
> > 
> > 
> > sofihsod hiosdh sdh gus us u sg
> > 
> > 
> > 
> > You then just start with you see the begin comment and stop 
> when you
> > hit the end comment.
> -
Hmm, they are stripping out the tags before looking at the words, so 
didn't work quite as I originally thought.
The solution seems to be to explode the string based on the entire 
comment before doing the word-by-word storing. I wrote up the following test 
code that seems to work and handles any string or error I could think of. Am 
wondering if this is good or is there better/more efficient code?


";

$finalArray = array();
$finalString = "";
$exploded1 = explode($pStart, $pString); // makes array $exploded1

for ($i=1; $i";
}

// TEST
$startTerm = "START";
$stopTerm = "STOP";

// test typical string
$theString = "one two START three four STOP five six START seven eight 
STOP nine ten";
contentString($theString, $startTerm, $stopTerm); // outputs "three 
four seven eight"
// test string with immediate START
$theString = "START one two STOP three four START five six STOP seven 
eight START nine ten";
contentString($theString, $startTerm, $stopTerm); // outputs "one two 
five six nine ten"
// test string with "error" (2 STARTS)
$theString = "START one two START three four STOP five six START seven 
eight STOP nine ten";
contentString($theString, $startTerm, $stopTerm); // outputs "one two 
three four seven eight"
// test string with no space between separators and real content
$theString = "STARTone twoSTOP three four STARTfive sixSTOP seven eight 
STARTnine ten";
contentString($theString, $startTerm, $stopTerm); // outputs "one two 
five six nine ten"

?>

Any thoughts/suggestions? Thanks!

George


Re: [PHP] Limit Local Search to Content

2009-03-26 Thread George Langley
> 2009/3/26 George Langley :
> > How do I STOP it? Is it permissible to add the id again in the 
> closing div tag ie .
>

From: Stuart 
> You can't have any extra info in a closing HTML tag. This 
> problem is
> usually handled using comments. Something like the following...
> 
> 
> 
> sofihsod hiosdh sdh gus us u sg
> 
> 
> 
> You then just start with you see the begin comment and stop when you
> hit the end comment.
-
Thanks! Will use a unique word like  to make 
sure is located and not accidentally found within the content.

George


Re: [PHP] Limit Local Search to Content

2009-03-26 Thread Stuart
2009/3/26 George Langley :
>        Hi all! Am building a Search feature following the excellent tutorial 
> at:
>
> 
>
> It loops through a page and stores the words found in a mySQL database.
>        I have about 60 pages, and all of them share a number of common items 
> like header, menu, footer, etc. These get added as includes. The result is 
> that every page gets marked as having "Contact Us", "Terms of Use" or any 
> other item in the menu, footer, etc. I would like to limit the word list to 
> items found just in the page's unique content.
>        I do have a div with an id of "divContent" for the actual content. So 
> I could add an if statement to only start storing words found after the word 
> "divContent" has been found. But, my question is:
>
> How do I STOP it? Is it permissible to add the id again in the closing div 
> tag ie .
>
>        If this is allowed, I could keep an eye out for that id again and stop 
> it when found a second time, so that my list doesn't include items in the 
> footer (which again is common to all 60 pages) or any other items outside of 
> the content section. Or is there a better way to trigger the recording of 
> words on/off? Thanks!

You can't have any extra info in a closing HTML tag. This problem is
usually handled using comments. Something like the following...



sofihsod hiosdh sdh gus us u sg



You then just start with you see the begin comment and stop when you
hit the end comment.

-Stuart

-- 
http://stut.net/

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



[PHP] Limit Local Search to Content

2009-03-26 Thread George Langley
Hi all! Am building a Search feature following the excellent tutorial 
at:



It loops through a page and stores the words found in a mySQL database.
I have about 60 pages, and all of them share a number of common items 
like header, menu, footer, etc. These get added as includes. The result is that 
every page gets marked as having "Contact Us", "Terms of Use" or any other item 
in the menu, footer, etc. I would like to limit the word list to items found 
just in the page's unique content.
I do have a div with an id of "divContent" for the actual content. So I 
could add an if statement to only start storing words found after the word 
"divContent" has been found. But, my question is:

How do I STOP it? Is it permissible to add the id again in the closing div tag 
ie .

If this is allowed, I could keep an eye out for that id again and stop 
it when found a second time, so that my list doesn't include items in the 
footer (which again is common to all 60 pages) or any other items outside of 
the content section. Or is there a better way to trigger the recording of words 
on/off? Thanks!


George Langley    Multimedia Developer    Audio/Video Editor    Musician, 
Arranger, Composer www.georgelangley.ca




Re: [PHP] limit mail() function

2008-04-09 Thread Jordi Moles

hi,

thanks for all your opinions and suggestions, i'll have a look at all of 
them to see if i can implement a restricted system for mail() functions.


I'll report back in a few days to let you know if i've come up with 
something that really works.


Thanks for all.

En/na Andrew Ballard ha escrit:

On Tue, Apr 8, 2008 at 3:51 PM, Greg Bowser <[EMAIL PROTECTED]> wrote:
  

 >postfix has rate-limitation facilities you can use for this

 I'm aware of several configuration directives that limit rate, none of
 which directly limit the send rate local users.  Perhaps some kludgly
 or elusive trick involving multiple options would do the trick; I
 don't claim to be a postfix expert.  Perhaps, instead of making empty
 statements, you might choose to enlighten me as per the exact
 configuration that will accomplish this.

 Of course, I spent some time googling, but it appears that not too
 many people know (or at least write about) how to implement such
 functionality.



Not being a sysadmin I can't tell you HOW to do it, but I can tell you
that nearly every shared-hosting service I have worked with implements
some level of throttling such that an account on that machine cannot
send more than some set number of messages per hour whether directly
through local SMTP or through sendmail, mail(), etc., so I know it CAN
be done, and it appears that more than a few people know how to do it.

Andrew

  



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



Re: [PHP] limit mail() function

2008-04-08 Thread Andrew Ballard
On Tue, Apr 8, 2008 at 3:51 PM, Greg Bowser <[EMAIL PROTECTED]> wrote:
>  >postfix has rate-limitation facilities you can use for this
>
>  I'm aware of several configuration directives that limit rate, none of
>  which directly limit the send rate local users.  Perhaps some kludgly
>  or elusive trick involving multiple options would do the trick; I
>  don't claim to be a postfix expert.  Perhaps, instead of making empty
>  statements, you might choose to enlighten me as per the exact
>  configuration that will accomplish this.
>
>  Of course, I spent some time googling, but it appears that not too
>  many people know (or at least write about) how to implement such
>  functionality.

Not being a sysadmin I can't tell you HOW to do it, but I can tell you
that nearly every shared-hosting service I have worked with implements
some level of throttling such that an account on that machine cannot
send more than some set number of messages per hour whether directly
through local SMTP or through sendmail, mail(), etc., so I know it CAN
be done, and it appears that more than a few people know how to do it.

Andrew

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



Re: [PHP] limit mail() function

2008-04-08 Thread Greg Bowser
>Pardon me, but that's one kludgy idea

Hence my use of the term hackish. But really, is isn't all that
kludgy.  An software solution that implements this natively would have
to keep track of the stats somehow; undoubtely via some sort of stats
file. So the real difference is that two processes are run, instead of
one.  Yet, by the same "wrapper" logic, is it not kludgy that php
invokes the sendmail binary, instead of using some sort of native php
implementation?  And again, by the same logic, the sendmail binary
that comes with many MTAs is simply a wrapper to allow normal sendmail
usage.


>postfix has rate-limitation facilities you can use for this

I'm aware of several configuration directives that limit rate, none of
which directly limit the send rate local users.  Perhaps some kludgly
or elusive trick involving multiple options would do the trick; I
don't claim to be a postfix expert.  Perhaps, instead of making empty
statements, you might choose to enlighten me as per the exact
configuration that will accomplish this.

Of course, I spent some time googling, but it appears that not too
many people know (or at least write about) how to implement such
functionality.  I did manage to find two interesting items in my
searches:

http://www.postfix.org/anvil.8.html
http://www.opennix.com/email/postfix/policy/ratelimit.html

The former doesn't appear to be magical, and from what my limited and
apparently klugdy thoughts permit me to deduce, it seems to bear,
conceptually, at least a degree (Celsius, mind you) of similarity to
the aforementioned kludgy statistics idea... I didn't find any
documentation regarding the implementation of anvil.  And the latter,
well that's not even a native postfix solution, so apparently, I have
failed to find the alleged rate-limitation.

All cynical, superficial, and sarcastic storming somewhat consummate,
I can at last take solace knowing that I would, had you _suggested_ a
better solution, or had I not, kludgy though it apparently was, put
some effort into finding a solution, pardoned you.

And with the sarcasm, sincerity, and cynicism now accomplished, permit
me to offer my most sincere apologies for the above rude, and overly
verbose post.

-- Greg

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



Re: [PHP] limit mail() function

2008-04-08 Thread Per Jessen
Greg Bowser wrote:

> I'm not sure how, or if there is a way to do this in postfix.  The
> mail() function calls the sendmail binary, so one sort of hackish way
> might be to move this binary and write a wrapper script that keeps
> track of per-user rate limits, and then invokes the real sendmail
> binary.  

Pardon me, but that's one kludgy idea - postfix has rate-limitation
facilities you can use for this. 


/Per Jessen, Zürich


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



Re: [PHP] limit mail() function

2008-04-08 Thread Greg Bowser
As far as I know, there's no way you can do this via PHP.

PHP doesn't "know" about users on the system.  Generally, PHP is run as an
apache module, and thus the scripts are run as the user apache is running
as.

So to start with, you'd probably need to be running a Fast CGI + SuExec
setup or something similar.

I'm not sure how, or if there is a way to do this in postfix.  The mail()
function calls the sendmail binary, so one sort of hackish way might be to
move this binary and write a wrapper script that keeps track of per-user
rate limits, and then invokes the real sendmail binary.  Of course, in this
case, you'd also probably want to make sure the real sendmail binary
couldn't be executed and that users could not write to the file that keeps
track of the rate-limit.

-- Greg

On Tue, Apr 8, 2008 at 12:37 PM, Jordi Moles <[EMAIL PROTECTED]> wrote:

> hello everyone,
>
> first of all... i'm sorry if this has been asked like a million times
> before... but i've been looking for info about this and found nothing so
> far.
>
> anyway
>
> I've got a server with apache2 and postfix and php5 providing hosting to
> some clients. I've got this big problem about clients sending spam
> massively, either consciously or because they website have been hacked. The
> main way to spam is by using the "mail()" function.
> So far, i've only found how to disable the use of the mail() function
> completely in the php.ini file, but it's not a really good option to me,
> cause i run some server scripts to check for some things and they send some
> mails when they find something wrong.
>
> So... i would like to know what options i have if i want to limit this
> function...
>
> can i disable the function only for some users?
> may be i can set a rate limit for it?
>
> thanks.
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP] limit mail() function

2008-04-08 Thread Per Jessen
Jordi Moles wrote:

> I've got a server with apache2 and postfix and php5 providing hosting
> to some clients. I've got this big problem about clients sending spam
> massively, either consciously or because they website have been
> hacked. The main way to spam is by using the "mail()" function.
> So far, i've only found how to disable the use of the mail() function
> completely in the php.ini file, but it's not a really good option to
> me, cause i run some server scripts to check for some things and they
> send some mails when they find something wrong.
> 
> So... i would like to know what options i have if i want to limit this
> function...
> 
> can i disable the function only for some users?
> may be i can set a rate limit for it?

Check your mail-server config - rate limits and such are probably best
done there.  


/Per Jessen, Zürich


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



[PHP] limit mail() function

2008-04-08 Thread Jordi Moles

hello everyone,

first of all... i'm sorry if this has been asked like a million times 
before... but i've been looking for info about this and found nothing so 
far.


anyway

I've got a server with apache2 and postfix and php5 providing hosting to 
some clients. I've got this big problem about clients sending spam 
massively, either consciously or because they website have been hacked. 
The main way to spam is by using the "mail()" function.
So far, i've only found how to disable the use of the mail() function 
completely in the php.ini file, but it's not a really good option to me, 
cause i run some server scripts to check for some things and they send 
some mails when they find something wrong.


So... i would like to know what options i have if i want to limit this 
function...


can i disable the function only for some users?
may be i can set a rate limit for it?

thanks.




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



Re: [PHP] Limit query results

2007-05-04 Thread Jim Lucas

Dan Shirah wrote:

 $result = mssql_query($sql) or die(mssql_error());
  // print_r ($result);
You realize that this will print the Resource ID# for the resource pointer, but not the actual 
result set.


--
Jim Lucas

   "Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them."

Unknown

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



Re: [PHP] Limit query results

2007-05-04 Thread Miguel J. Jiménez

Use "SELECT DISTINCT" in your SQL syntax.

--
Miguel J. Jiménez
Programador Senior
Área de Internet/XSL/PHP
[EMAIL PROTECTED]



ISOTROL
Edificio BLUENET, Avda. Isaac Newton nº3, 4ª planta.
Parque Tecnológico Cartuja '93, 41092 Sevilla.
Teléfono: 955 036 800 - Fax: 955 036 849
http://www.isotrol.com

"You let a political fight  come between you and your best friend you have in all 
the world. Do you realize how foolish that is? How ominous? How can this country survive 
if friends can't rise above the quarrel".
Constance Hazard, North & South (book I)


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

Re: [PHP] Limit query results

2007-05-04 Thread Zoltán Németh
SELECT DISTINCT?

greets
Zoltán Németh

2007. 05. 4, péntek keltezéssel 08.44-kor Dan Shirah ezt írta:
> Good Morning everyone.
> 
> In the below code I am pulling records from two tables.  the records are
> tied together by a common key in a 3rd table.  Everything works correctly
> down to the $result.
> 
> 
>  // Connect to the database
>   $connection = mssql_pconnect($host, $user, $pass) or die ('server
> connection failed');
>   $database = mssql_select_db("$database", $connection) or die ('DB
> selection failed');
>   // Query the table and load all of the records into an array.
>$sql = "SELECT
>  support_payment_request.credit_card_id,
>  support_payment_request.status_code,
>  criminal_payment_request.credit_card_id,
>  criminal_payment_request.status_code,
>  credit_card_payment_request.credit_card_id,
>  credit_card_payment_request.date_request_received
> FROM
>  credit_card_payment_request LEFT OUTER JOIN support_payment_request
> ON support_payment_request.credit_card_id =
> credit_card_payment_request.credit_card_id
>  LEFT OUTER JOIN criminal_payment_request
> ON criminal_payment_request.credit_card_id =
> credit_card_payment_request.credit_card_id
> WHERE support_payment_request.status_code = 'P'
> OR criminal_payment_request.status_code = 'P'";
> 
> // print_r ($sql);
>   $result = mssql_query($sql) or die(mssql_error());
>// print_r ($result);
>   $number_rows= mssql_num_rows($result);
> ?>
>  bordercolor='#00'>
>  if(!empty($result)) {
>  while ($row= mssql_fetch_array($result)) {
>   $id = $row['credit_card_id'];
>   $dateTime = $row['date_request_received'];
>   //print_r ($id);
> ?>
> 
>  align='center'>$id"
> ?>
>  align='center'>
>  align='center'>
>  align='center'>
>  align='center'>
> 
>   }
> }
> ?>
> 
> The picture below is what mu output looks like.  BUT, what I am trying to do
> is have only ONE row returned per ID regardless of however many records may
> be associated with that ID.   Below record number 122 has three results, I
> only want one row for record 122 to be displayed.
> 
> Any ideas?
> 
> 
>2 
>  Oct 6 2010 12:00AM
>  To Be Processed
>  Payment Type
>  Last Processed By
>  46 
>  Feb 23 2007 2:27PM
>  To Be Processed
>  Payment Type
>  Last Processed By
>  66 
>  Feb 26 2007 3:16PM
>  To Be Processed
>  Payment Type
>  Last Processed By
>  68 
>  Feb 26 2007 3:39PM
>  To Be Processed
>  Payment Type
>  Last Processed By
>  76 
>  Mar 21 2007 7:36AM
>  To Be Processed
>  Payment Type
>  Last Processed By
>  77 
>  Mar 21 2007 7:40AM
>  To Be Processed
>  Payment Type
>  Last Processed By
>  78 
>  Mar 21 2007 7:40AM
>  To Be Processed
>  Payment Type
>  Last Processed By
>  79 
>  Mar 21 2007 7:41AM
>  To Be Processed
>  Payment Type
>  Last Processed By
>  122 
>  Mar 27 2007 5:29PM
>  To Be Processed
>  Payment Type
>  Last Processed By
>  122 
>  Mar 27 2007 5:29PM
>  To Be Processed
>  Payment Type
>  Last Processed By
>  122 
>  Mar 27 2007 5:29PM
>  To Be Processed
>  Payment Type
>  Last Processed By

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



Re: [PHP] Limit query results

2007-05-04 Thread Fredrik Thunberg

"GROUP BY whatever_id_you_want" in the SQL

Dan Shirah skrev:

Good Morning everyone.

In the below code I am pulling records from two tables.  the records are
tied together by a common key in a 3rd table.  Everything works correctly
down to the $result.


// Connect to the database
 $connection = mssql_pconnect($host, $user, $pass) or die ('server
connection failed');
 $database = mssql_select_db("$database", $connection) or die ('DB
selection failed');
 // Query the table and load all of the records into an array.
  $sql = "SELECT
support_payment_request.credit_card_id,
support_payment_request.status_code,
criminal_payment_request.credit_card_id,
criminal_payment_request.status_code,
credit_card_payment_request.credit_card_id,
credit_card_payment_request.date_request_received
   FROM
credit_card_payment_request LEFT OUTER JOIN support_payment_request
   ON support_payment_request.credit_card_id =
credit_card_payment_request.credit_card_id
LEFT OUTER JOIN criminal_payment_request
   ON criminal_payment_request.credit_card_id =
credit_card_payment_request.credit_card_id
   WHERE support_payment_request.status_code = 'P'
   OR criminal_payment_request.status_code = 'P'";

   // print_r ($sql);
 $result = mssql_query($sql) or die(mssql_error());
  // print_r ($result);
 $number_rows= mssql_num_rows($result);
?>
cellspacing='2'

bordercolor='#00'>


$id"
?>







The picture below is what mu output looks like.  BUT, what I am trying 
to do

is have only ONE row returned per ID regardless of however many records may
be associated with that ID.   Below record number 122 has three results, I
only want one row for record 122 to be displayed.

Any ideas?


  2 
Oct 6 2010 12:00AM
To Be Processed
Payment Type
Last Processed By
46 
Feb 23 2007 2:27PM
To Be Processed
Payment Type
Last Processed By
66 
Feb 26 2007 3:16PM
To Be Processed
Payment Type
Last Processed By
68 
Feb 26 2007 3:39PM
To Be Processed
Payment Type
Last Processed By
76 
Mar 21 2007 7:36AM
To Be Processed
Payment Type
Last Processed By
77 
Mar 21 2007 7:40AM
To Be Processed
Payment Type
Last Processed By
78 
Mar 21 2007 7:40AM
To Be Processed
Payment Type
Last Processed By
79 
Mar 21 2007 7:41AM
To Be Processed
Payment Type
Last Processed By
122 
Mar 27 2007 5:29PM
To Be Processed
Payment Type
Last Processed By
122 
Mar 27 2007 5:29PM
To Be Processed
Payment Type
Last Processed By
122 
Mar 27 2007 5:29PM
To Be Processed
Payment Type
Last Processed By



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



[PHP] Limit query results

2007-05-04 Thread Dan Shirah

Good Morning everyone.

In the below code I am pulling records from two tables.  the records are
tied together by a common key in a 3rd table.  Everything works correctly
down to the $result.


// Connect to the database
 $connection = mssql_pconnect($host, $user, $pass) or die ('server
connection failed');
 $database = mssql_select_db("$database", $connection) or die ('DB
selection failed');
 // Query the table and load all of the records into an array.
  $sql = "SELECT
support_payment_request.credit_card_id,
support_payment_request.status_code,
criminal_payment_request.credit_card_id,
criminal_payment_request.status_code,
credit_card_payment_request.credit_card_id,
credit_card_payment_request.date_request_received
   FROM
credit_card_payment_request LEFT OUTER JOIN support_payment_request
   ON support_payment_request.credit_card_id =
credit_card_payment_request.credit_card_id
LEFT OUTER JOIN criminal_payment_request
   ON criminal_payment_request.credit_card_id =
credit_card_payment_request.credit_card_id
   WHERE support_payment_request.status_code = 'P'
   OR criminal_payment_request.status_code = 'P'";

   // print_r ($sql);
 $result = mssql_query($sql) or die(mssql_error());
  // print_r ($result);
 $number_rows= mssql_num_rows($result);
?>



$id"
?>







The picture below is what mu output looks like.  BUT, what I am trying to do
is have only ONE row returned per ID regardless of however many records may
be associated with that ID.   Below record number 122 has three results, I
only want one row for record 122 to be displayed.

Any ideas?


  2 
Oct 6 2010 12:00AM
To Be Processed
Payment Type
Last Processed By
46 
Feb 23 2007 2:27PM
To Be Processed
Payment Type
Last Processed By
66 
Feb 26 2007 3:16PM
To Be Processed
Payment Type
Last Processed By
68 
Feb 26 2007 3:39PM
To Be Processed
Payment Type
Last Processed By
76 
Mar 21 2007 7:36AM
To Be Processed
Payment Type
Last Processed By
77 
Mar 21 2007 7:40AM
To Be Processed
Payment Type
Last Processed By
78 
Mar 21 2007 7:40AM
To Be Processed
Payment Type
Last Processed By
79 
Mar 21 2007 7:41AM
To Be Processed
Payment Type
Last Processed By
122 
Mar 27 2007 5:29PM
To Be Processed
Payment Type
Last Processed By
122 
Mar 27 2007 5:29PM
To Be Processed
Payment Type
Last Processed By
122 
Mar 27 2007 5:29PM
To Be Processed
Payment Type
Last Processed By


[PHP] limit on the mail function

2006-02-13 Thread spamdetect

Hello!

I would like to know whether some limits on the mail function
could be set.

We host a lot of virtual hosts and some of our users send a lot
of messages by the mail() function. However I would like to 
implement a limit such as max. 512 emails per virtualhost per hour.

Is it possible with PHP mail()?

Thanks for any help.

Janos Suto

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



Re: [PHP] LIMIT?

2006-02-06 Thread John Nichel

Chris wrote:

Hi,

Just because it supports the keyword 'limit' doesn't mean much.

mysql does:
select * from table limit x,y;

postgresql does:
select * from table limit y offset x;

different syntax.


Because it makes the thread harder to read.

Why is top posting bad?

Anywho, A) I said that "Considering that the OP mentioned using the 
LIMIT command in his original post, it's probably safe to say that his 
db supports it."  Which means quite a bit; his db supports it.  B) Let's 
once again look at the OP's post, follow the thread, and use our problem 
solving skills: "SELECT *  FROM `x_news` LIMIT 0 , 15".  Hmmm, can we 
tell what syntax that follows?



John Nichel wrote:

James Kaufman wrote:


On Mon, Feb 06, 2006 at 05:08:59PM +0200, Andrei wrote:

You can use SELECT fields FROM table WHERE condition LIMIT 15, -1 
and it will select all from 15...


Andy

William Stokes wrote:


Hello

I have a news page which is getting quite long now and I would like 
to split the news to two pages. Now I have one SQL query for all 
the rows and I think I could use LIMIT to limit the results but how 
to limit the results for example to 15 rows for page one and from 
16 to the last on second page? Number of rows increase daily.


One page one there's headline and short summary and the second page 
should be "archive" with only the headline so all remaining rows 
can be printed to one page.


Something like: "SELECT *  FROM `x_news` LIMIT 0 , 15" but how to 
do the archive page SELECT * FROM `x_news` LIMIT 16 , xx?


Thanks
-Will






Answers that show SQL commands that apply to specific databases annoy
me. Not everyone uses MySQL. I've worked with several databases that
don't support a LIMIT command. At least mention the database engine
you are referencing.



Considering that the OP mentioned using the LIMIT command in his 
original post, it's probably safe to say that his db supports it.  At 
least follow the thread.







--
By-Tor.com
...it's all about the Rush
http://www.by-tor.com

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



Re: [PHP] LIMIT?

2006-02-06 Thread Chris

Hi,

Just because it supports the keyword 'limit' doesn't mean much.

mysql does:
select * from table limit x,y;

postgresql does:
select * from table limit y offset x;

different syntax.


John Nichel wrote:

James Kaufman wrote:


On Mon, Feb 06, 2006 at 05:08:59PM +0200, Andrei wrote:

You can use SELECT fields FROM table WHERE condition LIMIT 15, -1 and 
it will select all from 15...


Andy

William Stokes wrote:


Hello

I have a news page which is getting quite long now and I would like 
to split the news to two pages. Now I have one SQL query for all the 
rows and I think I could use LIMIT to limit the results but how to 
limit the results for example to 15 rows for page one and from 16 to 
the last on second page? Number of rows increase daily.


One page one there's headline and short summary and the second page 
should be "archive" with only the headline so all remaining rows can 
be printed to one page.


Something like: "SELECT *  FROM `x_news` LIMIT 0 , 15" but how to do 
the archive page SELECT * FROM `x_news` LIMIT 16 , xx?


Thanks
-Will






Answers that show SQL commands that apply to specific databases annoy
me. Not everyone uses MySQL. I've worked with several databases that
don't support a LIMIT command. At least mention the database engine
you are referencing.



Considering that the OP mentioned using the LIMIT command in his 
original post, it's probably safe to say that his db supports it.  At 
least follow the thread.




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



Re: [PHP] LIMIT?

2006-02-06 Thread Joe Henry


On Feb 6, 2006, at 12:11 PM, James Kaufman wrote:

Answers that show SQL commands that apply to specific databases annoy
me. Not everyone uses MySQL. I've worked with several databases that
don't support a LIMIT command. At least mention the database engine
you are referencing.


Response like this annoy me.



A liberal is someone too poor to be a capitalist and too rich to be
a communist.


Oh, that explains a lot.

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



Re: [PHP] LIMIT?

2006-02-06 Thread John Nichel

James Kaufman wrote:

On Mon, Feb 06, 2006 at 05:08:59PM +0200, Andrei wrote:

You can use SELECT fields FROM table WHERE condition LIMIT 15, -1 and it 
will select all from 15...


Andy

William Stokes wrote:


Hello

I have a news page which is getting quite long now and I would like to 
split the news to two pages. Now I have one SQL query for all the rows and 
I think I could use LIMIT to limit the results but how to limit the 
results for example to 15 rows for page one and from 16 to the last on 
second page? Number of rows increase daily.


One page one there's headline and short summary and the second page should 
be "archive" with only the headline so all remaining rows can be printed 
to one page.


Something like: "SELECT *  FROM `x_news` LIMIT 0 , 15" but how to do the 
archive page SELECT * FROM `x_news` LIMIT 16 , xx?


Thanks
-Will






Answers that show SQL commands that apply to specific databases annoy
me. Not everyone uses MySQL. I've worked with several databases that
don't support a LIMIT command. At least mention the database engine
you are referencing.



Considering that the OP mentioned using the LIMIT command in his 
original post, it's probably safe to say that his db supports it.  At 
least follow the thread.


--
John C. Nichel IV
Programmer/System Admin (ÜberGeek)
Dot Com Holdings of Buffalo
716.856.9675
[EMAIL PROTECTED]

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



Re: [PHP] LIMIT?

2006-02-06 Thread James Kaufman
On Mon, Feb 06, 2006 at 05:08:59PM +0200, Andrei wrote:
> 
> You can use SELECT fields FROM table WHERE condition LIMIT 15, -1 and it 
> will select all from 15...
> 
>   Andy
> 
> William Stokes wrote:
> >Hello
> >
> >I have a news page which is getting quite long now and I would like to 
> >split the news to two pages. Now I have one SQL query for all the rows and 
> >I think I could use LIMIT to limit the results but how to limit the 
> >results for example to 15 rows for page one and from 16 to the last on 
> >second page? Number of rows increase daily.
> >
> >One page one there's headline and short summary and the second page should 
> >be "archive" with only the headline so all remaining rows can be printed 
> >to one page.
> >
> >Something like: "SELECT *  FROM `x_news` LIMIT 0 , 15" but how to do the 
> >archive page SELECT * FROM `x_news` LIMIT 16 , xx?
> >
> >Thanks
> >-Will
> > 
> >
> 

Answers that show SQL commands that apply to specific databases annoy
me. Not everyone uses MySQL. I've worked with several databases that
don't support a LIMIT command. At least mention the database engine
you are referencing.

-- 
Jim Kaufman
Linux Evangelist
public key 0x6D802619
CCNA, CISSP# 65668
---
A liberal is someone too poor to be a capitalist and too rich to be
a communist.

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



Re: [PHP] LIMIT?

2006-02-06 Thread Andrei


You can use SELECT fields FROM table WHERE condition LIMIT 15, -1 and it 
will select all from 15...


Andy

William Stokes wrote:

Hello

I have a news page which is getting quite long now and I would like to split 
the news to two pages. Now I have one SQL query for all the rows and I think 
I could use LIMIT to limit the results but how to limit the results for 
example to 15 rows for page one and from 16 to the last on second page? 
Number of rows increase daily.


One page one there's headline and short summary and the second page should 
be "archive" with only the headline so all remaining rows can be printed to 
one page.


Something like: "SELECT *  FROM `x_news` LIMIT 0 , 15" but how to do the 
archive page SELECT * FROM `x_news` LIMIT 16 , xx?


Thanks
-Will
 



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



RE: [PHP] LIMIT?

2006-02-06 Thread Albert
William Stokes wrote:
> One page one there's headline and short summary and the second page should

> be "archive" with only the headline so all remaining rows can be printed 
> to one page.
>
> Something like: "SELECT *  FROM `x_news` LIMIT 0 , 15" but how to do the 
> archive page SELECT * FROM `x_news` LIMIT 16 , xx?

I've scanned the MySQL Reference Manual (for up to Version 5.0.4-beta) and:

"
To retrieve all rows from a certain offset up to the end of the result set,
you can use some large number for the second parameter. This statement
retrieves all rows from the 96th row to the last: 

mysql> SELECT * FROM table LIMIT 95,18446744073709551615;
"

HTH

Albert

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.375 / Virus Database: 267.15.2/251 - Release Date: 2006/02/04
 

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



Re: [PHP] LIMIT?

2006-02-06 Thread Larry E. Ullman
I have a news page which is getting quite long now and I would like  
to split
the news to two pages. Now I have one SQL query for all the rows  
and I think
I could use LIMIT to limit the results but how to limit the results  
for
example to 15 rows for page one and from 16 to the last on second  
page?

Number of rows increase daily.

One page one there's headline and short summary and the second page  
should
be "archive" with only the headline so all remaining rows can be  
printed to

one page.

Something like: "SELECT *  FROM `x_news` LIMIT 0 , 15" but how to  
do the

archive page SELECT * FROM `x_news` LIMIT 16 , xx?


What you're describing is called "pagination". There are examples  
online. Basically you just need to pass to the second (and other)  
pages the LIMIT values (16 and xx above).


Larry

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



[PHP] LIMIT?

2006-02-06 Thread William Stokes
Hello

I have a news page which is getting quite long now and I would like to split 
the news to two pages. Now I have one SQL query for all the rows and I think 
I could use LIMIT to limit the results but how to limit the results for 
example to 15 rows for page one and from 16 to the last on second page? 
Number of rows increase daily.

One page one there's headline and short summary and the second page should 
be "archive" with only the headline so all remaining rows can be printed to 
one page.

Something like: "SELECT *  FROM `x_news` LIMIT 0 , 15" but how to do the 
archive page SELECT * FROM `x_news` LIMIT 16 , xx?

Thanks
-Will
 

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



Fw: [PHP] Limit - nr of sessions on a domain?

2005-09-08 Thread Gustav Wiberg
- Original Message - 
From: "Gustav Wiberg" <[EMAIL PROTECTED]>

To: "PHP General" 
Sent: Thursday, September 08, 2005 11:36 PM
Subject: [PHP] Limit - nr of sessions on a domain?



Hi there!

I'm trying to set 30 diffrent cookies on a domain, but it seems that a 
cookie sets to zero and there is a max of 18 or 19 cookies... Can this be 
right?


This is an output of my cookievalues... But the problem is that i want a 
larger array. Isn't this possible?


Array ( [1] => voted [17] => voted [19] => voted [22] => voted [24] => voted 
[25] => voted [26] => voted [PHPSESSID] => 7d5917c49d7e0fba693f5a122c7851a4 
[2] => voted [3] => voted [6] => voted [7] => voted [8] => voted [9] => 
voted [10] => voted [11] => voted [13] => voted [12] => voted [14] => voted 
[15] => voted )


Array ( [17] => voted [19] => voted [22] => voted [24] => voted [25] => 
voted [26] => voted [PHPSESSID] => 7d5917c49d7e0fba693f5a122c7851a4 [2] => 
voted [3] => voted [6] => voted [7] => voted [8] => voted [9] => voted [10] 
=> voted [11] => voted [13] => voted [12] => voted [14] => voted [15] => 
voted [18] => voted )


Array ( [19] => voted [22] => voted [24] => voted [25] => voted [26] => 
voted [PHPSESSID] => 7d5917c49d7e0fba693f5a122c7851a4 [2] => voted [3] => 
voted [6] => voted [7] => voted [8] => voted [9] => voted [10] => voted [11] 
=> voted [13] => voted [12] => voted [14] => voted [15] => voted [18] => 
voted [20] => voted )





/G
http://www.varupiraten.se/

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



--
No virus found in this incoming message.
Checked by AVG Anti-Virus.
Version: 7.0.344 / Virus Database: 267.10.19/92 - Release Date: 2005-09-07




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



[PHP] Limit - nr of sessions on a domain?

2005-09-08 Thread Gustav Wiberg

Hi there!

I'm trying to set 30 diffrent cookies on a domain, but it seems that a 
cookie sets to zero and there is a max of 18 or 19 cookies... Can this be 
right?


/G
http://www.varupiraten.se/

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



Re: [PHP] Limit emails from servers & recommend a control panel (most prolly 0T)

2005-08-01 Thread Jochem Maas

Edward Vermillion wrote:

Ryan A wrote:


Hey,



'prolly' is not a member of the english language.
and yes it's completely off topic but you knew that...




Yep, I prolly did :-)

Should have taken out the "most prolly" and just had OT, my apoligies.

Cheers,
Ryan

P.S Join me in my campaign to get "PROLLY" as a member of the
English langauge...

If enough people use it, it will prolly get into the dictionary in a few
years.


the Oxford English Dictionary is very forthcoming liek I believe, you are 
probably correct.
heck just ask Lewis Carol - he invented quite a lot of words in his books that 
became
official.

but I don't like 'prolly' so I have to pass on your offer :-)



:-D


Here in Texas it's already there... :D


please 'explainify' ;-/

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



Re: [PHP] Limit emails from servers & recommend a control panel (most prolly 0T)

2005-08-01 Thread Dotan Cohen
On 8/1/05, Ryan A <[EMAIL PROTECTED]> wrote:
> > > P.S Join me in my campaign to get "PROLLY" as a member of the
> > > English langauge...
> > >
> > > If enough people use it, it will prolly get into the dictionary in a few
> > > years.
> > >
> > > :-D
> > >
> > Here in Texas it's
> > already there... :D
> 
> 
> Good! That means my works already done there :-p
> 


And in a lot of other places! Google found about 762,000 of them...
And my name shows up in 21 of those... I should move to Texas.

Dotan
http://lyricslist.com

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



Re: [PHP] Limit emails from servers & recommend a control panel (most prolly 0T)

2005-08-01 Thread Ryan A
> > P.S Join me in my campaign to get "PROLLY" as a member of the
> > English langauge...
> >
> > If enough people use it, it will prolly get into the dictionary in a few
> > years.
> >
> > :-D
> >
> Here in Texas it's
> already there... :D


Good! That means my works already done there :-p

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



RE: [PHP] Limit emails from servers & recommend a control panel O T

2005-08-01 Thread Ryan A

> [/snip]
> P.S Join me in my campaign to get "PROLLY" as a member of the
> English langauge...
> 
> If enough people use it, it will prolly get into the dictionary in a few
> years.
> [snip]
> 
> I ceriusly dowt it.


Hahahahah good one 

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



Re: [PHP] Limit emails from servers & recommend a control panel (most prolly 0T)

2005-08-01 Thread Edward Vermillion

Ryan A wrote:

Hey,



'prolly' is not a member of the english language.
and yes it's completely off topic but you knew that...



Yep, I prolly did :-)

Should have taken out the "most prolly" and just had OT, my apoligies.

Cheers,
Ryan

P.S Join me in my campaign to get "PROLLY" as a member of the
English langauge...

If enough people use it, it will prolly get into the dictionary in a few
years.

:-D


Here in Texas it's already there... :D

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



RE: [PHP] Limit emails from servers & recommend a control panel O T

2005-08-01 Thread Jay Blanchard
[/snip]
P.S Join me in my campaign to get "PROLLY" as a member of the
English langauge...

If enough people use it, it will prolly get into the dictionary in a few
years.
[snip]

I ceriusly dowt it.

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



Re: [PHP] Limit emails from servers & recommend a control panel (most prolly 0T)

2005-08-01 Thread Ryan A
Hey,

> 'prolly' is not a member of the english language.
> and yes it's completely off topic but you knew that...

Yep, I prolly did :-)

Should have taken out the "most prolly" and just had OT, my apoligies.

Cheers,
Ryan

P.S Join me in my campaign to get "PROLLY" as a member of the
English langauge...

If enough people use it, it will prolly get into the dictionary in a few
years.

:-D

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



Re: [PHP] Limit emails from servers & recommend a control panel (most prolly 0T)

2005-08-01 Thread Jochem Maas

'prolly' is not a member of the english language.
and yes it's completely off topic but you knew that...



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



[PHP] Limit emails from servers & recommend a control panel (most prolly 0T)

2005-08-01 Thread Ryan A
Hi,
A client of mine wants to offer freehosting to tech companies in Sweden.
(He plans to take a dedicated *unix server)

1)
The main problem with offering hosting is there are some SOBs who will
use that account to spam, so he asked me if it is possible to limit the
amount
of emails from each account?

eg:
Max 1 email every 10 or 20 seconds from each account

by doing this it would be easier to shut down the spamming account before
any real damage is done and it also wont be too attractive to spammers to
host with him.

Any ideas how this can be done?


2)
 The server will be given to us without any control panel, cpanel costs a
bit
every month, can anyone recommend a good control panel that is free and
would
give us control to offer hosting to others (eg Plesk/WHM)

Thanks,
Ryan

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



Re: [PHP] Limit iterations on a foreach loop?

2005-02-11 Thread Robby Russell
On Thu, 2005-02-10 at 15:58 -0800, Brian Dunning wrote:
> I'm using an RSS feed that has WAY too much content, I only want the 
> first 10. I'm outputting the array with a foreach loop: is there a way 
> to limit it to only go through the first 10?
> 
> Thanks,
> 
> - Brian
> 

Is this data coming from a database? If so, just set a limit at the end
of your query...

example: SELECT * FROM blog ORDER BY id DESC LIMIT 10;

..will return the latest 10 entries.

-Robby

-- 
/***
* Robby Russell | Owner.Developer.Geek
* PLANET ARGON  | www.planetargon.com
* Portland, OR  | [EMAIL PROTECTED]
* 503.351.4730  | blog.planetargon.com
* PHP/PostgreSQL Hosting & Development
* --- Now hosting Ruby on Rails Apps ---
/

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



Re: [PHP] Limit iterations on a foreach loop?

2005-02-11 Thread Alex Hogan
> I'm using an RSS feed that has WAY too much content, I only want the
> first 10. I'm outputting the array with a foreach loop: is there a way
> to limit it to only go through the first 10?

foreach($var as $newvar){
if($count <= 10){
// Do something here
}
else{
break;
}
}

alex hogan

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



Re: [PHP] Limit iterations on a foreach loop?

2005-02-11 Thread Greg Donald
On Thu, 10 Feb 2005 15:58:28 -0800, Brian Dunning
<[EMAIL PROTECTED]> wrote:
> I'm using an RSS feed that has WAY too much content, I only want the
> first 10. I'm outputting the array with a foreach loop: is there a way
> to limit it to only go through the first 10?

Use a counter variable and break.

php.net/break


-- 
Greg Donald
Zend Certified Engineer
http://destiney.com/

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



[PHP] Limit iterations on a foreach loop?

2005-02-11 Thread Brian Dunning
I'm using an RSS feed that has WAY too much content, I only want the 
first 10. I'm outputting the array with a foreach loop: is there a way 
to limit it to only go through the first 10?

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


Re: [PHP] LIMIT with MSSQL

2005-01-26 Thread Richard Lynch
Zouari Fourat wrote:
> Is there anybody who succed in doing per/page listing from a MS SQL Server
> db.

Sure.

> knowing that mssql doesnt support LIMIT like mysql and it uses TOP.

Ain't never heard of TOP...

But start reading the MS SQL manual about "cursors" to get efficient paging.

-- 
Like Music?
http://l-i-e.com/artists.htm

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



[PHP] LIMIT with MSSQL

2005-01-26 Thread Zouari Fourat
Hello
Is there anybody who succed in doing per/page listing from a MS SQL Server db.
knowing that mssql doesnt support LIMIT like mysql and it uses TOP.
i didnt find an optimized way to make a per/page script.

Here's what am doing know :

to replace a MySQL "SELECT FROM  LIMIT $x,$y"
i did this with MSSQL :

:1  $query = "SELECT FROM "; //Without limit
:2  $ligne = fetch_assoc(query_bd($query));
:3  $temp = Array();
:4  for ($i=$debut;$i<($x+$y);$i++) {
:5  if (isset($ligne[$i]))
:6  $temp[] = $ligne[$i];
:7  }
:8  $ligne = $temp;

am loosing time between lines 4 to 7 when i have a big big array :(

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



[PHP] Limit to the number of sockets socket_select can supervise?

2004-11-20 Thread Hans-Christian Jehg
Hi
Im building a TCP server in PHP 5.0.2 on Windows. It will have to serve a 
lot of clients (500+) with low traffic.

During this I have noticed that socket_select seems unable to supervise more 
than 64 connections at a time (Not good when I need 500+). It stops with a 
message that

"Socket select failed, error code is: 10038, error message is: An operation 
was at tempted on something that is not a socket."

These are the outputs of socket_last_error() and 
socket_strerror(socket_last_error()).

And now forthe questions:
Does any of you have the same experience?
Is it something to do with Windows? Does this limitation exist on Linux?
Is it just a bug?
Any good suggestions?
Best regards
and thanx in advance
HC 

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


Re: [PHP] Limit the number of characters in a string

2004-06-12 Thread Richard Harb
actually it is:
substr($string, 0, 100);

http://www.php.net/substr

-Original Message-
From: php-general
Sent: Friday, June 11, 2004, 3:17:15 PM
> substr( xxx, 1, 100)

>>>
>>>Hi
>>>
>>>Anyone know how to clip the number of characters in a string? For instance,
>>>I have a string carrying a long piece of text, say, of 200 characters, but I
>>>want to reduce this to just the first 100 characters.
>>>
>>>
>>>Thanks in advance.
>>>
>>>Russell

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



Re: [PHP] Limit the number of characters in a string

2004-06-11 Thread Daniel Clark
substr( xxx, 1, 100)

>>
>>Hi
>>
>>Anyone know how to clip the number of characters in a string? For instance,
>>I have a string carrying a long piece of text, say, of 200 characters, but I
>>want to reduce this to just the first 100 characters.
>>
>>
>>Thanks in advance.
>>
>>Russell

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



[PHP] Limit number of characters in a string

2004-06-11 Thread Russell Curtis
Hi

Anyone know how to clip the number of characters in a string? For instance,
I have a string carrying a long piece of text, say, of 200 characters, but I
want to reduce this to just the first 100 characters.


Thanks in advance.

Russell

-- 
---
Russell Curtis

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



[PHP] Limit the number of characters in a string

2004-06-11 Thread Russell Curtis

Hi

Anyone know how to clip the number of characters in a string? For instance,
I have a string carrying a long piece of text, say, of 200 characters, but I
want to reduce this to just the first 100 characters.


Thanks in advance.

Russell

-- 
---
Russell Curtis

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



[PHP] limit number of CGI processes

2004-04-16 Thread Florian Effenberger
Hi there,

I run PHP as CGI (because of suEXEC), but some configuration must be wrong.
I just tried out to reload a PHP generated website about 20 or 30 times in
my browser, and this really bogged down the server, I had a load of about 20
or 30.

Is there anything I can do to limit this risk? I already fiddled around with
some configuration variables, but it didn't help. It always created a whole
lot of CGI childs that used up all memory...

I run Apache 2.0 on Linux 2.4.

Thanks!
Florian

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



RE: [PHP] limit on ammount of generated jscript arrays

2004-04-08 Thread Jay Blanchard
[snip]
Hi there i am building an app of insteading of building a list menu of
items, i am generating arrays of the data in javascript using a php
class,
this is then autocompleted in a textbox. Is there a limit to how many i
can
list in the page, like will it eventually slow the page down ?
[/snip]

Yes.

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



[PHP] limit on ammount of generated jscript arrays

2004-04-08 Thread electroteque
Hi there i am building an app of insteading of building a list menu of
items, i am generating arrays of the data in javascript using a php class,
this is then autocompleted in a textbox. Is there a limit to how many i can
list in the page, like will it eventually slow the page down ?

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



Re: [PHP] limit run time of a function?

2004-02-11 Thread Richard Davey
Hello Anthony,

Wednesday, February 11, 2004, 1:43:29 PM, you wrote:

A> I have a function in my application that does a large query on my database.
A> In certain instances the query will take to long to return and will reach
A> the max execution time set in PHP.ini.  This is ok though, it's already set
A> to 90 secs and I don't want it any longer than that.  What I would like is
A> to have a way that I can time a function.  If the function takes to long to
A> return data, kill it and follow some other path in my app to let the user
A> know what's going on.  What I'm trying to avoid is the warning from PHP

There may be a more elegant way, but this technique should certainly
work (in theory anyway! you'll have to test it for yourself):

Split your script up, so you have the "processing" script (i.e. the
one that actually does the query that might time out) and a handler
script.

The user is sent to the handler script (via say a form post, or
however you are doing this) and the handler script calls the
processing script via fsockopen().

Using this function you can specify a time-out value - either you'll
be able to stream the results of your processing script back into the
handler (and just echo them out perhaps? depends what it does) or you
can catch the time out and inform the user accordingly.

I probably made this sound more complicated than it really is :)

-- 
Best regards,
 Richardmailto:[EMAIL PROTECTED]

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



[PHP] limit run time of a function?

2004-02-11 Thread Anthony
I have a function in my application that does a large query on my database.
In certain instances the query will take to long to return and will reach
the max execution time set in PHP.ini.  This is ok though, it's already set
to 90 secs and I don't want it any longer than that.  What I would like is
to have a way that I can time a function.  If the function takes to long to
return data, kill it and follow some other path in my app to let the user
know what's going on.  What I'm trying to avoid is the warning from PHP
saying that the script reached max execution time.  The user gets all
confused and then I get help desk calls.  There has got to be another way.
Any ideas?

- Anthony

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



Re: [PHP] limit mysql connections

2004-01-09 Thread John W. Holmes
Diana Castillo wrote:

Is there any way to limit the connections so that this error never happens?
Warning: mysql_connect(): Too many connections at
/home/local/global/php/libraries/dblayer_mysql.php line 14.
The connections are already limited, that's why you get this warning. 
You need to handle this from the MySQL side and increase the number of 
connections allowed either when you start MySQL or in a config file. 
Directions are in the manual, of course. :)

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals – www.phparch.com

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


[PHP] limit mysql connections

2004-01-09 Thread Diana Castillo
Is there any way to limit the connections so that this error never happens?
Warning: mysql_connect(): Too many connections at
/home/local/global/php/libraries/dblayer_mysql.php line 14.

--
--
Diana Castillo
Global Reservas, S.L.
C/Granvia 22 dcdo 4-dcha
28013 Madrid-Spain
Tel : 00-34-913604039
Fax : 00-34-915228673
email: [EMAIL PROTECTED]
Web : http://www.hotelkey.com
  http://www.destinia.com

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



Re: [PHP] limit to elements in an array?

2003-10-24 Thread Robert Cummings
On Fri, 2003-10-24 at 04:48, Ian Truelsen wrote:
> Is there an upper limit to the number of elements that can be in an
> array? If so, what is that limit?

I think it is only limitted by your computer's memory or the size of a
long integer (2.4 billion or so). I did a test one day to see just how
much a lookup into a configuration array would cost, and it was
negligible both for loading time and access time on a 1 entry array.
Load time increases a bit on a 1 million entry array, but lookup was
still extremely fast, which is fairly expected with any decent unique
key lookup implementation.

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



[PHP] limit to elements in an array?

2003-10-24 Thread Ian Truelsen
Is there an upper limit to the number of elements that can be in an
array? If so, what is that limit?

-- 
Ian Truelsen
Email: [EMAIL PROTECTED]
AIM: ihtruelsen
Homepage: http://www.ihtruelsen.dyndns.org

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



RE: [PHP] Limit output of query field

2003-07-05 Thread Giz
This add a bit more functionality, in that it will adjust to the nearest end
of a word, and includes a 'more' link to the full text.  This also assumes
that the article may already only be 50 chars or less.

$maxsize = 50; // might be better as a DEFINE
$post = $row->text;
$post = (strlen($post) > $maxsize ) ? substr(substr($post,0,$maxsize-1), 0,
strrpos(substr($post,0,$maxsize-1),' '))."... more" : $post; 


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: Saturday, July 05, 2003 6:59 AM
To: [EMAIL PROTECTED]
Subject: [PHP] Limit output of query field

Hi there,

Hope you can help me with the following:

I have a query and i'm showing the output:

echo $row->text;

That goes o.k. but the text is 400 characters long and I only one to show
the first 50 characters and at the end showing ... dot's..

Help!

Thank you very much!

Frank




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



Re: [PHP] Limit output of query field

2003-07-05 Thread Dan Anderson
> Make it with your sql query, it will be faster:
> SELECT ..., IF(LENGTH(text)>50, CONCAT(SUBSTRING(text,0,50),'...'), 
> text) as text

I won't outright disagree, but warn fkessen to be careful.  There are
some scenarios in which that would not be faster.

-Dan


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



Re: [PHP] Limit output of query field

2003-07-05 Thread Marek Kilimajer
Make it with your sql query, it will be faster:
SELECT ..., IF(LENGTH(text)>50, CONCAT(SUBSTRING(text,0,50),'...'), 
text) as text

[EMAIL PROTECTED] wrote:
Hi there,

Hope you can help me with the following:

I have a query and i'm showing the output:

echo $row->text;

That goes o.k. but the text is 400 characters long and I only one to show the first 50 characters and at the end showing ... dot's..

Help!

Thank you very much!

Frank




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


RE: [PHP] Limit output of query field

2003-07-05 Thread Audun Larsen
Try this: 

if(strlen($row->text)>50) {
echo substr($row->text,0,47) . "...";
} else {
echo $row->text;
}

- Audun

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: Saturday, July 05, 2003 3:59 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Limit output of query field


Hi there,

Hope you can help me with the following:

I have a query and i'm showing the output:

echo $row->text;

That goes o.k. but the text is 400 characters long and I only one to
show the first 50 characters and at the end showing ... dot's..

Help!

Thank you very much!

Frank



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



Re: [PHP] Limit output of query field

2003-07-05 Thread Dan Anderson
Look up the function substr.  It will allow you to create a string of
the first 50 chars from your 400 char string.

-Dan

On Sat, 2003-07-05 at 09:58, [EMAIL PROTECTED] wrote:
> Hi there,
> 
> Hope you can help me with the following:
> 
> I have a query and i'm showing the output:
> 
> echo $row->text;
> 
> That goes o.k. but the text is 400 characters long and I only one to show the first 
> 50 characters and at the end showing ... dot's..
> 
> Help!
> 
> Thank you very much!
> 
> Frank
> 
> 
> __
> 
> -- 
> 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] Limit output of query field

2003-07-05 Thread fkeessen
Hi there,

Hope you can help me with the following:

I have a query and i'm showing the output:

echo $row->text;

That goes o.k. but the text is 400 characters long and I only one to show the first 50 
characters and at the end showing ... dot's..

Help!

Thank you very much!

Frank

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

Re: [PHP] limit on displaying a LONGTEXT filed from MySQL database

2003-06-22 Thread Justin French
Here one way you can do it (untested):



Justin



on 23/06/03 10:41 AM, Artoo ([EMAIL PROTECTED]) wrote:

> Hi,
> 
> How can I start searching for the first space in a string while starting at
> say the 150th character?  I'm trying to display the first 150 characters of
> an article that is stored in a LONGTEXT filed of a MYSQL database, and
> should the 150th character be inside a word, I would want to finish
> displaying that word.
> 
> For example supose the 150th character is the v in the word "privileges"  I
> would want to finish displaying the word and end with "privileges" rather
> then ending  with"priv"
> 
> thanks
> 
> 


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



Re: [PHP] limit on displaying a LONGTEXT filed from MySQL database

2003-06-22 Thread Adam i Agnieszka Gasiorowski FNORD
Artoo wrote:
 
> For example supose the 150th character is the v in the word "privileges"  I
> would want to finish displaying the word and end with "privileges" rather
> then ending  with"priv"

How about using the SUBSTRING_INDEX function
 with delimiter set to ' ' (space). You could select
 for example - 25 words - with it, I think.

-- 
Seks, seksić, seksolatki... news:pl.soc.seks.moderowana
http://hyperreal.info / ALinkA / bOrk! *  WiNoNa )   (
http://szatanowskie-ladacznice.0-700.pl  foReVeR(  *  )
Poznaj jej zwiewne kształty... http://www.opera.com 007


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



[PHP] limit on displaying a LONGTEXT filed from MySQL database

2003-06-22 Thread Artoo
Hi,

How can I start searching for the first space in a string while starting at
say the 150th character?  I'm trying to display the first 150 characters of
an article that is stored in a LONGTEXT filed of a MYSQL database, and
should the 150th character be inside a word, I would want to finish
displaying that word.

For example supose the 150th character is the v in the word "privileges"  I
would want to finish displaying the word and end with "privileges" rather
then ending  with"priv"

thanks



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



Re: [PHP] limit contral

2003-02-19 Thread Ernest E Vogelsinger
At 13:11 19.02.2003, James Shergold said:
[snip]
>I'm making a script that pulls property (house) from a mysql
>database in categories e.g. there cat1, cat2 ect and in each
>category I only want to show 10 properties a time then click
>next to show the next 10 properties in that catorgy.
[snip] 

Limiting the SQL result set brings you half the way there, as Jono already
pointed out:
SELECT foo FROM bar ORDER by blah LIMIT 10

For paging, you might additionally tell the database where to start by
adding the OFFSET parameter:
SELECT foo FROM bar ORDER by blah OFFSET 0 LIMIT 10
SELECT foo FROM bar ORDER by blah OFFSET 10 LIMIT 10
SELECT foo FROM bar ORDER by blah OFFSET 20 LIMIT 10

Note: This syntax is for PostgreSQL; MySQL also allows a slightly different
syntax:
SELECT foo FROM bar ORDER by blah LIMIT 0,10
SELECT foo FROM bar ORDER by blah LIMIT 10,10
SELECT foo FROM bar ORDER by blah LIMIT 20,10

 From the MySQL manual (http://www.mysql.com/doc/en/SELECT.html):
SELECT [STRAIGHT_JOIN]
...
  [LIMIT [offset,] rows | rows OFFSET offset]

HTH,

-- 
   >O Ernest E. Vogelsinger
   (\)ICQ #13394035
^ http://www.vogelsinger.at/



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




Re: [PHP] limit contral

2003-02-19 Thread Jono Bacon
James Shergold wrote:


Hi, all

I'm quite new to php and still finding my way round and came
across a problem.

I'm making a script that pulls property (house) from a mysql
database in categories e.g. there cat1, cat2 ect and in each
category I only want to show 10 properties a time then click
next to show the next 10 properties in that catorgy.

here is the main part of the script
http://www.smoothdesign.com/green/

if anyone can help that would be great.

James
[EMAIL PROTECTED]


 

Hi James,

You can limit the number of results using SQL:

   SELECT foo FROM bar ORDER by blah LIMIT 10

As for showing a page at a time - I have not done this before in PHP, 
but it is referred to as paging. Have a search on google and I am sure 
you will find a solution.

   Jono




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



[PHP] limit contral

2003-02-19 Thread James Shergold
Hi, all

I'm quite new to php and still finding my way round and came
across a problem.

I'm making a script that pulls property (house) from a mysql
database in categories e.g. there cat1, cat2 ect and in each
category I only want to show 10 properties a time then click
next to show the next 10 properties in that catorgy.

here is the main part of the script
http://www.smoothdesign.com/green/

if anyone can help that would be great.

James
[EMAIL PROTECTED]




RE: [PHP] Limit the amount of returns in a MySQL query

2003-02-07 Thread Chris Shiflett
--- Chad Day <[EMAIL PROTECTED]> wrote:
> if (!isset($startlimit)) {
>   $startlimit = 0;
> }
> 
> $endlimit = $startlimit + 10;
> 
> $yourquery = "your query data LIMIT $startlimit,
> $endlimit"
> 
> that should give you enough insight on how to work it.

Nice example.

As an interesting tidbit, the LIMIT clause is not standard
ANSI92 SQL and was "invented" by PHP's creator, Rasmus. So,
you can thank him for this useful clause.

Chris

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




RE: [PHP] Limit the amount of returns in a MySQL query

2003-02-07 Thread Chad Day
if (!isset($startlimit)) {
$startlimit = 0;
}

$endlimit = $startlimit + 10;

$yourquery = "your query data LIMIT $startlimit, $endlimit"

that should give you enough insight on how to work it.

Chad

-Original Message-
From: Daniel Page [mailto:[EMAIL PROTECTED]]
Sent: Friday, February 07, 2003 3:53 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Limit the amount of returns in a MySQL query


Hi All,

Imagine I have a giant database table tracking email addresses (I don't but
it is the first example that jumps to mind after my recent antispam
campaign!).

If i do a
 select * from mailaddresses;
I will get all of the table.
If i do a
 select * from mailaddresses where id < 10;
I will get all the records where the id is less than 10...

The problem is that I want 10 records, period, so if id is not a primary
key, I could have 60 records that match... or if it is a P.K., but I delete
2 to 8, it will only return 2 records (1 and 9...)

How can I structure the query to only return only 10 records ? the idea
being able to construct a query where if there are more than 10 (or x)
results on a page, you click on a link 'page 2' and so on, and the next
query will return the next 10 (or x) records...


Cheers,
Daniel



-- 
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] Limit the amount of returns in a MySQL query

2003-02-07 Thread Rankin, Randy
select * from mailaddresses where id < 10 LIMIT 10;

-Original Message-
From: Daniel Page [mailto:[EMAIL PROTECTED]]
Sent: Friday, February 07, 2003 2:53 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Limit the amount of returns in a MySQL query


Hi All,

Imagine I have a giant database table tracking email addresses (I don't but
it is the first example that jumps to mind after my recent antispam
campaign!).

If i do a
 select * from mailaddresses;
I will get all of the table.
If i do a
 select * from mailaddresses where id < 10;
I will get all the records where the id is less than 10...

The problem is that I want 10 records, period, so if id is not a primary
key, I could have 60 records that match... or if it is a P.K., but I delete
2 to 8, it will only return 2 records (1 and 9...)

How can I structure the query to only return only 10 records ? the idea
being able to construct a query where if there are more than 10 (or x)
results on a page, you click on a link 'page 2' and so on, and the next
query will return the next 10 (or x) records...


Cheers,
Daniel



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



[PHP] Limit the amount of returns in a MySQL query

2003-02-07 Thread Daniel Page
Hi All,

Imagine I have a giant database table tracking email addresses (I don't but
it is the first example that jumps to mind after my recent antispam
campaign!).

If i do a
 select * from mailaddresses;
I will get all of the table.
If i do a
 select * from mailaddresses where id < 10;
I will get all the records where the id is less than 10...

The problem is that I want 10 records, period, so if id is not a primary
key, I could have 60 records that match... or if it is a P.K., but I delete
2 to 8, it will only return 2 records (1 and 9...)

How can I structure the query to only return only 10 records ? the idea
being able to construct a query where if there are more than 10 (or x)
results on a page, you click on a link 'page 2' and so on, and the next
query will return the next 10 (or x) records...


Cheers,
Daniel



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




Re: [PHP] Limit to size of autoindex in MySQL/PHPMyAdmin?

2003-01-03 Thread Jim MacCormaic
On Friday, January 3, 2003, at 08:59  am, Leif K-Brooks wrote:


The limit to tinyint is 255... use int.


On Friday, January 3, 2003, at 09:02  am, Jasper Bryant-Greene wrote:


Change the field type from TINYINT to SMALLINT or MEDIUMINT. UNSIGNED 
TINYINT only has a range of 0 thru 255.

Thanks so much guys. I've made the change, tried again, and all is 
well. I opted for SMALLINT because its range is more than adequate for 
my needs. Whew! Relief!

Sorry for not thinking of going first to the source. Having read your 
posts I went back to the MYSQL manual and checked out Column Types. In 
my defence all I can say is that I'll remember it better this way ;-)


Jim MacCormaic
Dublin, Ireland
iChat/AIM	 : [EMAIL PROTECTED]


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



  1   2   >