[PHP] Re: Substr by words

2005-10-29 Thread Gustavo Narea
My script will fail if the amount of words in $MyOriginalString is less than $MaxWords. So, this is the new suggestion: $MyOriginalString = "This is my original string.\nWhat do you think about this script?"; $MaxWords = 50; // How many words are needed? $replacement = ereg_replace ("^([[:spa

[PHP] Re: Substr by words

2005-10-29 Thread Gustavo Narea
Gustavo Narea wrote: If forgot to say that It counts ($MaxWords) words, It doesn't matter if they're separated by simple spaces, line feeds (Unix, dos or mac), tabs, And punctuation marks. Sorry, I'm very forgetful tonight! Cheers. -- PHP General Mailing List (http://www.php.net/) To unsubsc

[PHP] Re: Substr by words

2005-10-29 Thread Gustavo Narea
If forgot to say that It counts ($MaxWords) words, It doesn't matter if they're separated by simple spaces, line feeds (Unix, dos or mac), tabs, among others. On the other hand, you won't have any problem if you use non-English characters. Best regards, Gustavo Narea. Gustavo Narea wrote:

[PHP] Re: Substr by words

2005-10-29 Thread Gustavo Narea
Hello. What do you think about this: $MyOriginalString = "This is my original string.\nWhat do you think about this script?"; $MaxWords = 6; // How many words are needed? echo substr( $MyOriginalString, 0, -strlen(ereg_replace ("^([[:space:]]*[^[:space:][:cntrl:]]+){1,$MaxWords}", "",$MyOri

Re: [PHP] Script Multitasking

2005-10-29 Thread Richard Lynch
On Sat, October 29, 2005 3:57 pm, Martin Zvarík wrote: > I have a file, which I run using command line. The file I am running, > runs several files using passthru(). > What I realise is, that it runs each file in sequence and waits for > its > result. > I need to run all files at once and they don'

[PHP] Script Multitasking

2005-10-29 Thread Martin Zvarík
Hi, I have a file, which I run using command line. The file I am running, runs several files using passthru(). What I realise is, that it runs each file in sequence and waits for its result. I need to run all files at once and they don't have to return the result to the main file. How do I do

Re: [PHP] Mixed PHP/SSI and environment variables

2005-10-29 Thread Richard Lynch
On Fri, October 28, 2005 9:36 am, Christoph Freundl wrote: > Perhaps I return to what I primarily intended to ask: is it really the > wanted behaviour of virtual() that changes that are made by the > included file do not influence the environment of the including file? That is most definitely a de

Re: [PHP] Mixed PHP/SSI and environment variables

2005-10-29 Thread Richard Lynch
On Thu, October 27, 2005 3:43 am, Christoph Freundl wrote: > I have a problem with the persistence of environment variables when > mixing PHP and SSI (Apache) and I am not sure if I just made an error > or if this approach cannot work at all. > So please consider the following files: I *believe* t

Re: [PHP] Detailed Report

2005-10-29 Thread Richard Lynch
On Thu, October 27, 2005 4:26 am, Danny wrote: > I´ve got a connection, to a MySQL db, and get the following > ResultSet(Category | Name | Code | City) > Customers | John | A36 | New York > Customers | Jason | B45 | Los Angeles > Customers | Max | A36 | Paris > Providers | John | A36 | London > P

Re: [PHP] Sending E-Mail - Setting O/S User

2005-10-29 Thread Richard Lynch
On Thu, October 27, 2005 5:04 am, Cabbar Duzayak wrote: > When someone sends an e-mail using php, exim sets the following 2 > headers (along with others of course): > > Received: from x.x.x.x (EHLO host.mydomain.com) (x.x.x.x) by > mta151.mail.dcn.yahoo.com with SMTP; Wed, 24 Sep 2005 10:29:04

Re: [PHP] Using PHP for accsess control, preventing access to static files

2005-10-29 Thread Richard Lynch
On Thu, October 27, 2005 11:05 am, Dan Trainor wrote: > It's been suggested to use readfile() to accomplish this, by > forwarding > content from outside of the document root - but this just sounds odd. > On top of being (what I think would be) incredibly slow, it just > doesn't > sound "right". A)

Re: [PHP] PHP5 class constants

2005-10-29 Thread Richard Lynch
On Thu, October 27, 2005 9:56 pm, Chris wrote: > Though I suppose you could make an argument for using expressions that > consist of only constant values. Actually... One could argue that so long as the programmer was willing to accept the consequences, there could be many legitimate circumstance

Re: [PHP] printing from php

2005-10-29 Thread Richard Lynch
On Fri, October 28, 2005 6:17 am, Tom Cruickshank wrote: > I've been reading up on printing out documents using PHP (using > Printer > functions calls in the php manual) > > I'm using a Linux and/or FreeBSD operating system to run my php code > on (in > apache). However, I am surfing these pag

Re: [PHP] Re: Type of form element

2005-10-29 Thread Richard Lynch
> I usually place a hidden field with the same name as the checkbox > field before the actual checkbox field. I store my 'false' value in > there. If the checkbox is checked the hidden field is overridden. > > > error_reporting( E_ALL ); > > if( isset( $_POST[ 'submit' ] ) ) > { > echo '';

Re: [PHP] Type of form element

2005-10-29 Thread Richard Lynch
On Fri, October 28, 2005 10:00 am, Shaun wrote: > I have some checkboxes on my page which correspond with boolean fields > in my > database - actually they are TINYINT's in which I store a 0 or 1 in > for > false and true values respectively. > > Is it possible to loop through all $_POST values to

Re: [PHP] curious (and frustrating) php/apache behavior

2005-10-29 Thread Richard Lynch
On Sat, October 29, 2005 12:01 pm, Don Brown wrote: > We're having a problem getting more than one imbedded PHP script to > execute in our Apache-served pages. We're using Apache 2.0.40 > server-side includes. We wish to include multiple PHP scripts into our > pages but are only succeeding in havin

Re: [PHP] Retrieve Data Formated from Text field

2005-10-29 Thread Richard Lynch
http://php.net/nl2br On Sat, October 29, 2005 12:07 pm, Danny wrote: > Hi Gurus, > I´ve got a problem with the result displaying a "TEXT" type field > The data is inserted into db in this way: > "Hello, > This is a sample of first line. > This is another paragraph, blah > blah blah > Bye" >

[PHP] Re: curious (and frustrating) php/apache behavior

2005-10-29 Thread Petr Smith
Hi, why don't you use normal php include (require) functions? Why do you want to mix apache server side includes with php code? There is nothing php include can't do.. Just change all to Petr Don Brown wrote: We're having a problem getting more than one imbedded PHP script to execute

Re: [PHP] Re: Inserting NULL Integer Values

2005-10-29 Thread Richard Lynch
On Sat, October 29, 2005 4:45 am, Bogdan Ribic wrote: >> $value1 = 'xyz","xyz"); DELETE FROM MYTABLE;'; >> >> you might get surprising results! >> >> This is called SQL injection and it's important to escape all the >> values >> before putting them into the statement. > > > Did you try that? This d

Re: [PHP] [DONE] Substr by words

2005-10-29 Thread Richard Lynch
On Sat, October 29, 2005 10:51 am, Minuk Choi wrote: > function trim_text($text, $count) > { > $text = str_replace(" ", " ", $text); > /* >* This is redundant; you are replacing all " " in $text with " " >* maybe you meant >* $text = trim($text); ? >*/

[PHP] Re: [DONE] Substr by words

2005-10-29 Thread James Benson
Did you actually test that? Even better version of your function, $string = "one two three four"; echo substr($string, -4); echo '...'; James Danny wrote: Finally i found it (Google is god, you only have to ask the right question) function trim_text($text, $count){ $text = str_r

Re: [PHP] Substr by words

2005-10-29 Thread Richard Lynch
On Sat, October 29, 2005 6:36 am, Danny wrote: > I need to extract 50 words more or less from a description field. How > can i > do that?. Substr, cuts the words. Is there any other way to that, > without > using and array? I mean and implemented function in PHP 4.x > I´ve been googling around, b

Re: [PHP] is there a number translation function?

2005-10-29 Thread Greg Donald
On Sat, 2005-10-29 at 12:13 -0700, Linda H wrote: > Does anyone know of a function for translating a decimal number into an > English number. In other words, if you pass it 1 it will return 'one', if > you pass it 127 it will return 'one hundred twenty seven', and etc. http://pear.php.net/packa

Re: [PHP] is there a number translation function?

2005-10-29 Thread tg-php
I couldn't find one out there Linda (and I'm sure I've seen them before) so since I'm stuck at work on a Saturday I thought I'd take a break and see if I could hack this out myself. Probably a more elegant way to do this, but here's what I came up with. Feel free to use and modify it at will.

Re: [PHP] Retrieve Data Formated from Text field

2005-10-29 Thread Linda H
The data is inserted into db in this way: "Hello, This is a sample of first line. This is another paragraph, blah blah blah Bye" But the result is in one paragraph: "Hello, This is a sample of first line. This is another paragraph, blah blah blah Bye" It sounds as if your database recor

Re: [PHP] curious (and frustrating) php/apache behavior

2005-10-29 Thread Linda H
We wish to include multiple PHP scripts into our pages but are only succeeding in having the first included PHP script executed; the rest are ignored or misinterpreted as HTML... I don't know if this is part of your problem, but when you do an include, it throws you out of php. So, if there

[PHP] curious (and frustrating) php/apache behavior

2005-10-29 Thread Don Brown
We're having a problem getting more than one imbedded PHP script to execute in our Apache-served pages. We're using Apache 2.0.40 server-side includes. We wish to include multiple PHP scripts into our pages but are only succeeding in having the first included PHP script executed; the rest are ig

[PHP] Retrieve Data Formated from Text field

2005-10-29 Thread Danny
Hi Gurus, I´ve got a problem with the result displaying a "TEXT" type field The data is inserted into db in this way: "Hello, This is a sample of first line. This is another paragraph, blah blah blah Bye" But the result is in one paragraph: "Hello, This is a sample of first line. This is an

[PHP] Re: curious (and frustrating) php/apache behavior

2005-10-29 Thread Don Brown
We're having a problem getting more than one imbedded PHP script to execute in our Apache-served pages. We're using Apache 2.0.40 server-side includes. We wish to include multiple PHP scripts into our pages but are only succeeding in having the first included PHP script executed; the rest are i

Re: [PHP] [DONE] Substr by words

2005-10-29 Thread tg-php
Good start guys. That's usually how I start down the path in solving a new problem. Invariably down the road I find a more "refined" way of doing what I did the hard way. The hard way is good though, you learn stuff along the way. Let's see how tight we can make this though: $maxwords) {

[PHP] is there a number translation function?

2005-10-29 Thread Linda H
Hi, Does anyone know of a function for translating a decimal number into an English number. In other words, if you pass it 1 it will return 'one', if you pass it 127 it will return 'one hundred twenty seven', and etc. Thanks, Linda -- PHP General Mailing List (http://www.php.net/) To unsubs

Re: [PHP] [DONE] Substr by words

2005-10-29 Thread Minuk Choi
Good job! However, let me give a few suggestions to optimize the code function trim_text($text, $count) { $text = str_replace(" ", " ", $text); /* * This is redundant; you are replacing all " " in $text with " " * maybe you meant * $text = trim($text); ? */

Re: [PHP] Sessions and register_long_arrays

2005-10-29 Thread Marcus Bointon
On 29 Oct 2005, at 14:48, Marcus Bointon wrote: changing an item in $_SESSION simply does not get saved back to the session file if register_long_arrays is enabled. I meant disabled. I've also tried using it with the mm session save handler and I get the same symptoms. I also get identical

[PHP] Sessions and register_long_arrays

2005-10-29 Thread Marcus Bointon
Strange behaviour that's taken me ages to track down. I have the situation where I can create a session, but any changes to it are not saved. session_write_close() didn't help. Eventually I tracked it down: if you have register_long_arrays disabled (as is the default in PHP5), this can happ

[PHP] [DONE] Substr by words

2005-10-29 Thread Danny
Finally i found it (Google is god, you only have to ask the right question) function trim_text($text, $count){ $text = str_replace(" ", " ", $text); $string = explode(" ", $text); for ( $wordCounter = 0; $wordCounter <= $count;wordCounter++ ){ $trimed .= $string[$wordCounter]; if ( $wordCounter <

[PHP] Substr by words

2005-10-29 Thread Danny
Hi, I need to extract 50 words more or less from a description field. How can i do that?. Substr, cuts the words. Is there any other way to that, without using and array? I mean and implemented function in PHP 4.x I´ve been googling around, but wordwrap, and substr is driving me mad... Thanks in

[PHP] Re: Referencing Containing (Non-Parent) Object?

2005-10-29 Thread Bogdan Ribic
Morgan Doocy wrote: I'm trying to figure out if PHP has the facility to reference containing, non-parent objects. I have three classes, embedded hierarchically, but which are NOT extended classes of their containing objects. I'd like to be able to reference variables in the higher-level objec

[PHP] Re: foreach / unset

2005-10-29 Thread Bogdan Ribic
Richard Lynch wrote: Anyway, can you do *this* safely as a DOCUMENTED FEATURE: foreach($array as $k => $v){ if (...) unset($array[$k]); } Well, somewhere in the said manual it is written that foreach operates on a *copy* of the array, so you should be safe unsetting values in the origin

[PHP] Images outside webroot + session = safe?

2005-10-29 Thread Joseph Tura
Hi there, I am storing images outside the webroot to keep them from being accessible for unauthorized users to see. Then I use a script to show the images, like this: Now, as there is no information on the images stored in a database yet (they have just been uploaded via ftp), I need to find a

[PHP] Re: Inserting NULL Integer Values

2005-10-29 Thread Bogdan Ribic
Oliver Grätz wrote: Shaun schrieb: $qid = mysql_query('INSERT INTO MYTABLE ( column1, column2, ) VALUES ( "'.$value1.'", "'.$value2.'"