Re: [PHP] Problems with implode

2009-03-26 Thread Toke Herkild

Tom Worster skrev:

On 3/24/09 9:25 AM, Andrea Giammarchi an_...@hotmail.com wrote:


Dunno why you guys started talk about utf-8 problems, he has a list of ids
which should contain only unsigned integers, otherwise I do not get how that
query could work with an implode(',', $whatever) rather than 'id in
('.implode(',', array_map('mysql_real_escape_string', $whatever)).')' ...
so, the problem could be more about missed ids in the array obtaining ,, ...
so, in this case, array_filter before, no?


it's certainly possible. but the way toke described his problem did not
imply that his ids were unsigned integers.

SELECT FROM ... WHERE id IN ('aardvark', 'abacus', 'abbey', ..., 'zulu',
'zygote');





AS written else it is not a problem with either implode nor with string,
Only when sending debug info via unformatted mail.
Which really should not give this problem, but it does one day I'll have 
time to figure out exactly what does trigger this error.


Regards,
Toke

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



Re: [PHP] Problems with implode

2009-03-26 Thread Virgilio Quilario
 Dunno why you guys started talk about utf-8 problems, he has a list of
 ids
 which should contain only unsigned integers, otherwise I do not get how
 that
 query could work with an implode(',', $whatever) rather than 'id in
 ('.implode(',', array_map('mysql_real_escape_string', $whatever)).')'
 ...
 so, the problem could be more about missed ids in the array obtaining ,,
 ...
 so, in this case, array_filter before, no?

 it's certainly possible. but the way toke described his problem did not
 imply that his ids were unsigned integers.

 SELECT FROM ... WHERE id IN ('aardvark', 'abacus', 'abbey', ..., 'zulu',
 'zygote');




 AS written else it is not a problem with either implode nor with string,
 Only when sending debug info via unformatted mail.
 Which really should not give this problem, but it does one day I'll have
 time to figure out exactly what does trigger this error.

 Regards,
 Toke


it is probably the way the email message was formatted.
it has to cut long lines to email line length limit.
so you see some numbers are broken ie on different lines.

Virgil
http://www.jampmark.com

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



[PHP] PHPizabi - Applying php in TPL (smarty template engine)

2009-03-26 Thread Luciano Felli
Hi there!
Any know how Can I use PHP code into Smarty Temple Engine (TPL files) ?
I usued {php} include(text.php); {/php} but the code don't run simply
output the code.
What's the problem? Wht don't run?

Thankx,
Luciano Felli


Re: [PHP] PHPizabi - Applying php in TPL (smarty template engine)

2009-03-26 Thread Jacques Manukyan
You have to change the $php_handling variable in Smarty first before you 
can use {php}{/php} tags inside your template. The default behavior of 
Smarty is to ignore or echo your code inside {php}{/php} tags in the 
template.


Take a look at http://www.smarty.net/manual/en/variable.php.handling.php

-- Jacques Manukyan

Luciano Felli wrote:

Hi there!
Any know how Can I use PHP code into Smarty Temple Engine (TPL files) ?
I usued {php} include(text.php); {/php} but the code don't run simply
output the code.
What's the problem? Wht don't run?

Thankx,
Luciano Felli

  



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



[PHP] Rusu Ionut, PHP Question

2009-03-26 Thread Ionut Rusu
Hello my name is Rusu Ionut,  i'm from Romania and i was wondering if you
have the time to to explain to mea little situation that i encountered.
So i have a class:  *index *and inside this class i have declared a public
array containing some classes, inside the constructor of the class i extract
the array variables and call the include function to include the array
variable which is the reference of an php class file.
My Question to you is : how is this possible
The php doesnt outputs any errors, and i was wondering if this style of
codying is making the server to work slower



here is my code.



class index
{
public $fisiere=array
  (
  *main_classes/db/functii.class.php*,
  *main_classes/db/mysql.class.php*,
  *main_classes/sp/setari_pagina.class.php*,
  *main_classes/admin/admin.class.php*,
  *main_classes/captcha/captcha.class.php*
  );

/*-*/

public function __construct()
{
$eroare=;
foreach($this-fisiere as $key=$value)
{
if(!file_exists(url_dinamice.$value))
{
*echo **error!;*
}
else
{
  *  include url_dinamice.$value;*
}
}
   }
}
$indexObj=new index();


RE: [PHP] Problems with implode

2009-03-26 Thread Andrea Giammarchi

The mail problem came out later or I missed some post about it.
So yes, I would pass that implode via wordwrap then

wordwrap(implode(', ', $list), 100, \n, false);

please note the space after the coma, to avoid truncated id.

@Tom Worster
I hope on daily basis you do NOT create arrays with single or double quoted 
strings when you need to implode an array of strings ... as I wrote already, if 
those where not numbers, that implode did not make sense:
'WHERE id IN ('.implode(',', array_map('mysql_real_escape_string', 
$whatever)).')'Regards



 Date: Thu, 26 Mar 2009 21:01:03 +0800
 From: virgilio.quila...@gmail.com
 To: t...@ezl-data.dk
 CC: php-general@lists.php.net
 Subject: Re: [PHP] Problems with implode
 
  Dunno why you guys started talk about utf-8 problems, he has a list of
  ids
  which should contain only unsigned integers, otherwise I do not get how
  that
  query could work with an implode(',', $whatever) rather than 'id in
  ('.implode(',', array_map('mysql_real_escape_string', $whatever)).')'
  ...
  so, the problem could be more about missed ids in the array obtaining ,,
  ...
  so, in this case, array_filter before, no?
 
  it's certainly possible. but the way toke described his problem did not
  imply that his ids were unsigned integers.
 
  SELECT FROM ... WHERE id IN ('aardvark', 'abacus', 'abbey', ..., 'zulu',
  'zygote');
 
 
 
 
  AS written else it is not a problem with either implode nor with string,
  Only when sending debug info via unformatted mail.
  Which really should not give this problem, but it does one day I'll have
  time to figure out exactly what does trigger this error.
 
  Regards,
  Toke
 
 
 it is probably the way the email message was formatted.
 it has to cut long lines to email line length limit.
 so you see some numbers are broken ie on different lines.
 
 Virgil
 http://www.jampmark.com
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 

_
News, entertainment and everything you care about at Live.com. Get it now!
http://www.live.com/getstarted.aspx

RE: [PHP] Rusu Ionut, PHP Question

2009-03-26 Thread kyle.smith
Have you bolded sections of the email or are there really asterisk
characters in those strings?

Assuming it's bolding being converted to text, why shouldn't this work?
It's definitely not the best approach, for example if you instanciate
the index class twice, you'll re-include the code *again*.  A better
approach is require_once(), or placing all the includes at the top of
your scripts.

Hope this helps,
Kyle 

-Original Message-
From: Ionut Rusu [mailto:johnr...@gmail.com] 
Sent: Thursday, March 26, 2009 10:35 AM
To: php-general@lists.php.net
Subject: [PHP] Rusu Ionut, PHP Question

Hello my name is Rusu Ionut,  i'm from Romania and i was wondering if
you have the time to to explain to mea little situation that i
encountered.
So i have a class:  *index *and inside this class i have declared a
public array containing some classes, inside the constructor of the
class i extract the array variables and call the include function to
include the array variable which is the reference of an php class
file.
My Question to you is : how is this possible
The php doesnt outputs any errors, and i was wondering if this style of
codying is making the server to work slower



here is my code.



class index
{
public $fisiere=array
  (
  *main_classes/db/functii.class.php*,
  *main_classes/db/mysql.class.php*,
 
*main_classes/sp/setari_pagina.class.php*,
  *main_classes/admin/admin.class.php*,
  *main_classes/captcha/captcha.class.php*
  );

/*-*/

public function __construct()
{
$eroare=;
foreach($this-fisiere as $key=$value)
{
if(!file_exists(url_dinamice.$value))
{
*echo **error!;*
}
else
{
  *  include url_dinamice.$value;*
}
}
   }
}
$indexObj=new index();

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



Re: [PHP] utf-8-safe replacement for strtr()?

2009-03-26 Thread Nisse Engström
On Wed, 25 Mar 2009 11:32:42 +0100, Nisse Engström wrote:

 On Tue, 24 Mar 2009 08:15:35 -0400, Tom Worster wrote:
 
 strtr() with three parameters is certainly unsafe. but my tests are showing
 that it may be ok with two parameters if the strings in the second parameter
 are well formed utf-8.
 
 does anyone know more? can confirm or contradict?
 
 The two-argument version of strtr() should work fine
 since there are no collisions in utf-8 such that part
 of one character matches part of a different character.

Oops. I meant to write that one complete character does
not match any part of any other character. If a string
of one or more utf-8 characters match a utf-8 text, it
matches exactly those characters in the text. If that
makes sense...


/Nisse

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



[PHP] Re: Rusu Ionut, PHP Question

2009-03-26 Thread Ionut Rusu
sry to boder you again but i didnt quite understood youre answer, i got the
part where to add the include files on the top of the file or with
require_once statment, but i still dont understant how is it posiible to add
classes to the constructor with the include statment and not trigger a
nested class error..

is it corect to add include files( php classes ) to the constructor, and if
so how does php do it
thank you!!!


Re: [PHP] Re: Rusu Ionut, PHP Question

2009-03-26 Thread Jan G.B.
Erm, aren't extends what you're looking for?
To accomplish the auto-loading of needed subclasses?

example:
?php
class FOO {
static $x = 'Hello World';
}
class BAR extends FOO {
public $greeting = false;
public function __construct() {
$this-greeting = parent::$x;
}
}

$test = new BAR();
echo $test-greeting;
?

Prints out Hello World.

Sure - the if you put class FOO in a separate file, than you need to
require_once(it) (as often as you need to) - it'll be there.


bye



2009/3/26 Ionut Rusu johnr...@gmail.com:
 sry to boder you again but i didnt quite understood youre answer, i got the
 part where to add the include files on the top of the file or with
 require_once statment, but i still dont understant how is it posiible to add
 classes to the constructor with the include statment and not trigger a
 nested class error..

 is it corect to add include files( php classes ) to the constructor, and if
 so how does php do it
 thank you!!!


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



Re: [PHP] PHPizabi - Applying php in TPL (smarty template engine)

2009-03-26 Thread Virgilio Quilario
 Hi there!
 Any know how Can I use PHP code into Smarty Temple Engine (TPL files) ?
 I usued {php} include(text.php); {/php} but the code don't run simply
 output the code.
 What's the problem? Wht don't run?

 Thankx,
 Luciano Felli

it may be the file path.
try echoing something before the include and see if it shows.

here is a collection of smarty tips and techniques
http://www.jampmark.com/php-programming/16-very-useful-smarty-scripting-tips-and-techniques-to-make-templates-smarter.html

hope you find it useful.

good luck.

virgil

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

http://www.oreillynet.com/pub/a/php/2002/10/24/simplesearchengine.html

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 /div id=divContent.

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 Local Search to Content

2009-03-26 Thread Stuart
2009/3/26 George Langley george.lang...@shaw.ca:
        Hi all! Am building a Search feature following the excellent tutorial 
 at:

 http://www.oreillynet.com/pub/a/php/2002/10/24/simplesearchengine.html

 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 /div id=divContent.

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

div id=divContent
!-- content begin --
sofihsod hiosdh sdh gus us u sg
!-- content end --
/div

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] similar page replication

2009-03-26 Thread PJ
I have a series of pages to display that are all exactly the same,
except for a couple of small changes like 1 number that needs to be
changed for a mysql_query, the title of the page, and the page_name.php.
I am wondering how these changes could be implemented when clicking on
an href link? Is there some way to redirect the link to another page
which would then $_GET['the_link'] and then pass the related info as
$strings to another page (a sort-of master page) that would then display
the results? I can visualize the solution, but is it possible? This
would avoid repeating the same page some 30+ times.

-- 
unheralded genius: A clean desk is the sign of a dull mind. 
-
Phil Jourdan --- p...@ptahhotep.com
   http://www.ptahhotep.com
   http://www.chiccantine.com/andypantry.php


-- 
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
 2009/3/26 George Langley george.lang...@shaw.ca:
  How do I STOP it? Is it permissible to add the id again in the 
 closing div tag ie /div id=divContent.


From: Stuart stut...@gmail.com
 You can't have any extra info in a closing HTML tag. This 
 problem is
 usually handled using comments. Something like the following...
 
 div id=divContent
 !-- content begin --
 sofihsod hiosdh sdh gus us u sg
 !-- content end --
 /div
 
 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 !-- startSearchTerms -- to make 
sure is located and not accidentally found within the content.

George


[PHP] flushing AJAX scripts

2009-03-26 Thread jim white
I am using jQuery AJAX request to run a script that can take several 
minutes to create a report. I want to start the script and immediately 
echo a response to close the connection and then let the script complete 
a report which I can get later. I have tried several thing such as


ob_start();
echo json_encode(array(time=$now, message=Report has started 
running!));

ob_end_flush();

However, the script does not respond and (I suppose close the 
connection) until the report is complete. How can I fix this behaviour?


Jim


--
James (Jim) B. White
tel: (919)-380-9615
homepage: http://jimserver.net/ 



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



[PHP] Re: similar page replication

2009-03-26 Thread Shawn McKenzie
PJ wrote:
 I have a series of pages to display that are all exactly the same,
 except for a couple of small changes like 1 number that needs to be
 changed for a mysql_query, the title of the page, and the page_name.php.
 I am wondering how these changes could be implemented when clicking on
 an href link? Is there some way to redirect the link to another page
 which would then $_GET['the_link'] and then pass the related info as
 $strings to another page (a sort-of master page) that would then display
 the results? I can visualize the solution, but is it possible? This
 would avoid repeating the same page some 30+ times.
 

Just use one page if you don't already have the 30 pages.  Something
like this maybe (needs lots of work, just an example):

index.php

?php

switch ($_GET['page']) {
case 'page1':
$sql_num = 1;
$page_title = 'Page 1';
break;

case 'page2':
$sql_num = 2;
$page_title = 'Page 2';
break;
}

echo $page_title;
//do some sql query using $sql_num

?

Then the links on your page would be index.php?page=page1 etc...

If you have multiple pages, then in the switch set a $filename and then
after the switch include($filename).

-- 
Thanks!
-Shawn
http://www.spidean.com

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



[PHP] Regex

2009-03-26 Thread Jesse.Hazen
Hi,

 

Brand new to regex. So I have a cli which runs a regex on users input,
to make sure that only 0-9 and A-Z are accepted. It should strip
everything else. My problem is that when you press control-Z (on
Windows; I have not yet tested this on linux, and I will, but I would
like this to be compatible with both OS's) it loops infinitely saying
invalid data (because of the next method call, which decides what to do
based on your input). So, here is the input code. Is there a way I can
ensure that control commands are stripped, here?

 

 

 

 

 

public function getSelection() {

 

$choice =
$this-validateChoice(trim(strtoupper(fgets(STDIN;

return $choice;

 

}

 

private function validateChoice($choice) {

 

$choice =
ereg_replace(/[^0-9A-Z]/,,$choice);

return $choice;

 

}

 

 

 

I have tried a ton of different things to try and fix this. Tried
/\c.|[^0-9A-Z]/, and many variations of \c and the [^0-9A-Z], to no
avail. I also tried using both preg_replace() as well as ereg_replace().
I spent a lot of time on the regex section of the PHP manual, but I am
not finding anything. Any advise on how to accomplish this?

 

 

 

Thanks,

 

Jesse Hazen



Re: [PHP] Regex

2009-03-26 Thread Nitsan Bin-Nun
To filter out everything which is not A-Z, a-z and 0-9 try this regex:

$str = preg_replace(#[^a-zA-Z0-9]+#is, , $str);

On Thu, Mar 26, 2009 at 10:23 PM, jesse.ha...@arvatousa.com wrote:

 Hi,



 Brand new to regex. So I have a cli which runs a regex on users input,
 to make sure that only 0-9 and A-Z are accepted. It should strip
 everything else. My problem is that when you press control-Z (on
 Windows; I have not yet tested this on linux, and I will, but I would
 like this to be compatible with both OS's) it loops infinitely saying
 invalid data (because of the next method call, which decides what to do
 based on your input). So, here is the input code. Is there a way I can
 ensure that control commands are stripped, here?











public function getSelection() {



$choice =
 $this-validateChoice(trim(strtoupper(fgets(STDIN;

return $choice;



}



private function validateChoice($choice) {



$choice =
 ereg_replace(/[^0-9A-Z]/,,$choice);

return $choice;



}







 I have tried a ton of different things to try and fix this. Tried
 /\c.|[^0-9A-Z]/, and many variations of \c and the [^0-9A-Z], to no
 avail. I also tried using both preg_replace() as well as ereg_replace().
 I spent a lot of time on the regex section of the PHP manual, but I am
 not finding anything. Any advise on how to accomplish this?







 Thanks,



 Jesse Hazen




RE: [PHP] Regex

2009-03-26 Thread Jesse.Hazen
Nitsan,

 

Thank you very much for the input. However, I just gave this a try and
it still did not strip the control-Z. Therefore, it is still hitting my
loop later and looping infinitely. I am sure I could mend that by
working something into that loop, but there are several loops I would
need to do this on. If I can stop the command at this method, then the
entire script will run perfectly.

 

 

 

 

Thanks,

 

Jesse Hazen

_ 

arvato digital services llc

A Bertelsmann Company

29011 Commerce Center Dr.

Valencia, CA 91355

 

http://arvatodigitalservices.com
blocked::http://arvatodigitalservices.com 

 

jesse.ha...@arvatousa.com blocked::mailto:jesse.ha...@arvatousa.com 

Tel. +1 (661) 702-2727

Fax. +1 (661) 775-6478



From: nit...@binnun.co.il [mailto:nit...@binnun.co.il] On Behalf Of
Nitsan Bin-Nun
Sent: Thursday, March 26, 2009 1:44 PM
To: Hazen, Jesse, arvato digital services llc
Cc: php-general@lists.php.net
Subject: Re: [PHP] Regex

 

To filter out everything which is not A-Z, a-z and 0-9 try this regex:

$str = preg_replace(#[^a-zA-Z0-9]+#is, , $str);

On Thu, Mar 26, 2009 at 10:23 PM, jesse.ha...@arvatousa.com wrote:

Hi,



Brand new to regex. So I have a cli which runs a regex on users input,
to make sure that only 0-9 and A-Z are accepted. It should strip
everything else. My problem is that when you press control-Z (on
Windows; I have not yet tested this on linux, and I will, but I would
like this to be compatible with both OS's) it loops infinitely saying
invalid data (because of the next method call, which decides what to do
based on your input). So, here is the input code. Is there a way I can
ensure that control commands are stripped, here?











   public function getSelection() {



   $choice =
$this-validateChoice(trim(strtoupper(fgets(STDIN;

   return $choice;



   }



   private function validateChoice($choice) {



   $choice =
ereg_replace(/[^0-9A-Z]/,,$choice);

   return $choice;



   }







I have tried a ton of different things to try and fix this. Tried
/\c.|[^0-9A-Z]/, and many variations of \c and the [^0-9A-Z], to no
avail. I also tried using both preg_replace() as well as ereg_replace().
I spent a lot of time on the regex section of the PHP manual, but I am
not finding anything. Any advise on how to accomplish this?







Thanks,



Jesse Hazen

 



Re: [PHP] Regex

2009-03-26 Thread Nitsan Bin-Nun
I have no idea about this control-Z thing, you might want to try it with UTF
(just add the 'u' modificator):
$str = preg_replace(#[^a-zA-Z0-9]+#uis, , $str);

Or try this:
$str = preg_replace(#(\b[^a-zA-Z0-9]\b?)+#uis, , $str);

I may be wrong about the second one but it might work...

On Thu, Mar 26, 2009 at 10:51 PM, jesse.ha...@arvatousa.com wrote:

  Nitsan,



 Thank you very much for the input. However, I just gave this a try and it
 still did not strip the control-Z. Therefore, it is still hitting my loop
 later and looping infinitely. I am sure I could mend that by working
 something into that loop, but there are several loops I would need to do
 this on. If I can stop the command at this method, then the entire script
 will run perfectly.









 Thanks,



 Jesse Hazen

 _

 arvato digital services llc

 A Bertelsmann Company

 29011 Commerce Center Dr.

 Valencia, CA 91355



 http://arvatodigitalservices.com



 jesse.ha...@arvatousa.com

 Tel. +1 (661) 702-2727

 Fax. +1 (661) 775-6478
   --

 *From:* nit...@binnun.co.il [mailto:nit...@binnun.co.il] *On Behalf Of *Nitsan
 Bin-Nun
 *Sent:* Thursday, March 26, 2009 1:44 PM
 *To:* Hazen, Jesse, arvato digital services llc
 *Cc:* php-general@lists.php.net
 *Subject:* Re: [PHP] Regex



 To filter out everything which is not A-Z, a-z and 0-9 try this regex:

 $str = preg_replace(#[^a-zA-Z0-9]+#is, , $str);

 On Thu, Mar 26, 2009 at 10:23 PM, jesse.ha...@arvatousa.com wrote:

 Hi,



 Brand new to regex. So I have a cli which runs a regex on users input,
 to make sure that only 0-9 and A-Z are accepted. It should strip
 everything else. My problem is that when you press control-Z (on
 Windows; I have not yet tested this on linux, and I will, but I would
 like this to be compatible with both OS's) it loops infinitely saying
 invalid data (because of the next method call, which decides what to do
 based on your input). So, here is the input code. Is there a way I can
 ensure that control commands are stripped, here?











public function getSelection() {



$choice =
 $this-validateChoice(trim(strtoupper(fgets(STDIN;

return $choice;



}



private function validateChoice($choice) {



$choice =
 ereg_replace(/[^0-9A-Z]/,,$choice);

return $choice;



}







 I have tried a ton of different things to try and fix this. Tried
 /\c.|[^0-9A-Z]/, and many variations of \c and the [^0-9A-Z], to no
 avail. I also tried using both preg_replace() as well as ereg_replace().
 I spent a lot of time on the regex section of the PHP manual, but I am
 not finding anything. Any advise on how to accomplish this?







 Thanks,



 Jesse Hazen





RE: [PHP] Regex

2009-03-26 Thread Jesse.Hazen
Nitsan,

 

Thanks again. Sad to say, same result.

 

The second option looped an error: Warning: preg_replace(): Compilation
failed: nothing to repeat at offset 17 

 

 

 

 

Thanks,

 

Jesse Hazen



From: nit...@binnun.co.il [mailto:nit...@binnun.co.il] On Behalf Of
Nitsan Bin-Nun
Sent: Thursday, March 26, 2009 1:58 PM
To: Hazen, Jesse, arvato digital services llc
Cc: php-general@lists.php.net
Subject: Re: [PHP] Regex

 

I have no idea about this control-Z thing, you might want to try it with
UTF (just add the 'u' modificator):
$str = preg_replace(#[^a-zA-Z0-9]+#uis, , $str);

Or try this:
$str = preg_replace(#(\b[^a-zA-Z0-9]\b?)+#uis, , $str);

I may be wrong about the second one but it might work...

On Thu, Mar 26, 2009 at 10:51 PM, jesse.ha...@arvatousa.com wrote:

Nitsan,

 

Thank you very much for the input. However, I just gave this a try and
it still did not strip the control-Z. Therefore, it is still hitting my
loop later and looping infinitely. I am sure I could mend that by
working something into that loop, but there are several loops I would
need to do this on. If I can stop the command at this method, then the
entire script will run perfectly.

 

 

 

 

Thanks,

 

Jesse Hazen

_ 

arvato digital services llc

A Bertelsmann Company

29011 Commerce Center Dr.

Valencia, CA 91355

 

http://arvatodigitalservices.com

 

jesse.ha...@arvatousa.com

Tel. +1 (661) 702-2727

Fax. +1 (661) 775-6478



From: nit...@binnun.co.il [mailto:nit...@binnun.co.il] On Behalf Of
Nitsan Bin-Nun
Sent: Thursday, March 26, 2009 1:44 PM
To: Hazen, Jesse, arvato digital services llc
Cc: php-general@lists.php.net
Subject: Re: [PHP] Regex

 

To filter out everything which is not A-Z, a-z and 0-9 try this regex:

$str = preg_replace(#[^a-zA-Z0-9]+#is, , $str);

On Thu, Mar 26, 2009 at 10:23 PM, jesse.ha...@arvatousa.com wrote:

Hi,



Brand new to regex. So I have a cli which runs a regex on users input,
to make sure that only 0-9 and A-Z are accepted. It should strip
everything else. My problem is that when you press control-Z (on
Windows; I have not yet tested this on linux, and I will, but I would
like this to be compatible with both OS's) it loops infinitely saying
invalid data (because of the next method call, which decides what to do
based on your input). So, here is the input code. Is there a way I can
ensure that control commands are stripped, here?











   public function getSelection() {



   $choice =
$this-validateChoice(trim(strtoupper(fgets(STDIN;

   return $choice;



   }



   private function validateChoice($choice) {



   $choice =
ereg_replace(/[^0-9A-Z]/,,$choice);

   return $choice;



   }







I have tried a ton of different things to try and fix this. Tried
/\c.|[^0-9A-Z]/, and many variations of \c and the [^0-9A-Z], to no
avail. I also tried using both preg_replace() as well as ereg_replace().
I spent a lot of time on the regex section of the PHP manual, but I am
not finding anything. Any advise on how to accomplish this?







Thanks,



Jesse Hazen

 

 



Re: [PHP] Regex

2009-03-26 Thread Nitsan Bin-Nun
If you can point me on the character which control-z creates it would make
it easier, I have no idea of it ;)

I'm sorry mate.

On Thu, Mar 26, 2009 at 11:06 PM, jesse.ha...@arvatousa.com wrote:

  Nitsan,



 Thanks again. Sad to say, same result.



 The second option looped an error: Warning: preg_replace(): Compilation
 failed: nothing to repeat at offset 17









 Thanks,



 Jesse Hazen
   --

 *From:* nit...@binnun.co.il [mailto:nit...@binnun.co.il] *On Behalf Of *Nitsan
 Bin-Nun
 *Sent:* Thursday, March 26, 2009 1:58 PM

 *To:* Hazen, Jesse, arvato digital services llc
 *Cc:* php-general@lists.php.net
 *Subject:* Re: [PHP] Regex



 I have no idea about this control-Z thing, you might want to try it with
 UTF (just add the 'u' modificator):
 $str = preg_replace(#[^a-zA-Z0-9]+#uis, , $str);

 Or try this:
 $str = preg_replace(#(\b[^a-zA-Z0-9]\b?)+#uis, , $str);

 I may be wrong about the second one but it might work...

 On Thu, Mar 26, 2009 at 10:51 PM, jesse.ha...@arvatousa.com wrote:

 Nitsan,



 Thank you very much for the input. However, I just gave this a try and it
 still did not strip the control-Z. Therefore, it is still hitting my loop
 later and looping infinitely. I am sure I could mend that by working
 something into that loop, but there are several loops I would need to do
 this on. If I can stop the command at this method, then the entire script
 will run perfectly.









 Thanks,



 Jesse Hazen

 _

 arvato digital services llc

 A Bertelsmann Company

 29011 Commerce Center Dr.

 Valencia, CA 91355



 http://arvatodigitalservices.com



 jesse.ha...@arvatousa.com

 Tel. +1 (661) 702-2727

 Fax. +1 (661) 775-6478
   --

 *From:* nit...@binnun.co.il [mailto:nit...@binnun.co.il] *On Behalf Of *Nitsan
 Bin-Nun
 *Sent:* Thursday, March 26, 2009 1:44 PM
 *To:* Hazen, Jesse, arvato digital services llc
 *Cc:* php-general@lists.php.net
 *Subject:* Re: [PHP] Regex



 To filter out everything which is not A-Z, a-z and 0-9 try this regex:

 $str = preg_replace(#[^a-zA-Z0-9]+#is, , $str);

 On Thu, Mar 26, 2009 at 10:23 PM, jesse.ha...@arvatousa.com wrote:

 Hi,



 Brand new to regex. So I have a cli which runs a regex on users input,
 to make sure that only 0-9 and A-Z are accepted. It should strip
 everything else. My problem is that when you press control-Z (on
 Windows; I have not yet tested this on linux, and I will, but I would
 like this to be compatible with both OS's) it loops infinitely saying
 invalid data (because of the next method call, which decides what to do
 based on your input). So, here is the input code. Is there a way I can
 ensure that control commands are stripped, here?











public function getSelection() {



$choice =
 $this-validateChoice(trim(strtoupper(fgets(STDIN;

return $choice;



}



private function validateChoice($choice) {



$choice =
 ereg_replace(/[^0-9A-Z]/,,$choice);

return $choice;



}







 I have tried a ton of different things to try and fix this. Tried
 /\c.|[^0-9A-Z]/, and many variations of \c and the [^0-9A-Z], to no
 avail. I also tried using both preg_replace() as well as ereg_replace().
 I spent a lot of time on the regex section of the PHP manual, but I am
 not finding anything. Any advise on how to accomplish this?







 Thanks,



 Jesse Hazen







RE: [PHP] Regex

2009-03-26 Thread Jesse.Hazen
Nitsan,

 

Not a problem, thanks for the help. So, it is printed as ^Z. However, I
created a little test.php script to accept input and print it back to
me. So, I used control z as my test, and it simply printed a line, and
that's all. So, then I input control z, and then had it print a letter
right after (a), and it was just the letter a. no whitespace, no
breaks, nothing. 

 

I even tried one more thing: in the loop (not in the code below) I put
unset($choice), right above where it tells the user their input is
invalid and asks for it again. Even this did not change anything: when
pressing control - z, it looped infinitely.

 

I assumed that \c would be the regex to mend this, as the php manual has
this as control-x, where x is any character. I even tried every
variation of this, with a key combination like \cZ, or \cz, or \c[zZ],
yet it still does not catch it.

 

 

 

 

Thanks,

 

Jesse Hazen

 



From: nit...@binnun.co.il [mailto:nit...@binnun.co.il] On Behalf Of
Nitsan Bin-Nun
Sent: Thursday, March 26, 2009 2:09 PM
To: Hazen, Jesse, arvato digital services llc
Cc: php-general@lists.php.net
Subject: Re: [PHP] Regex

 

If you can point me on the character which control-z creates it would
make it easier, I have no idea of it ;)

I'm sorry mate.

On Thu, Mar 26, 2009 at 11:06 PM, jesse.ha...@arvatousa.com wrote:

Nitsan,

 

Thanks again. Sad to say, same result.

 

The second option looped an error: Warning: preg_replace(): Compilation
failed: nothing to repeat at offset 17 

 

 

 

 

Thanks,

 

Jesse Hazen



From: nit...@binnun.co.il [mailto:nit...@binnun.co.il] On Behalf Of
Nitsan Bin-Nun
Sent: Thursday, March 26, 2009 1:58 PM


To: Hazen, Jesse, arvato digital services llc
Cc: php-general@lists.php.net
Subject: Re: [PHP] Regex

 

I have no idea about this control-Z thing, you might want to try it with
UTF (just add the 'u' modificator):
$str = preg_replace(#[^a-zA-Z0-9]+#uis, , $str);

Or try this:
$str = preg_replace(#(\b[^a-zA-Z0-9]\b?)+#uis, , $str);

I may be wrong about the second one but it might work...

On Thu, Mar 26, 2009 at 10:51 PM, jesse.ha...@arvatousa.com wrote:

Nitsan,

 

Thank you very much for the input. However, I just gave this a try and
it still did not strip the control-Z. Therefore, it is still hitting my
loop later and looping infinitely. I am sure I could mend that by
working something into that loop, but there are several loops I would
need to do this on. If I can stop the command at this method, then the
entire script will run perfectly.

 

 

 

 

Thanks,

 

Jesse Hazen

_ 

arvato digital services llc

A Bertelsmann Company

29011 Commerce Center Dr.

Valencia, CA 91355

 

http://arvatodigitalservices.com

 

jesse.ha...@arvatousa.com

Tel. +1 (661) 702-2727

Fax. +1 (661) 775-6478



From: nit...@binnun.co.il [mailto:nit...@binnun.co.il] On Behalf Of
Nitsan Bin-Nun
Sent: Thursday, March 26, 2009 1:44 PM
To: Hazen, Jesse, arvato digital services llc
Cc: php-general@lists.php.net
Subject: Re: [PHP] Regex

 

To filter out everything which is not A-Z, a-z and 0-9 try this regex:

$str = preg_replace(#[^a-zA-Z0-9]+#is, , $str);

On Thu, Mar 26, 2009 at 10:23 PM, jesse.ha...@arvatousa.com wrote:

Hi,



Brand new to regex. So I have a cli which runs a regex on users input,
to make sure that only 0-9 and A-Z are accepted. It should strip
everything else. My problem is that when you press control-Z (on
Windows; I have not yet tested this on linux, and I will, but I would
like this to be compatible with both OS's) it loops infinitely saying
invalid data (because of the next method call, which decides what to do
based on your input). So, here is the input code. Is there a way I can
ensure that control commands are stripped, here?











   public function getSelection() {



   $choice =
$this-validateChoice(trim(strtoupper(fgets(STDIN;

   return $choice;



   }



   private function validateChoice($choice) {



   $choice =
ereg_replace(/[^0-9A-Z]/,,$choice);

   return $choice;



   }







I have tried a ton of different things to try and fix this. Tried
/\c.|[^0-9A-Z]/, and many variations of \c and the [^0-9A-Z], to no
avail. I also tried using both preg_replace() as well as ereg_replace().
I spent a lot of time on the regex section of the PHP manual, but I am
not finding anything. Any advise on how to accomplish this?







Thanks,



Jesse Hazen

 

 

 



Re: [PHP] flushing AJAX scripts

2009-03-26 Thread Chris

jim white wrote:
I am using jQuery AJAX request to run a script that can take several 
minutes to create a report. I want to start the script and immediately 
echo a response to close the connection and then let the script complete 
a report which I can get later. I have tried several thing such as


ob_start();
echo json_encode(array(time=$now, message=Report has started 
running!));

ob_end_flush();


Try something like this

echo something;
flush();

without the ob* stuff.

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


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



Re: [PHP] Limit Local Search to Content

2009-03-26 Thread George Langley
- Original Message -
 From: Stuart stut...@gmail.com
  You can't have any extra info in a closing HTML tag. This 
  problem is
  usually handled using comments. Something like the following...
  
  div id=divContent
  !-- content begin --
  sofihsod hiosdh sdh gus us u sg
  !-- content end --
  /div
  
  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?


?php

function contentString($pString, $pStart, $pStop){
echo $pStringbr /;

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

for ($i=1; $icount($exploded1); $i++) // ignore first item (0) in 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 br /br /;
}

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


[PHP] Re: similar page replication

2009-03-26 Thread tedd


PJ wrote:

 I have a series of pages to display that are all exactly the same,
 except for a couple of small changes like 1 number that needs to be
 changed for a mysql_query, the title of the page, and the page_name.php.
 I am wondering how these changes could be implemented when clicking on
 an href link? Is there some way to redirect the link to another page
 which would then $_GET['the_link'] and then pass the related info as
 $strings to another page (a sort-of master page) that would then display
 the results? I can visualize the solution, but is it possible? This
 would avoid repeating the same page some 30+ times.



Try this demo, it will show you how to do that:

http://sperling.com/examples/include-demo/

Cheers,

tedd
--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



RE: [PHP] Regex

2009-03-26 Thread Jesse.Hazen
Nistan,

Just got home, tested on linux. No problem on linux, the control-z just exits. 
I may just go ahead and post my issue to the PHP windows list to see if 
anything comes up, and not worry if it doesnt. I appreciate the help very much



Thanks,

Jesse

-Original Message-
From: jesse.ha...@arvatousa.com [mailto:jesse.ha...@arvatousa.com]
Sent: Thu 3/26/2009 2:17 PM
To: nitsa...@gmail.com
Cc: php-general@lists.php.net
Subject: RE: [PHP] Regex
 
Nitsan,

 

Not a problem, thanks for the help. So, it is printed as ^Z. However, I
created a little test.php script to accept input and print it back to
me. So, I used control z as my test, and it simply printed a line, and
that's all. So, then I input control z, and then had it print a letter
right after (a), and it was just the letter a. no whitespace, no
breaks, nothing. 

 

I even tried one more thing: in the loop (not in the code below) I put
unset($choice), right above where it tells the user their input is
invalid and asks for it again. Even this did not change anything: when
pressing control - z, it looped infinitely.

 

I assumed that \c would be the regex to mend this, as the php manual has
this as control-x, where x is any character. I even tried every
variation of this, with a key combination like \cZ, or \cz, or \c[zZ],
yet it still does not catch it.

 

 

 

 

Thanks,

 

Jesse Hazen

 



From: nit...@binnun.co.il [mailto:nit...@binnun.co.il] On Behalf Of
Nitsan Bin-Nun
Sent: Thursday, March 26, 2009 2:09 PM
To: Hazen, Jesse, arvato digital services llc
Cc: php-general@lists.php.net
Subject: Re: [PHP] Regex

 

If you can point me on the character which control-z creates it would
make it easier, I have no idea of it ;)

I'm sorry mate.

On Thu, Mar 26, 2009 at 11:06 PM, jesse.ha...@arvatousa.com wrote:

Nitsan,

 

Thanks again. Sad to say, same result.

 

The second option looped an error: Warning: preg_replace(): Compilation
failed: nothing to repeat at offset 17 

 

 

 

 

Thanks,

 

Jesse Hazen



From: nit...@binnun.co.il [mailto:nit...@binnun.co.il] On Behalf Of
Nitsan Bin-Nun
Sent: Thursday, March 26, 2009 1:58 PM


To: Hazen, Jesse, arvato digital services llc
Cc: php-general@lists.php.net
Subject: Re: [PHP] Regex

 

I have no idea about this control-Z thing, you might want to try it with
UTF (just add the 'u' modificator):
$str = preg_replace(#[^a-zA-Z0-9]+#uis, , $str);

Or try this:
$str = preg_replace(#(\b[^a-zA-Z0-9]\b?)+#uis, , $str);

I may be wrong about the second one but it might work...

On Thu, Mar 26, 2009 at 10:51 PM, jesse.ha...@arvatousa.com wrote:

Nitsan,

 

Thank you very much for the input. However, I just gave this a try and
it still did not strip the control-Z. Therefore, it is still hitting my
loop later and looping infinitely. I am sure I could mend that by
working something into that loop, but there are several loops I would
need to do this on. If I can stop the command at this method, then the
entire script will run perfectly.

 

 

 

 

Thanks,

 

Jesse Hazen

_ 

arvato digital services llc

A Bertelsmann Company

29011 Commerce Center Dr.

Valencia, CA 91355

 

http://arvatodigitalservices.com

 

jesse.ha...@arvatousa.com

Tel. +1 (661) 702-2727

Fax. +1 (661) 775-6478



From: nit...@binnun.co.il [mailto:nit...@binnun.co.il] On Behalf Of
Nitsan Bin-Nun
Sent: Thursday, March 26, 2009 1:44 PM
To: Hazen, Jesse, arvato digital services llc
Cc: php-general@lists.php.net
Subject: Re: [PHP] Regex

 

To filter out everything which is not A-Z, a-z and 0-9 try this regex:

$str = preg_replace(#[^a-zA-Z0-9]+#is, , $str);

On Thu, Mar 26, 2009 at 10:23 PM, jesse.ha...@arvatousa.com wrote:

Hi,



Brand new to regex. So I have a cli which runs a regex on users input,
to make sure that only 0-9 and A-Z are accepted. It should strip
everything else. My problem is that when you press control-Z (on
Windows; I have not yet tested this on linux, and I will, but I would
like this to be compatible with both OS's) it loops infinitely saying
invalid data (because of the next method call, which decides what to do
based on your input). So, here is the input code. Is there a way I can
ensure that control commands are stripped, here?












   public function getSelection() {



   $choice =
$this-validateChoice(trim(strtoupper(fgets(STDIN;

   return $choice;



   }



   private function validateChoice($choice) {



   $choice =
ereg_replace(/[^0-9A-Z]/,,$choice);

   return $choice;



   }







I have tried a ton of different things to try and fix this. Tried
/\c.|[^0-9A-Z]/, and many variations of \c and the [^0-9A-Z], to no
avail. I also tried using both preg_replace() as well as ereg_replace().
I spent a lot of time on the regex section of the PHP manual, but I am
not 

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 stut...@gmail.com
   You can't have any extra info in a closing HTML tag. This 
   problem is
   usually handled using comments. Something like the following...
   
   div id=divContent
   !-- content begin --
   sofihsod hiosdh sdh gus us u sg
   !-- content end --
   /div
   
   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?
 
 
 ?php
 
 function contentString($pString, $pStart, $pStop){
   echo $pStringbr /;
   
   $finalArray = array();
   $finalString = ;
   $exploded1 = explode($pStart, $pString); // makes array $exploded1
   
   for ($i=1; $icount($exploded1); $i++) // ignore first item (0) in 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 br /br /;
 }
 
 // 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] Regex

2009-03-26 Thread bruce
hi...

if you haven't solved your issue... can you tell me in detail what you're
trying to accomplish? what are the steps to running the script?

thanks


-Original Message-
From: jesse.ha...@arvatousa.com [mailto:jesse.ha...@arvatousa.com]
Sent: Thursday, March 26, 2009 1:23 PM
To: php-general@lists.php.net
Subject: [PHP] Regex


Hi,

 

Brand new to regex. So I have a cli which runs a regex on users input,
to make sure that only 0-9 and A-Z are accepted. It should strip
everything else. My problem is that when you press control-Z (on
Windows; I have not yet tested this on linux, and I will, but I would
like this to be compatible with both OS's) it loops infinitely saying
invalid data (because of the next method call, which decides what to do
based on your input). So, here is the input code. Is there a way I can
ensure that control commands are stripped, here?

 

 

 

 

 

public function getSelection() {

 

$choice =
$this-validateChoice(trim(strtoupper(fgets(STDIN;

return $choice;

 

}

 

private function validateChoice($choice) {

 

$choice =
ereg_replace(/[^0-9A-Z]/,,$choice);

return $choice;

 

}

 

 

 

I have tried a ton of different things to try and fix this. Tried
/\c.|[^0-9A-Z]/, and many variations of \c and the [^0-9A-Z], to no
avail. I also tried using both preg_replace() as well as ereg_replace().
I spent a lot of time on the regex section of the PHP manual, but I am
not finding anything. Any advise on how to accomplish this?

 

 

 

Thanks,

 

Jesse Hazen


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

[PHP] Multiple cookies on the same computer

2009-03-26 Thread Ken Watkins
Hi all.

Newbie here.

I have set up a blog site where my family creates posts and they get emailed to 
members of the family. To keep up with their identities, I created a script for 
each family member to run (dad.php, mom.php, etc.), and it sets a cookie on 
each computer and uses sessions so I know who is connecting. It works great 
unless I want to share a computer between two users.

I thought I had a solution: install both Firefox and IE on the same computer 
and set two different cookies. But this doesn't seem to work. My question is: 
Is it possible to set one cookie for IE and another for Firefox so that, 
depending on which browser is used, I can tell who is connecting to the blog? 
If this is not possible, is there another easy way to do it?

Thanks for your help.

- Ken Watkins




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



Re: [PHP] Multiple cookies on the same computer

2009-03-26 Thread dg


On Mar 26, 2009, at 7:14 PM, Ken Watkins wrote:

To keep up with their identities, I created a script for each family  
member to run (dad.php, mom.php, etc.), and it sets a cookie on each  
computer and uses sessions so I know who is connecting.


Each family member only uses her/his own page?  Maybe set a unique  
cookie name based on each page?


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



Re: [PHP] flushing AJAX scripts

2009-03-26 Thread Raymond Irving

Hello Jim,

You will need to do some low level ajax coding from the client side with the 
onreadychange event. If you're using jquery 1.3 then you can create your own 
XHR object with the xhr callback handler.

To learn more about the ready state check out this link:
http://www.quirksmode.org/blog/archives/2005/09/xmlhttp_notes_r_2.html

You might find what you're looking for with the following ready state:

3 - Interactive Downloading, responseText holds the partial data. 


Raymond Irving
Create Rich PHP Web Apps Today!
Raxan PDI - http://raxanpdi.com/

--- On Thu, 3/26/09, jim white jbw2...@earthlink.net wrote:

 From: jim white jbw2...@earthlink.net
 Subject: [PHP] flushing AJAX scripts
 To: php-general@lists.php.net
 Date: Thursday, March 26, 2009, 4:01 PM
 I am using jQuery AJAX request to run
 a script that can take several minutes to create a report. I
 want to start the script and immediately echo a response to
 close the connection and then let the script complete a
 report which I can get later. I have tried several thing
 such as
 
 ob_start();
 echo json_encode(array(time=$now,
 message=Report has started running!));
 ob_end_flush();
 
 However, the script does not respond and (I suppose close
 the connection) until the report is complete. How can I fix
 this behaviour?
 
 Jim
 
 
 -- James (Jim) B. White
 tel: (919)-380-9615
 homepage: http://jimserver.net/ 
 
 -- PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 

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



Re: [PHP] Regex

2009-03-26 Thread Shawn McKenzie
jesse.ha...@arvatousa.com wrote:
 Nistan,
 
 Just got home, tested on linux. No problem on linux, the control-z just 
 exits. I may just go ahead and post my issue to the PHP windows list to see 
 if anything comes up, and not worry if it doesnt. I appreciate the help very 
 much
 
 
 
 Thanks,
 
 Jesse

Ctrl z suspends the current process running in the shell in linux.  Not
sure about winbloze.  Probably sends an escape char of some sort.


-- 
Thanks!
-Shawn
http://www.spidean.com

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



[PHP] Re: Multiple cookies on the same computer

2009-03-26 Thread Shawn McKenzie
Ken Watkins wrote:
 Hi all.
 
 Newbie here.
 
 I have set up a blog site where my family creates posts and they get emailed 
 to members of the family. To keep up with their identities, I created a 
 script for each family member to run (dad.php, mom.php, etc.), and it sets a 
 cookie on each computer and uses sessions so I know who is connecting. It 
 works great unless I want to share a computer between two users.
 
 I thought I had a solution: install both Firefox and IE on the same computer 
 and set two different cookies. But this doesn't seem to work. My question is: 
 Is it possible to set one cookie for IE and another for Firefox so that, 
 depending on which browser is used, I can tell who is connecting to the blog? 
 If this is not possible, is there another easy way to do it?
 
 Thanks for your help.
 
 - Ken Watkins
 
 

Even if you don't need it secure, have a login.  Dad and mom can login
with dad or mom with no password if all you need to do is give them
their own cookie/session.


-- 
Thanks!
-Shawn
http://www.spidean.com

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



[PHP] Re: Multiple cookies on the same computer

2009-03-26 Thread Shawn McKenzie
Shawn McKenzie wrote:
 Ken Watkins wrote:
 Hi all.

 Newbie here.

 I have set up a blog site where my family creates posts and they get emailed 
 to members of the family. To keep up with their identities, I created a 
 script for each family member to run (dad.php, mom.php, etc.), and it sets a 
 cookie on each computer and uses sessions so I know who is connecting. It 
 works great unless I want to share a computer between two users.

 I thought I had a solution: install both Firefox and IE on the same computer 
 and set two different cookies. But this doesn't seem to work. My question 
 is: Is it possible to set one cookie for IE and another for Firefox so that, 
 depending on which browser is used, I can tell who is connecting to the 
 blog? If this is not possible, is there another easy way to do it?

 Thanks for your help.

 - Ken Watkins


 
 Even if you don't need it secure, have a login.  Dad and mom can login
 with dad or mom with no password if all you need to do is give them
 their own cookie/session.
 
 

Optionally, I just thought that if this was too much for them to
do/remember, they could have their own bookmarks, like Dad - Yoursite
(http://www.yoursite.com/index.php?person=dad) and Mom - Yoursite
(http://www.yoursite.com/index.php?person=mom) and set the
session/cookie or whatever you're doing based on $_GET['person'].

I would still opt for the login though, even if not secure.

-- 
Thanks!
-Shawn
http://www.spidean.com

-- 
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 !--  
start_search -- line, it would start parsing, and stop again when it  
reached the !-- stop_search -- 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 stut...@gmail.com

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

div id=divContent
!-- content begin --
sofihsod hiosdh sdh gus us u sg
!-- content end --
/div

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?



?php

function contentString($pString, $pStart, $pStop){
echo $pStringbr /;

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

	for ($i=1; $icount($exploded1); $i++) // ignore first item (0)  
in 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 br /br /;
}

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



[PHP] PHP and making a ZIP file

2009-03-26 Thread Ron Piggott
Does anyone know how to make a ZIP file using PHP?  This is for an
application where the files the user selected will be put into a ZIP
file and then the ZIP file made available for download.  Ron


Re: [PHP] PHP and making a ZIP file

2009-03-26 Thread Chris

Ron Piggott wrote:

Does anyone know how to make a ZIP file using PHP?  This is for an
application where the files the user selected will be put into a ZIP
file and then the ZIP file made available for download.  Ron


http://www.php.net/zip would be a good place to start.

Or http://pear.php.net/package/File_Archive if your host can't/won't 
install the requirements.


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


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