Re[2]: [PHP] Simultaneus execution

2004-08-29 Thread Eugene
Maybe you can use classes in this case? I'm using them when I need to
process the same object or to assign some simultaneous actions to
many objects at the same time.

Sunday, August 29, 2004, 6:40:42 AM, you wrote:

> An example would be the execution of a function. Let's say that I can't
> execute one same function twice, but how can I execute it again, before the
> first execution has completed?

> Regards, Andrew

> "Jason Wong" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
>> On Sunday 29 August 2004 09:56, Andrew wrote:
>>
>> > Do anyone have an idea how to execute 2 different functions in the same
>> > moment, no matter if they're system or custom ones. For example, how can
> I
>> > execute 2 different loops simultaneously?
>>
>> I'm curious at what you're trying to achieve. Could you elaborate?
>>
>> --
>> Jason Wong -> Gremlins Associates -> www.gremlins.biz
>> Open Source Software Systems Integrators
>> * Web Design & Hosting * Internet & Intranet Applications Development *
>> --
>> Search the list archives before you post
>> http://marc.theaimsgroup.com/?l=php-general
>> --
>> /*
>> QOTD:
>> "What do you mean, you had the dog fixed?   Just what made you
>> think he was broken!"
>> */




-- 
Best regards,
 Eugenemailto:[EMAIL PROTECTED]

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



[PHP] Save new page in file

2004-08-29 Thread Eugene
Hi! I have a HTML page generated from XSLT template by Java servlet that
opens in a new window. How can be possible to read the content of
this page and save it in file without user participation? I cant
recompile the servlet, but I need to read the request generated by it. The
page that sends request to servlet its PHP page. Please give me some ideas...

Thanks in advance.

-- 
Best regards,
 Eugenemailto:[EMAIL PROTECTED]

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



Re: [PHP] newbie help, pressing the submit button returns nothing

2003-04-04 Thread Eugene Mah
At 08:24 04-04-03 -0500, you wrote:
On Friday 04 April 2003 07:43 am, Petre Agenbag wrote:
> Your problem is not with PHP but with basic HTML.
> Your  tag needs an action="www.somepage.com" in order to "do"
> something. With PHP, you can call the same page back onto itself.
Hi Petre, Thanks for the reply, I have actually tried this too and all the
output I get is "Welcome !" but the username that was entered into the form
box should appear between the Welcome and !, Please take a look at the code
below:
>>First page named: jobapp.html

-


Practice app
Fill in the name and echo it back to the user.

Please enter your name:





---
>>Second page: named jobapp_action.php
Welcome !
Unless your register_globals is set to on,
you should be using


instead

Eugene

-----
Eugene Mah, M.Sc., DABR   [EMAIL PROTECTED]
Medical Physicist/Misplaced Canuck[EMAIL PROTECTED]
Department of Radiology   "For I am a Bear of Very Little
Medical University of South Carolina   Brain, and long words Bother
Charleston, South Carolina me."   Winnie the Pooh
http://www.netcom.com/~eugenem/
PGP KeyID = 0x1F9779FD, 0x319393F4
PGP keys available on request ICQ 3113529 O-
-
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] countries

2002-06-04 Thread Eugene Lee

Why not go to the source?


http://www.iso.org/iso/en/prods-services/iso3166ma/02iso-3166-code-lists/list-en1.html


-- 
Eugene Lee
[EMAIL PROTECTED]

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




Re: [PHP] mysql_num_rows always returns 1?

2002-06-18 Thread Eugene Mah

At 13:00 18-06-02 +0100, Mark Colvin wrote:
>The function below works when I pass in a valid username and password and
>returns '1'. When I pass a username and password that is not in the database
>it still returns '1'. I have put some echo statements in for debugging and
>the value of $numresult is always '1'. Does mysql_num_rows retain results in
>memory or something like that or am I completely going down the wrong road?

that's because when 'select count(*)' = 0 when it finds no results.
So you get a record returned to $result with a single line that tells
you count(*) was 0.

what you should probably do is instead of counting, check for a valid
username/password returned by your query.  if they're blank, then
$user/$pass are either incorrect or not in your users table.

or, as someone else suggested, check the value of count(*)
rather than the number of lines returned by the query.

Eugene

--
-----
Eugene Mah, M.Sc., DABR   [EMAIL PROTECTED]
Medical Physicist/Misplaced Canuck[EMAIL PROTECTED]
Department of Radiology   "For I am a Bear of Very Little
Medical University of South Carolina   Brain, and long words Bother
Charleston, South Carolina me."   Winnie the Pooh
http://home.netcom.com/~eugenem/
PGP KeyID = 0x1F9779FD, 0x319393F4
PGP keys available on request ICQ 3113529 O-
-


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




[PHP] issues with PHP 4.1.2 / solaris 2.6 / gcc 3.1

2002-06-26 Thread Eugene Mah

After replacing hard drives and reinstalling solaris 2.6 onto
my Sparc 20, I'm getting the following error when starting up
Apache 1.3.26 and PHP 4.1.2

Syntax error on line 205 of /export/home/eugenem/apache/conf/httpd.conf:
/export/home/eugenem/apache/bin/httpd: fatal: relocation error: file
/export/home/eugenem/apache/libexec/libphp4.so: symbol ap_block_alarms:
referenced symbol not found

I've also been having problems building mod_perl into Apache, but
that's a question for another list.

Aside from a new version of Apache, this combination was working
quite well on my system before having to redo everything.
I'm starting to suspect gcc (3.1), but everything (Apache, PHP, MySQL)
compiles without complaint.  that said, everything on the old system
was built using gcc 3.0.4 or 2.96.3 instead of gcc 3.1.
i may end up going back to gcc 3.0.4 to see if i can get things working
again.

when compiling php 4.2.1 on solaris 2.6/gcc 3.1, i also get an error
about not finding unix.h.

Can anybody offer any suggestions?

thanks
eugene


--
-----
Eugene Mah, M.Sc., DABR   [EMAIL PROTECTED]
Medical Physicist/Misplaced Canuck[EMAIL PROTECTED]
Department of Radiology   "For I am a Bear of Very Little
Medical University of South Carolina   Brain, and long words Bother
Charleston, South Carolina me."   Winnie the Pooh
http://home.netcom.com/~eugenem/
PGP KeyID = 0x1F9779FD, 0x319393F4
PGP keys available on request ICQ 3113529 O-
-


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




Re: [PHP] Re: HTTP_REFERER

2003-09-12 Thread Eugene Lee
On Fri, Sep 12, 2003 at 09:11:09AM +0200, Catalin Trifu wrote:
: 
: "Louie Miranda" <[EMAIL PROTECTED]> wrote:
: >
: > Does php support this? HTTP_REFERER
: > or simply cgi and ssi only?
: 
: It does support any HTTP information, and since
: HTTP_REFERER is part of the HTTP spec. it is supported.
: You can find it in the $_SERVER variable.
: FYI: The referer is not a reliable information.

Several Windoze firewalls also filter out HTTP_REFERER.


-- 
Eugene Lee
http://www.coxar.pwp.blueyonder.co.uk/

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



Re: [PHP] Re: HTTP_REFERER

2003-09-12 Thread Eugene Lee
On Fri, Sep 12, 2003 at 03:53:22PM +0800, Louie Miranda wrote:
: "Eugene Lee" mentioned:
: >
: > Several Windoze firewalls also filter out HTTP_REFERER.
: 
: what can you suggest, im trying to do a referer email program on a website
: and i think HTTP_REFERER will be my first approach, but limited on some
: browsers and firewall.
: 
: What can you suggest for a dynamic page?

It depends on what exactly you are trying to accomplish.  Are you trying
to restrict access to your email program based on the HTTP_REFERER which
may be real or may be forged?

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



Re: [PHP] Re: HTTP_REFERER

2003-09-12 Thread Eugene Lee
On Fri, Sep 12, 2003 at 04:21:16PM +0800, Louie Miranda wrote:
: Eugene Lee mentioned:
: > On Fri, Sep 12, 2003 at 03:53:22PM +0800, Louie Miranda wrote:
: > : "Eugene Lee" mentioned:
: > : >
: > : > Several Windoze firewalls also filter out HTTP_REFERER.
: > :
: > : what can you suggest, im trying to do a referer email program on a
: > : website and i think HTTP_REFERER will be my first approach, but
: > : limited on some browsers and firewall.
: >
: > It depends on what exactly you are trying to accomplish.
: 
: no, im making a "send this page to a friend program"
: when the users click the button a small pop-up window will come out
: and the http_referer will work and catch the previous page.

Since it's a button, you could always send the SCRIPT_FILENAME to the
pop-up window via a GET or POST method.

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



[PHP] square brackets in form names violate HTML specs?

2003-09-13 Thread Eugene Lee
Something I've noticed in PHP is a proliferation of code like this:



According to the specs, the square brackets in "stuff[title]" are
technically illegal.

http://www.w3.org/TR/html4/types.html#h-6.2

ID and NAME tokens must begin with a letter ([A-Za-z]) and may
be followed by any number of letters, digits ([0-9]), hyphens
("-"), underscores ("_"), colons (":"), and periods (".").

Thoughts?  Suggestions for writing flexible PHP code that at least
passes the HTML 4.01 Transitional DTD?

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



Re: [PHP] htmlentities() and the macintosh character set

2003-09-13 Thread Eugene Lee
On Sat, Sep 13, 2003 at 11:24:56AM -0700, Michael Winston wrote:
: 
: The request:  Can the macintosh character set be added as an option for 
: htmlentities() and other commands?  That would be so helpful for our 
: mac-based company.
: 
: The problem:  I'm fairly new to php and have found that the macintosh 
: character set is pretty different from other standard sets, so when 
: someone in our company enters an em-dash (an extended dash, that would 
: be represented as &emdash; in html) into our SQL database, browsers 
: display it as Ñ (Ñ) because that's the correct mapping in other, 
: standard sets.  Of course, I could do a replace on that character, but 
: there are another 6 characters that I know of that will cause problems, 
: and probably more beyond that.  The quick and good way is to convert 
: with htmlentities(), but the mac charset is lacking.
: 
: Any suggestions how to fix this?

You could modify the HTML translation table and add Mac specific
characters to the mix.



I wonder if anyone has already done the work for the other entites.
Anyways, if not, you can always build your own from Apple's list:

http://developer.apple.com/documentation/mac/Text/Text-516.html#MARKER-9-3

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



Re: [PHP] square brackets in form names violate HTML specs?

2003-09-13 Thread Eugene Lee
On Sat, Sep 13, 2003 at 06:15:29PM +, Curt Zirzow wrote:
: * Thus wrote Eugene Lee ([EMAIL PROTECTED]):
: > Something I've noticed in PHP is a proliferation of code like this:
: > 
: > 
[...]
: The way to properly do it would be to set set your name as:
: 
: 

Great idea, thanks Curt!

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



Re: [PHP] (Conclusion) Re: [PHP] Program works only when there are records :-(

2003-09-14 Thread Eugene Lee
On Mon, Sep 15, 2003 at 02:15:56AM +0200, Ryan A wrote:
: 
: Its a version problem, UNION was not implempted till V4, and my host has
: V3.23
: Anybody know of a work around with my code? I have found some work arounds
: on google but its too advanced for me...i dont really understand left joins,
: right joins etc

The user notes in the MySQL documentation includes some suggestions that
work around UNION-less MySQL 3.x systems.

http://www.mysql.com/doc/en/UNION.html

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



Re: [PHP] Re: HTTP_REFERER

2003-09-14 Thread Eugene Lee
On Mon, Sep 15, 2003 at 07:58:25AM +0800, Louie Miranda wrote:
: Eugene Lee mentioned:
: > On Fri, Sep 12, 2003 at 04:21:16PM +0800, Louie Miranda wrote:
: > : Eugene Lee mentioned:
: > : > On Fri, Sep 12, 2003 at 03:53:22PM +0800, Louie Miranda wrote:
: > : > : "Eugene Lee" mentioned:
: > : > : >
: > : > : > Several Windoze firewalls also filter out HTTP_REFERER.
: > : > :
: > : > : what can you suggest, im trying to do a referer email program on a
: > : > : website and i think HTTP_REFERER will be my first approach, but
: > : > : limited on some browsers and firewall.
: > : >
: > : > It depends on what exactly you are trying to accomplish.
: > : 
: > : no, im making a "send this page to a friend program"
: > : when the users click the button a small pop-up window will come out
: > : and the http_referer will work and catch the previous page.
: > 
: > Since it's a button, you could always send the SCRIPT_FILENAME to the
: > pop-up window via a GET or POST method.
:
: SCRIPT_FILENAME, sorry but i didnt get this part.

On URL A, $_SERVER['SCRIPT_FILENAME'] reports URL A.  And on that page,
if you click on a link that takes you to URL B, then in URL B you'll get
$_SERVER['HTTP_REFERER'] that also says URL A.

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



Re: [PHP] How to comment out chunk of html/php mixed code?

2003-09-15 Thread Eugene Lee
On Mon, Sep 15, 2003 at 08:59:53PM +0100, Wei Wang wrote:
: 
: This may sound very newbie. But since html comment uses 
: which doesn't comment out the php code. And the php comment /**/ //
: apparently doesn't work on html. So how do I comment out a chunk of
: html/php mixed code? 

Remove the chunk of mixed code and save it into an external PHP file,
e.g. mixed_code.php.  In place of removed chunk, use an include() or
require() statement, e.g. include("mixed_code.php").  Now comment
that one line in or out as needed.

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



Re: [PHP] abreviating echo commands

2003-09-15 Thread Eugene Lee
: Kris Yates <[EMAIL PROTECTED]> wrote:
: > 
: > I forget where but I found some source awhile back that abbreviated 
: > echo.  It was something like
: >  which worked the same as .  Maybe it was 
: > .. Obviously I dont remember.. which is why I am asking..  
: > :)  Does anyone have a link to something that talks about how to 
: > abbreviate commands in PHP?

Is this what you meant?


http://www.php.net/manual/en/language.basic-syntax.php#language.basic-syntax.phpmode

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



Re: [PHP] RE: $_SELF[PHP_SELF] not working anymore

2003-09-16 Thread Eugene Lee
On Tue, Sep 16, 2003 at 03:30:39PM +, Curt Zirzow wrote:
: * Thus wrote Maria Garcia Suarez ([EMAIL PROTECTED]):
: > --- Javier Tacon <[EMAIL PROTECTED]> wrote:
: > 
: > > Try with $_SERVER["PHP_SELF"]
: > 
: > Then I get:
: > 
: > Parse error: parse error, unexpected
: > T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or
: > T_VARIABLE or T_NUM_STRING in
: > 
: > This is how I use it:
: > $currentAddress="$_SERVER[HTTP_HOST]$_SERVER[PHP_SELF]";
: 
: You should always quote your array keys (cept if all the keys are
: numeric.  Also when inside a string, enclose your variables with
: {}.
: 
: $currentAddress="{$_SERVER['HTTP_HOST']}{$_SERVER['PHP_SELF']}";

How about:

$currentAddress = $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];

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



Re: [PHP] Control Structure problem

2003-09-16 Thread Eugene Lee
On Wed, Sep 17, 2003 at 12:49:03AM +, Curt Zirzow wrote:
: 
:   switch ($var)  {
: case 'TEST-1': case 'TEST-2': case 'TEST-2':
:   do something
:   }

The switch statement doesn't do an equivalency test, does it?  So while
this switch statement can be rewritten as:

if (($var == 'TEST-1') || ($var == 'TEST-1') || ($var == 'TEST-1'))
{
do something
}

it doesn't do:

if (($var === 'TEST-1') || ($var === 'TEST-1') || ($var === 'TEST-1'))
{
do something
}

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



Re: [PHP] Control Structure problem

2003-09-16 Thread Eugene Lee
On Wed, Sep 17, 2003 at 01:29:26PM +1000, Tom Rogers wrote:
: Wednesday, September 17, 2003, 11:47:45 AM, Eugene Lee wrote:
: 
: EL> The switch statement doesn't do an equivalency test, does it?
[...]
: EL> it doesn't do:
: 
: EL> if (($var === 'TEST-1') ||
: EL>($var === 'TEST-1') ||
: EL>($var === 'TEST-1'))
: EL> {
: EL> do something
: EL> }
: 
: You can do it this way I think :)
: 
: switch (true)  {
:  case ($var === 'TEST-1')?true:false:
:  case ($var === 'TEST-2')?true:false:
:  case ($var === 'TEST-2')?true:false:
:do something
: }

Oh man, that's just sick...

I guess, for the sake of performance and readability, it's probably
easier to do an is_string($var) (or whatever variable type) before
doing a normal switch statement.

Still... that's just sick...

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



[PHP] consistent PHP function names?

2003-09-17 Thread Eugene Lee
One thing that's always bothered me about PHP is that the function names
are not terribly consistent.  For example, when are underscores okay?
strip_tags() has an underscore but stripslashes() does not.  Also,
should inverse functions be named appropriately?  htmlentities() and
html_entity_decode() are inverse functions.  But seems to make more
sense to rename htmlentities() to html_entity_encode().  Something like
a class[_subclass1[_subclass2[...]]]_method nomenclature makes sense.

Then you have really weird stuff.  For example, md5() is listed as a
"string function" since it takes a string, calculates the MD5 hash, and
returns said hash.  Makes sense.  Then you have md5_file(), which takes
a filename, calculates the MD5 hash of the file's contents, and returns
said hash.  But md5_file() is listed as a "string function".  To me, it
makes more sense to be classified as a "filesystem function", and maybe
even rename the function to file_md5().

Thoughts?

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



Re: [PHP] when clients go bad

2003-09-18 Thread Eugene Lee
On Thu, Sep 18, 2003 at 05:31:52PM -0400, Tim Thorburn wrote:
: 
: As this is a very small market, for this one client I did not create a 
: contract - there was however a very detailed proposal which did not include 
: any source files.  Whether it'll stand or not, we also had a verbal 
: agreement that they did not want any source files as at the time that we 
: began our relationship, I had informed them that the source files would 
: cost extra - the client at that time agreed that they did not want any 
: source code.

Sounds fine to me.  Unless you signed a contract saying that your code
belongs to someone else in exchange for something like money, then it's
still your code.

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



Re: [PHP] Session with various Browser.

2003-09-19 Thread Eugene Lee
On Fri, Sep 19, 2003 at 02:39:21PM +1000, Justin French wrote:
: 
: Re-enforcing this is the fact that (AFAIK) no Mac browsers display 
: in-line PDFs via a plug-in -- they open 'Acrobat' or 'Preview' to 
: display them -- in other words, the PDF file should not be considered 
: part of the web application, therefor does not require session headers.

For Mac OS X folks, there is a browser plugin to view PDFs.

http://www.schubert-it.com/pluginpdf/

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



[PHP] forcing variable expansion

2003-09-19 Thread Eugene Lee
If I have a block of text saved in an external text file, e.g.:

All {$badstuff} and no {$goodstuff} makes {$name} a dull {$type}.

after reading the text into a string, is there a way to force variable
expansion?  In a sense, it's like having a heredoc for multiline strings
with variable expansion while not having the heredoc embedded in PHP code.

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



Re: [PHP] forcing variable expansion

2003-09-19 Thread Eugene Lee
On Fri, Sep 19, 2003 at 03:50:40PM -0500, Jay Blanchard wrote:
: 
: Eugene Lee asked:
: >
: > If I have a block of text saved in an external text file, e.g.:
: > 
: > All {$badstuff} and no {$goodstuff} makes {$name} a dull
: > {$type}.
: > 
: > after reading the text into a string, is there a way to force variable
: > expansion?  In a sense, it's like having a heredoc for multiline strings
: > with variable expansion while not having the heredoc embedded in PHP
: > code.
: 
: http://us3.php.net/eval maybe?

This will work, thanks!

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



Re: [PHP] Clear ALL Cookies previously set

2003-09-20 Thread Eugene Lee
On Fri, Sep 19, 2003 at 09:14:57PM -0400, Stevie D Peele wrote:
: 
: How can I clear all cookies that have been previously set?
: 
: I want this in an if statement so something like
: 
: if ($value == $blue){
: clear all cookies;
: setcookie("name",time()+3600);
: }

Walk through your $_COOKIE array and expire each one:

if ($value == $blue)
{
foreach ($_COOKIE as $name => $value)
{
setcookie($_COOKIE["$name"], "", time()-3600);
}
}

But I don't know what might happen if you use setcookie() to expire a
cookie and then use setcookie() later on to set the same cookie.

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



Re: [PHP] Problem with getting non-blocking data from stdin

2003-09-20 Thread Eugene Lee
On Sat, Sep 20, 2003 at 02:14:54AM -0400, Robert Cummings wrote:
: On Sat, 2003-09-20 at 01:53, Dan Anderson wrote:
: >
: > I find your responses to my e-mails quite humorous.  Upon review --
: > aside from a single WTF -- I don't think I was condescending in any way
: > shape or form.  I was just trying to offer help.
: 
: The particular shape of your help was non newbie friendly. I think that,
: combined with your incorrect assessments made it all the more annoying.
: And yes, "WTF" and "you really need to read the documentation" played a
: key part also since they were quite condescending, and inappropriate
: given your incorrect answers and knowledge of functionality.
[...snips snipped...]

Can't we just get along and bash M$ ?  Or VeriSign ?  :-)

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



Re: [PHP] Trying to View php.ini

2003-09-21 Thread Eugene Lee
On Sat, Sep 20, 2003 at 06:19:25PM -0400, Stephen Tiano wrote:
: 
: I'm on a Mac PowerBook. I'm able to locate the php.ini file. But when I 
: open it with BBEdit, it's a blank page. I just want to open it and 
: either view it, or make a copy to view. But all I have is the blank. Any 
: suggestions?

If you're talking about PHP 4.1.2 currently shipping with Mac OS X,
it does not come with a php.ini file anywhere (although you can grab
one from the source distribution and install it in /usr/lib).

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



Re: [PHP] consistent PHP function names?

2003-09-22 Thread Eugene Lee
On Sun, Sep 21, 2003 at 09:10:16AM -0700, Raquel Rice wrote:
: 
: On Wed, 17 Sep 2003 21:22:36 +1000
: Justin French <[EMAIL PROTECTED]> wrote:
: 
: > I posted a similar topic a few months back.  I guess the answer is
: > that the collaborative nature of open source, and the fact that
: > PHP has grown from very humble beginnings has meant that naming
: > standards and conventions are a little lacking.
: > 
: > It would've been nice if these issues were rectified in PHP5 with 
: > deprecated aliases to the old names left in for backwards 
: > compatibility, but it'd be a HUGE job :)
: 
: I suppose that if this really bothers someone, they could create
: their own aliases.
: 
: function decodehtmlentities($string, $quote_style, $charset) {
: return html_entity_decode($string, $quote_style, $charset);
: }

That's simply an additional function call, which slows things down just
a little more.  But it's probably still faster than object methods.  :-)

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



Re: [PHP] Re: forcing variable expansion

2003-09-22 Thread Eugene Lee
On Sun, Sep 21, 2003 at 03:01:41PM -0400, Rich Fox wrote:
: "Eugene Lee" <[EMAIL PROTECTED]> wrote:
: >
: > If I have a block of text saved in an external text file, e.g.:
: >
: > All {$badstuff} and no {$goodstuff} makes {$name} a dull {$type}.
: >
: > after reading the text into a string, is there a way to force variable
: > expansion?  In a sense, it's like having a heredoc for multiline strings
: > with variable expansion while not having the heredoc embedded in PHP code.

Question already answered by another helpful soul: use eval().

: That's not Eugene from the dojo is it?

Hmmm?  What dojo?

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



Re: [PHP] Clear ALL Cookies previously set

2003-09-22 Thread Eugene Lee
On Mon, Sep 22, 2003 at 10:18:21AM +0200, Marek Kilimajer wrote:
: 
: Eugene Lee wrote:
: >
: >But I don't know what might happen if you use setcookie() to expire a
: >cookie and then use setcookie() later on to set the same cookie.
: 
: www.php.net/set_cookie :
: 
:  In PHP 3, multiple calls to setcookie() in the same script will be 
: performed in reverse order. If you are trying to delete one cookie 
: before inserting another you should put the insert before the delete. In 
: PHP 4, multiple calls to setcookie() are performed in the order called.

This only explains how cookies are sent from a PHP script.  My question
(sorry, should've been clearer) deals with how the browser handles such
multiple cookies.

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



Re: [PHP] speaking of php editors

2003-09-23 Thread Eugene Lee
On Tue, Sep 23, 2003 at 12:28:12AM +, Curt Zirzow wrote:
: * Thus wrote Chris W. Parker ([EMAIL PROTECTED]):
: > 
: > I am looking for an editor that will highlight the string
: > "{$array['index']['index']}" within a string.
: > 
: > For example:
: > 
: > +- gray +
: > |   |
: > |  +-- red ---+ |
: > |  |  | |
: > $variable = "The amount is {$amount[0]}.";
:    ^^ ^^ +*%%#^#+^^
:   |  ||  |    |
: Green <---'---'---'
:  ||  |   | ||
: Red +'--'
:   |  |   | |
: Dk. Red #'-'
:   |  |
: Yellow *--'  |
:  |
: Blue %---'
: 
: Thats vi's coloring :)

Plain vi does not do syntax highlighting.  Perhaps you are using a
vi-derivative, like Vim.

http://www.vim.org/

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



Re: [PHP] date conflict with old news archive

2003-09-23 Thread Eugene Lee
On Tue, Sep 23, 2003 at 09:01:19PM +0100, [ PAUL FERRIE ] wrote:
: 
: God i hope this is simple :)

It is.  I think.  :-)

: I have news bloggs section on my site.  At present the news is loaded in
: from a txt file,  most of the site is now running with most sections being
: loaded via mysqldb's.
: I would like to add the old entries to the new db that i have setup for the
: bloggs.
: My problem is converting the date format from 12-08-03 to the time stamp to
: be stored int the db.  It has to be done this way as new entries will be
: using the time stamp
: 
: So in the php file i have
: $dateAdded =  time();
: but time would then be 1064245532
: i need
: date=12-08-03
: $dateAdded = date(convert) to time stamp

$dateAdded = mktime(0, 0, 0, 12, 8, 2003);

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



Re: [PHP] help with arrays

2003-09-23 Thread Eugene Lee
On Tue, Sep 23, 2003 at 01:49:03PM -0700, Chris W. Parker wrote:
: 
: Robert Cummings  said:
: >
: > foreach( $data as $key => $value )
: 
: I don't use that syntax much so I'm not familiar with it. Maybe I should
: start eh?

Another caveat: it works on a *copy* of the array.  This is fine for
small arrays, but may be a performance killer for larger arrays.

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



Re: [PHP] help with arrays

2003-09-23 Thread Eugene Lee
On Tue, Sep 23, 2003 at 05:44:46PM -0400, Robert Cummings wrote:
: On Tue, 2003-09-23 at 17:37, Eugene Lee wrote:
: > On Tue, Sep 23, 2003 at 01:49:03PM -0700, Chris W. Parker wrote:
: > : 
: > : Robert Cummings <mailto:[EMAIL PROTECTED]> said:
: > : >
: > : > foreach( $data as $key => $value )
: > : 
: > : I don't use that syntax much so I'm not familiar with it. Maybe I should
: > : start eh?
: > 
: > Another caveat: it works on a *copy* of the array.  This is fine for
: > small arrays, but may be a performance killer for larger arrays.
: 
: I don't think you have enough knowledge of the PHP internals to make
: that claim :)

You're right.  I know little of PHP internals.  I'm just going by what
little the official documentation tells me.  :-)

http://www.php.net/manual/en/control-structures.foreach.php

Note: Also note that foreach operates on a copy of the specified
array and not the array itself.

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



Re: [PHP] PHP Editor - which to use?

2003-09-24 Thread Eugene Lee
On Wed, Sep 24, 2003 at 01:04:45PM -0400, Kevin Bruce wrote:
: 
: Thanks:) I'll give BBedit a go for a week and let you know how it turns out.
: Yes, Dreamweaver does sucketh much, but it's great for hashing out the page
: (WYSIWYG style) then tweeking the code. I Hate (capital H) hand typing
: nested tables.*  :P

IMHO, Golive 6 is better than Dreamweaver MX for editing tables.  :-)

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



Re: [PHP] About php String function

2003-09-24 Thread Eugene Lee
On Thu, Sep 25, 2003 at 10:48:19AM +0530, Uma Shankari T. wrote:
: 
: I am using strpos function for finding the string position in a
: particular string .If the string value is equal to zero or greater 
: than zero some steps to be executed. If the position is empty it is taking 
: as zero value and executing the steps under equal to zero loop..Is there 
: any method avoid doing that ??

The online manual for strpos() documents this:

http://www.php.net/manual/en/function.strpos.php

$mystring = 'abc';
$findme   = 'a';
$pos = strpos($mystring, $findme);

// Note our use of ===.  Simply == would not work as expected
// because the position of 'a' was the 0th (first) character.
if ($pos === false) {
echo "The string '$findme' was not found in the string '$mystring'";
} else {
echo "The string '$findme' was found in the string '$mystring'";
echo " and exists at position $pos";
}

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



Re: [PHP] What to use?

2003-09-25 Thread Eugene Lee
On Thu, Sep 25, 2003 at 10:01:48PM +0200, Ryan A wrote:
: 
: I am running a query on the database to get the avg of a few fields, I am
: getting a result something like this:
: 
: 5.
: 4.
: 5.
: 
: I dont want to use such big averages and want to cut the last to digits off
: so it will be something like:
: 5.00
: 4.00
: 44.23
: etc

Why not keep the precision internally and only deal with it as an output
formatting issue when you display the results?

$a = 5.;
printf("\$a = %.2f \n", $a);

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



Re: [PHP] Submit button

2003-09-28 Thread Eugene Lee
On Sun, Sep 28, 2003 at 12:49:27PM +0200, Karina S wrote:
: 
: I want to use an image as submit button on my form. Now I use the following
: code with button:
: 
:   if (!(isset($_Post['SubmitForm'])))
:   {
: ...
: .
:  
: }
: else
: {
: .
: }
: 
: Is it possible to change the Submit button with an image?

Yep.  It's a feature of HTML.



Note that the x,y coordinates of where you clicked on the image gets
submitted as "SubmitForm.x" and "SubmitForm.y", so watch out for the
existence of these variables.

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



Re: [PHP] where are the good examples of using OOP?

2003-09-28 Thread Eugene Lee
On Sun, Sep 28, 2003 at 12:52:40PM +0200, anders thoresson wrote:
: 
:  I wonder if someone can point me to tutorials that uses real PHP examples 
: instead, examples that shows me in a direct way how to use OOP. My biggest 
: trouble right now is what should be the classes and what should be the 
: methods.

Objects should try to model a real thing.  A thing may have properties
(e.g. weight, color, dimensions, temperature, gender, age) and/or states
(e.g. solid/liquid/gas, running/ready/waiting, eating/sleeping/working);
properties are stored in instance variables.  And the thing can do tasks
or have tasks done to them; these tasks are your methods.

Here's a simple exercise you can do: make a "watch" class that models a
real watch.  You can get the current time from a watch; and you can also
set the watch's time.  This class should have 3 methods (i.e. 2 methods
and 1 constructor) and 1 instance variable.  If you use Unix timestamps,
this should be really short (maybe around 10 lines of PHP code).

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



Re: [PHP] Submit button

2003-09-28 Thread Eugene Lee
On Sun, Sep 28, 2003 at 01:20:32PM +0200, Karina S wrote:
: 
: I have changed the code, but it doesn't work.
: 
:  if (!(isset($_Post['SubmitForm_x'])))
:   {
: ...
: .
:  
: }
: else
: {
: .
: }

1. The superglobal array is $_POST (all caps), not $_Post.

2. Make sure the URL path to your image file is correct, i.e. change
"image.gif" to the relative or absolute URL.

3. The "alt" attribute is technically unneeded.

4. When in doubt:

print_r($_POST);

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



Re: [PHP] General .htaccess question

2003-09-29 Thread Eugene Lee
On Sun, Sep 28, 2003 at 08:53:13PM -0400, Mike Brum wrote:
: 
: I think I know the answer to this, but want some confirmation from someone a
: bit more knowledgable about Apache and .htaccess files.

Okay.

: My webhost has the default 404 page set to 404.html. For the sake of
: consistancy on a number of levels, I prefer a PHP file for this (404.php).
: So to do this, I created a basic .htaccess file for this very purpose and it
: sits in the root dir.

Sure.

: Now, does this .htaccess file get read for EVERY resource request on my site
: - even when the page is found?

Yes.

: Aside from a META redirect from 404.html to 404.php, is there a less
: server-intensive way to set my 404 in Apache when I don't have root access?

No.

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



Re: [PHP] php and checkboxes.

2003-09-29 Thread Eugene Lee
On Mon, Sep 29, 2003 at 01:43:08PM +0200, Angelo Zanetti wrote:
: 
: Marek Kilimajer suggested:
: >
: > Angelo Zanetti wrote:
: > >
: > > I have a table that is populated from a database which gets the
: > > IDs of the records from a php array.Every row in the table has a
: > > checkbox next to the actual record, what I want to do is to allow
: > > the user to select the records they want to remove by clicking the
: > > checkbox(es) and then click a button to submit the form.
: > >
: > > so how do I remove these records?
: > 
: > Simple:
: > foreach($_POST['del_checkboxes'] as $id) {
: > $sql="delete from table where id='$id'";
: > }
: 
: I dont actually want to delete the record from the database, perhaps I
: wasnt very clear in my explanation, but I just need to remove that
: entry from the table.

To remove a record is to delete a row.  Same thing.  When you say
"entry", do you mean "record" or "row"?  Or do you mean something else?

If you want to change "one or more columns of a row" (this can also
be stated as "one or more fields of a record"), use the SQL command
"UPDATE  SET col1=expr1,col1=expr2,... WHERE ID=id_expr".

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



Re: [PHP] Resource Limits

2003-09-29 Thread Eugene Lee
On Mon, Sep 29, 2003 at 07:49:40AM -0500, Donald Tyler wrote:
:
: Decapode Azur asked:
: > 
: > How can I get the values of 'max_execution_time', 'max_input_time' and 
: > 'memory_limit' from my php script ?
:
: Just incase you weren't aware. You can change the Max execution time
: during the script with:
: 
: set_time_limit(Milliseconds);

That should be seconds, not milliseconds.  :-)

http://www.php.net/manual/en/function.set-time-limit.php

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



Re: [PHP] control M from export file

2003-09-29 Thread Eugene Lee
On Sun, Sep 28, 2003 at 06:58:57PM -0700, Ed Kwok wrote:
: 
:I am running into problem parsing a file exported from MS excel.  I 
: have exported the file as asci format, but there is a control "M" 
: append to my document.  What is this control "M" and how can I delete 
: without manually replace it? Is there any automated function I could 
: use?  Thanks.

The CONTROL-M character is showing up because of newline differences
between different OSes.  You need a program that converts text files
between the different formats, i.e. does newline translations between
Mac, Unix, and DOS.

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



Re: [PHP] Initial Value for Input Box

2003-09-29 Thread Eugene Lee
On Mon, Sep 29, 2003 at 05:46:15PM -0400, Matt Palermo wrote:
: 
: I have a form that a user can fill out.  In the text input field I allow
: them to insert HTML tags with their input data.  They can then submit the
: form for processing.  The problem is that later on when they go to edit
: their inputs (I initialize the text input with their previously submitted
: input) and they have HTML tags with double quotes, the it will only put
: characters up to the first double quote inside the input box and the rest
: will go outside of it.  I would like the text box to contain everything they
: previously submitted to be displayed there.  Does anyone know of an easy way
: to allow the double quotes to be initially inserted into the input box?

Look at htmlentities() or htmlspecialchars().

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



Re: [PHP] PNGs & PHP feedback

2003-09-30 Thread Eugene Lee
On Tue, Sep 30, 2003 at 02:40:42AM -0400, Joe Harman wrote:
: 
: I am looking for some guidance... I am using PHP to make dynamic
: buttons... Is the PNG image format a pretty safe thing to go with...
: Standard wise?

PNG support in M$ IE is still shaky.

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



Re: [PHP] arrays and php

2003-09-30 Thread Eugene Lee
On Tue, Sep 30, 2003 at 09:10:44AM -0700, Chris W. Parker wrote:
: 
: Angelo Zanetti 
: on Tuesday, September 30, 2003 5:43 AM said:
: 
: > hi I have a table with rows and each row contains a checkbox ( array)
: > and a record. TD of the checkbox:
: > echo(" value=". $chkSessionF[$i] .">");
: 
: Firstly you should be putting double quotes around every value in your
: HTML tags.
: 
: Revised: (watch wrap)
: 
: echo "";

A heredoc is more readable:

echo <<
HTMLTAG;

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



Re: [PHP] PNGs & PHP feedback

2003-09-30 Thread Eugene Lee
(about M$IE and PNG)

On Wed, Oct 01, 2003 at 11:31:46AM +0900, - Edwin - wrote:
: 
: Curt Zirzow <[EMAIL PROTECTED]> wrote:
: >
: > It does have a problem reading alpha channels in the pngs though.
: 
: Quite true. (I "forgot" that part...) Though it seems like it's not a
: problem for the IE on Macs...

M$IE for the Mac uses a completely different codebase from the Windoze
version and started with the home-grown Tasman engine, which at the time
was probably the most standards-compliant engine compared to anything
else on any other platform.

: ...and then I thought IE's problems were all about security and
: non-standard tags... ;)

The M$ way is "embrace, extend, extinguish".

http://www.wikipedia.org/wiki/Embrace,_extend_and_extinguish

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



Re: [PHP] Attempt at putting greedy htmlspecialchars on a diet

2003-09-30 Thread Eugene Lee
On Wed, Oct 01, 2003 at 01:12:16AM -0400, Gerard Samuel wrote:
: 
: Got a problem with htmlspecialchars being too greedy, where
: for example, it converts
: &foo;
: to
: &foo;
: 
: Yes it displays correctly in the browser for some content, but not all.  
: (an example is posted below)
: So I came up with this example code, but not sure if there is an 
: easier/better way to get the correct end result.
: If there is a better way, feel free to let me know.
: Thanks
: 
: Note: I dont read/speak chinese, so if its offensive please forgive me.
: 
: --
: http://www.foo.com/index.php?foo=1&bar=2';

The problem isn't with htmlspecialchars().  It doesn't know what parts
of the string are HTML character references and which parts are not.
But if you're willing to dig up the numeric character references for
those specific Chinese characters, then split the string into the part
that needs no translation and the part that needs it.  That is:

$foo1encoded = '中文'
$foo2raw = ' & http://www.foo.com/index.php?foo=1&bar=2';
$foo = $foo1 . htmlspecialchars(foo2raw);

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



[PHP] mmcache problems

2003-10-01 Thread Eugene Lee
Just tried installing Turck MMCache 2.4.1 on a FreeBSD box.  After
tweaking the configure script:

./configure --enable-mmcache=shared 
--with-php-config=/usr/local/bin/php-config --prefix=/usr/local

I got it to compile and install in:

/usr/local/lib/php/extensions/no-debug-non-zts-20020429/mmcache.so

But when I try to run it, I get this error (also reported in "php -m"):

PHP Warning:  Unknown(): Unable to load dynamic library './mmcache.so' - 
Cannot open "./mmcache.so" in Unknown on line 0

Not a very descriptive error message.  I appreciate any suggestions!

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



Re: [PHP] PNGs & PHP feedback

2003-10-01 Thread Eugene Lee
On Wed, Oct 01, 2003 at 04:41:28PM +0900, - Edwin - wrote:
: 
: (Sorry if this is becoming OT...)
: 
: Eugene Lee <[EMAIL PROTECTED]> wrote:
: > 
: > M$IE for the Mac uses a completely different codebase from the
: > Windoze version and started with the home-grown Tasman engine, which
: > at the time was probably the most standards-compliant engine
: > compared to anything else on any other platform.
: 
: "Surprise, surprise!" ? I heard they stopped the development of IE for
: Mac. Too bad...

Yep, M$ has halted development of IE for the Mac for a while.  But
except for your regularly scheduled security fixes, M$ has halted
development of IE for Windoze as well!  This is really annoying for
me as a web developer because I can't take full advantage of CSS.
I stopped using IE to check for the HTML correctness of my PHP code.
As long as stick with simple CSS features, I now jump between Safari,
Mozilla, and the W3C validators.

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



Re: [PHP] getting image width,height

2003-10-01 Thread Eugene Lee
On Wed, Oct 01, 2003 at 11:02:47AM +0300, Fatih Olcer wrote:
: 
: how can i get the image width and height ?

1. imagesx() and imagesy().

2. please try checking the online manual first, in the appropriate section:

http://www.php.net/manual/en/ref.image.php

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



Re: [PHP] array_diff()

2003-10-01 Thread Eugene Lee
On Wed, Oct 01, 2003 at 11:49:29AM +0200, Angelo Zanetti wrote:
: 
: I looked at the PHP manual and it doesnt say much about this function.
: what I want to know is that, do the 2 arrays have to have the same
: length of number of elements?

Nope.

Re-examine Example 1: $array1 and $array2 are different sizes.

http://www.php.net/manual/en/function.array-diff.php

 "green", "red", "blue", "red");
$array2 = array("b" => "green", "yellow", "red");
$result = array_diff($array1, $array2);
?>

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



Re: [PHP] Mail.php help

2003-10-01 Thread Eugene Lee
On Wed, Oct 01, 2003 at 08:18:21AM -0700, Eric Rounds wrote:
: 
: We have PHP 4.2 installed on Mac OS X under Apache.
: 
: The settings in the php.ini file are:
: 
: sendmail_from - [EMAIL PROTECTED]
: sendmail_path - /usr/sbin/sendmail -t -i 
: SMTP - localhost
: smtp_port - 25

Make sure that Sendmail is enabled and running on OS X.  By default,
Sendmail is disabled on OS X.

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



Re: [PHP] documentation on "<<<"

2003-10-01 Thread Eugene Lee
On Wed, Oct 01, 2003 at 01:07:35PM -0400, Rich Fox wrote:
: 
: Can someone point me to documentation on the <<< operator? I am wondering if
: there are some quirks I don't know about. Yet I can't find it documented on
: the php website.

Try searching for "heredoc".

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



Re: [PHP] Mail.php help

2003-10-01 Thread Eugene Lee
On Wed, Oct 01, 2003 at 08:31:49AM -0700, Eric Rounds wrote:
:  
: On Wednesday, October 01, 2003, at 08:26AM, Eugene Lee wrote:
: >
: >Make sure that Sendmail is enabled and running on OS X.  By default,
: >Sendmail is disabled on OS X.
: 
: Thank you! I will let the administrator know.
: 
: By the way, is there a way I can check, without looking into the
: serving Mac, to see if it is running?

The only way to be is to log into the Mac and check for a process that
looks like "/usr/sbin/sendmail -C /etc/mail/submit.cf -q1h".

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



Re: [PHP] Attempt at putting greedy htmlspecialchars on a diet

2003-10-01 Thread Eugene Lee
On Wed, Oct 01, 2003 at 02:02:08PM -0400, Gerard Samuel wrote:
: CPT John W. Holmes wrote:
: >From: "Eugene Lee" <[EMAIL PROTECTED]>
: >>On Wed, Oct 01, 2003 at 01:12:16AM -0400, Gerard Samuel wrote:
: >>:
: >>: Got a problem with htmlspecialchars being too greedy, where
: >>: for example, it converts
: >>: &foo;
: >>: to
: >>: &foo;
[...]
: >>: $foo = '中文 & http://www.foo.com/index.php?foo=1&bar=2';
: >>
: >>The problem isn't with htmlspecialchars().  It doesn't know what parts
: >>of the string are HTML character references and which parts are not.
: >>But if you're willing to dig up the numeric character references for
: >>those specific Chinese characters, then split the string into the part
: >>that needs no translation and the part that needs it.  That is:
: >>
: >>$foo1encoded = '中文'
: >>$foo2raw = ' & http://www.foo.com/index.php?foo=1&bar=2';
: >>$foo = $foo1 . htmlspecialchars(foo2raw);
: >
: >Maybe you should run html_entity_decode() on the string first, then run
: >encode again. The decode will take 中 and turn it into it's actual
: >character but not affect anything else. Then the recoding will turn it back
: >into 中 and also encode any other characters.
: 
: Eugene, your example leads me to believe that one knows before hand
: what characters needs special attention, in order to not run it
: through htmlspecialchars.  I would never know what characters needs
: special attention.

But it seems that you do know what characters need to be converted,
because you included the exact Unicode character references for those
Chinese characters.  You have to know your data.  Or modify your code
with specific assumptions about the data.

For example, let's say I have a string that I got from somewhere
(database, user form, text file, another web site, etc.):

$foo = 'Dick & Jane';

When you eventually display this to someone's web browser, what do you
want them to see?

Dick & Jane
or
Dick & Jane

This really depends on the format of the data inside $foo.  Is '&'
a character reference that you want to leave alone?  Or is it a literal
string that you want to convert to '&amp;' for display?  And the
only person that knows the format of the data is you.  Again, you have
to know your data.

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



Re: [PHP] Mail.php help

2003-10-01 Thread Eugene Lee
On Thu, Oct 02, 2003 at 02:23:44AM +0800, Jason Wong wrote:
: On Thursday 02 October 2003 01:28, Eugene Lee wrote:
: > On Wed, Oct 01, 2003 at 08:31:49AM -0700, Eric Rounds wrote:
: > :
: > : By the way, is there a way I can check, without looking into the
: > : serving Mac, to see if it is running?
: >
: > The only way to be is to log into the Mac and check for a process that
: > looks like "/usr/sbin/sendmail -C /etc/mail/submit.cf -q1h".
: 
: No idea whether it's different for OS X, but under, say Linux, PHP calls the 
: sendmail *binary*, thus you do not need the sendmail daemon running.

Doesn't matter.  Same problem.  PHP sends emails by submitting messages
to the Sendmail MTA.  If Sendmail itself is not running, it will not
deliver your message to the next-hop MTA.

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



Re: [PHP] Attempt at putting greedy htmlspecialchars on a diet

2003-10-01 Thread Eugene Lee
On Wed, Oct 01, 2003 at 02:46:14PM -0400, Gerard Samuel wrote:
: 
: When I say that I don't know what characters Im expecting.
: Im not talking about normal html entities, like &   <
: Im talking about chinese/japanese/korean/taiwanese alphabet, numbers 
: (even punctuation if applicable).
: Maybe Im thinking too hard, but trying to take far east languages 
: alphanumeric charaters into account,
: seems like overkill.
: Feel free to correct me.

Okay, I will.  :-)

There's two issues: input and output.

HTML character references address the problem of displaying certain
characters on a web browser.  This is an output issue.

When you get CJKV data, you are most likely getting it in some encoding.
Different Asian languages use their own encoding sets.  For example, if
you get Japanese text, it will be encoded in JIS, Shift-JIS, EUC, or
something Unicode.  You *have* to determine the type of data and its
encoding.  This is an input issue.

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



Re: [PHP] Attempt at putting greedy htmlspecialchars on a diet

2003-10-02 Thread Eugene Lee
On Thu, Oct 02, 2003 at 05:15:32PM +0900, - Edwin - wrote:
: 
: On Thu, 2 Oct 2003 01:54:43 -0500 Eugene Lee <[EMAIL PROTECTED]> wrote:
: > 
: > There's two issues: input and output.
: > 
: > HTML character references address the problem of displaying certain
: > characters on a web browser.  This is an output issue.
: > 
: > When you get CJKV data, you are most likely getting it in some
: > encoding. Different Asian languages use their own encoding sets. 
: > For example, if you get Japanese text, it will be encoded in JIS,
: > Shift-JIS, EUC, or something Unicode.  You *have* to determine the
: > type of data and its encoding.  This is an input issue.
: 
: Hmm... but the characters in question were already (at least in the
: examples used) in "something" Unicode (&#n;). So, there's really
: no need to know whether it's JIS, Shift-JIS, EUC, etc.

The Chinese characters in question were already converted to their HTML
numeric character references.  That's because someone made the conscious
and purposeful decision to provide the correct Unicode decimal numbers
for those Chinese characters.  Your concern about accepting CJKV data is
vague because you don't explain the source of the data or the encoding
method of the data.  You must determine these critical bits of info
before you can decide how to display the data.  There's no guarantee
that the user will send you CJKV data in nice HTML numeric character
references.  I'm not even sure exactly what you're trying to do.

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



Re: [PHP] PHP Bug Problems

2003-10-02 Thread Eugene Lee
On Wed, Oct 01, 2003 at 07:50:10PM -0700, Richard Baskett wrote:
: 
: Well I saw a post on a forum talking about a certain bug that PHP has for
: Mac OS X.. so I thought.. Im on OS X, I should see if that bug is real since
: on bugs.php.net they say it's bogus which you can view here:
: 
: http://bugs.php.net/bug.php?id=25394

I was able to replicate the problem you saw on my OS X box.  And I
posted a comment on the bug.  Hopefully, my comment won't get deleted
as quickly.  :-)

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



Re: [PHP] array_diff

2003-10-02 Thread Eugene Lee
On Thu, Oct 02, 2003 at 10:44:15AM +0200, Angelo Zanetti wrote:
: 
: I am getting some weird results when using the array_diff() function.
: 
: eg: $arrayResult = array_diff($array1, $array2);
: 
: When i use it the resulting array ($arrayResult) gets the correct number of
: elements, however when I echo the elements in $arrayResult it contains some
: blank values.
: 
: eg:
: 
: $array1 = [123] [120] [44] [54]
: $array2 = [120] [54]
: 
: then when I display $arrayResult:
: [123] ... -> blank value which should be 44.

It works for me:



with the output:

Array
(
[0] => 123
[2] => 44
)

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



Re: [PHP] array_diff

2003-10-02 Thread Eugene Lee
On Thu, Oct 02, 2003 at 11:28:23AM +0200, Angelo Zanetti wrote:
: 
: I know what the problem was, firstly that when doing an array_diff the keys
: are preserved. Therefore If I was looping through $arrayResult for the count
: of elements (in this case 2) then thats where the blank value comes in. SO
: therefore if I wanted to get all the values out of the $arrayResult that are
: not blank, would I loop through the array the amount of times that there are
: elements in the $array1, because $arrayResult will be the same size as
: $array1 and also because the keys are preserved?
: 
: Im not sure if Im heading in the right direction, with regards to gettig the
: values out the $arrayResult.

How about using a foreach() automatically walk the array without having
to worry about the keys?

I wonder if there is a function to re-index an array while preserving
numerical order.  If order is not important, a sort() will re-index the
array.

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



Re: [PHP] datediff in php

2003-10-02 Thread Eugene Lee
On Thu, Oct 02, 2003 at 01:36:04PM +0100, bob pilly wrote:
:  
: Does anyone know if there is a date difference function in php? I have
: searched the manual but found none. What im after is a function that
: will return the number of days or seconds between a start date and a
: second date. Much like DATEDIFF in ms sql. Any help or pointing to
: relevant docs would be greatly appreciated.

The easiest solution is to convert both dates into Unix timestamps.
Then the difference between the two timestamps is simply the number of
seconds between between both dates.

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



Re: [PHP] Dynamic tables-Change cell colour with drop down menu[Scanned]

2003-10-02 Thread Eugene Lee
On Fri, Oct 03, 2003 at 11:27:25AM +0800, [EMAIL PROTECTED] wrote:
: 
: I have tried using the methos you have mentioned. But it was not
: successful as the cell doesn't seem to be able to GET the COLOUR
: selected from the drop down menu. This is a small part of my code :
: 
:  cell1 
: 
: &
: 
: Red
: Grey
: white
: Pink
: Blue
: Yellow
: Cyan
: 
: 
: No matter which colour I select. The cell only stay at "black" colour.
: I wonder why?Need some help here.

If you're on a system that has global variables disabled, you must
switch to the superglobals.

 cell1 
or:
 cell1 

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



Re: [PHP] Building associative arrays

2003-10-03 Thread Eugene Lee
On Fri, Oct 03, 2003 at 10:22:55AM +0100, [EMAIL PROTECTED] wrote:
: 
: I'm trying to build an associative array from a database result. How can I
: assign a new key and value pair
: 
: eg
: 
: mysql_fetch_row etc
: {
: dbRowCol1 = myarray(key)
: dbRowCol2 = myarray(value)
: }
: 
: You get the general idea. Can't find any examples. I'm trying to lookup a
: key and retrieve the corresponding value.

If you really want your table's field names returned as keys, try using
mysql_fetch_assoc().

http://www.php.net/manual/en/function.mysql-fetch-row.php

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



Re: [PHP] How to swap the table's bg color with php

2003-10-03 Thread Eugene Lee
On Fri, Oct 03, 2003 at 06:11:39PM +0800, Jack wrote:
: 
: I had write a script using php,which will pull the values from a mysql table
: to display in HTML.
: now i want to add a function which when the mouse had move over a table
: cell, the background of the table cell will turn to other color!
: 
: Is anyone know how i can perform this task?

You'll have to write up some function in JavaScript that gets invoked on
a onMouseover() event.

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



Re: [PHP] Cookies Vs Sessions...?

2003-10-03 Thread Eugene Lee
On Fri, Oct 03, 2003 at 04:31:23PM +0100, [EMAIL PROTECTED] wrote:
: 
: I currently remember my visitors on my site by setting a cookie thusly:
: 
: setcookie("logged", "yes");
: 
: On each protected page, put an IF ($logged == "yes") { //show page etc } 
: else {//show login form etc }

You should use $_COOKIE['logged'] instead.  :-)

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



Re: [PHP] Cookies Vs Sessions...?

2003-10-03 Thread Eugene Lee
On Fri, Oct 03, 2003 at 08:57:17AM -0700, Chris Shiflett wrote:
: 
: --- Eugene Lee <[EMAIL PROTECTED]> wrote:
: > > 
: > > On each protected page, put an IF ($logged == "yes") { //show page etc } 
: > > else {//show login form etc }
: > 
: > You should use $_COOKIE['logged'] instead.  :-)
: 
: While we're talking about "should", you should also never trust what
: the client sends, including cookies. :-)

But if you take this to its natural conclusion, then you should never
trust the client.  :-)

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



Re: [PHP] dir size

2003-10-03 Thread Eugene Lee
On Fri, Oct 03, 2003 at 02:14:14PM -0500, Jay Blanchard wrote:
: [snip]
: > > >
: > > > $foo = exec("du -h");
: > >
: > > Hmmm this solution would appear to include the file sizes :D
: > 
: > man du  :D
: 
: et du?

LMAO!  :-D

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



Re: [PHP] stripping comments

2003-10-05 Thread Eugene Lee
On Sun, Oct 05, 2003 at 04:46:16AM -0400, zzz wrote:
: 
: I'm trying to strip comments out of my code.  I can get it to strip one
: section of comments but the problem comes in when I have more then one
: comment section to strip.
: 
: I am using this: $code = preg_replace('/\/*(.*?)*\//is', '$1', $code) and
: need help fixing my regex.
: 
: example:
: 
: code 1
: /* comment 1 */
: code 2
: /* comment 2 */
: code 3
: 
: result (bad):
: =
: code 1
: code 3
: 
: result (good):
: ==
: code 1
: code 2
: code 3

How about this:

$code = preg_replace('|/\*.*\*/|msU', '', $code);

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



Re: [PHP] attach file with mail() function??

2003-10-05 Thread Eugene Lee
On Sun, Oct 05, 2003 at 09:58:55PM -0500, John Nichel wrote:
: [EMAIL PROTECTED] wrote:
: >>Jason Wong wrote:
: >>>On Monday 06 October 2003 07:34, Roy W wrote:
: >>>
: Is there a way to attach a file with the mail() function?
: >>>
: >>>Yes.
: >>
: >>Is there a way to have PHP print out "Hello World"?
: >
: >Mr Wong has had his panties in a bunch all day, you may not want to
: >bait him.
: 
: Actually, I think Jason is as just tired of seeing the same, already 
: answered, questions over and over again...like alot of us are.  I think 
: he's tired of people who won't take one bit of their time to look up 
: answers for themselves, but expect us to hold their hand and waste our 
: timelike alot of us are.  Sure, the purpose of this list is to help, 
: but it's not here to babysit.

Maybe responders should take a slightly tougher attitude and make
some less reasonable demands like requesting the original poster to
read the online manual:

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

the FAQ:

http://www.php.net/FAQ.php

the list archives:

http://marc.theaimsgroup.com/?l=php-general

or even some other links:

http://www.php.net/links.php


Or there be a FAQ specifically for this list?

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



Re: [PHP] Re: php5 and possible oop features/questions

2003-10-06 Thread Eugene Lee
On Mon, Oct 06, 2003 at 12:36:49PM +0200, Tit Black Petric wrote:
: 
: Not really what i was getting at dude, i dont see how defining a class
: variable will let me define a method outside of a given class, or to
: dynamically extend/implement other classes inside a general one?

Why the desire to define a method outside of a class definition besides
the primary reason of syntactical sugar?

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



Re: [PHP] php&javascript live-clock

2003-10-07 Thread Eugene Lee
On Tue, Oct 07, 2003 at 03:48:27PM +0200, Alex Ciurea wrote:
: 
: is it possible to show the live-clock from the server machine, using
: php and javascript, without having to make refresh of that page?

AFAIK, no.

PHP scripts get their time information from the server.  JavaScript can
get its time from the server or the client, but it counts the time on
the client side.  If your web browser counts time a bit more slowly or
quickly than the server, the time drift would result in your JavaScript
clock to become more inaccurate over time.  Then you would have to
refresh the PHP page and re-sync your JavaScript clock with the server.
This is not be a big problem if your time drift is "minimal" and your
intervals between page refreshes is "reasonable".

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



Re: [PHP] or return problem

2003-10-07 Thread Eugene Lee
On Tue, Oct 07, 2003 at 01:02:36PM -0400, Pat Carmody wrote:
: 
: Calling the following retor_test() function causes a "Parse error: parse
: error, unexpected T_RETURN" message when the script is run:
: 
: function istrue() {
:   return true;
: }
: function retor_test() {
:   istrue() or return( "False" );
:   return "True";
: }
: 
: The problem is with the "or return" part.  Any ideas why?

Yes.

: I realize that I could use an if statement instead,

You just answered your own question.

: but I'm a lazy, lazy man and I don't want to.

Just use an if statement.  Lazy, Perl-ish syntax blows chunks.

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



Re: [PHP] A DATE Question

2003-10-08 Thread Eugene Lee
On Wed, Oct 08, 2003 at 03:08:44PM +0100, Shaun wrote:
: 
: is there a function in PHP that will work out the amount of time(hours)
: beween two different dates / times?

Just convert the two times into Unix timestamps, subtract one from the
other, and the difference is the amount of time in seconds.  Then it's
a simple matter of math to convert from seconds to hours (and minutes).

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



Re: [PHP] LiteSpeed Web Server 1.1

2003-10-08 Thread Eugene Lee
On Wed, Oct 08, 2003 at 11:56:51AM -0400, LiteSpeed Information wrote:
: 
: We glad to introduce you LiteSpeed Web Server 1.1.

So it is basically like TUX, a kernel-based web server?

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



Re: Re[2]: [PHP] dynamic -> static

2003-10-09 Thread Eugene Lee
On Thu, Oct 09, 2003 at 10:09:19AM -0700, Jim Lucas wrote:
: 
: I have the following configuration.
: 
: Redhat 8.0
:   Apache/2.0.40 (stock redhat install)
:   PHP 4.2.2 (stock redhat install)
: 
: What I get when I try and run this is an Object Not Found.
: 
: Same as the ERROR 404 page not found.
: 
: The URL looks like this
: 
: /index.php/var1/val1/var2/val2
: 
: I try this on a different development server running Apache 1.3.28,
: and it runs fine.
: 
: I couldn't even start to find the differences, since they are
: completely different version.

If I was Apache, I would try to serve the file:

/index.php/var1/val1/var2/val2/index.php
or
/index.php/var1/val1/var2/val2/index.html

or whatever files your DirectoryIndex is set to load.  In other words,
Apache thinks (and rightly so) that there is a directory "val2" in the
directory "var2" in the directory "val1" in the directory "var1" in the
directory "index.php".

If your URL is working on a different development server, it's probably
configured via mod_rewrite to do so.

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



Re: [PHP] Re: CSV file with PHP

2003-10-11 Thread Eugene Lee
On Fri, Oct 10, 2003 at 03:06:53PM -0700, Curt Zirzow wrote:
: 
: On Fri, 10 Oct 2003 18:38:04 -0300, Cesar Aracena <[EMAIL PROTECTED]> 
: wrote:
: >
: >Does anybody knows how to make a CSV (comma separated values) file
: >with PHP based on results fetched from MySQL? I need it to import it
: >with Microsoft Outlook Express.
: 
: csv file format as follows:
: 
:  value,"value\" with quotes",value with space,value

What about values with commas?

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



Re: [PHP] newbie question

2003-10-12 Thread Eugene Lee
On Sun, Oct 12, 2003 at 06:09:21PM +1000, Wang Feng wrote:
: 
: This is the example from the php manual:
[...]
: $formatted = sprintf("%01.2f", $money);// my question comes here
: // echo $formatted will output "123.10"
[...]
: 
: I don't understand the meaning of the 01 above, which follows the % sign. I
: tried the "%.2f" and "%1.2f", both work fine. So, what's the meaning of
: 01(especially what the 0 is for)? Seems very much the same as C anyway :-).

The "01" part guarantees that your money always has a preceding "0" for
decimal-only amounts.  For example, ".15" should be displayed as "0.15".

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



Re: [PHP] Age from date field?

2003-10-12 Thread Eugene Lee
On Sun, Oct 12, 2003 at 02:09:38AM +0200, DvDmanDT wrote:
: 
: Does anyone have a good solution on how to get the age of someone from a
: date column in mysql... This is what I have, but it's not really the
: truth... What's the right way to do it?
: 
: floor((time()-$a["born"])/(3600*24*365.25))
: 
: where $a["born"] is the timestamp of the birthdate... Current query:

This should work for well-formed timestamps, i.e. they are not in the
future:

function age($ts)
{
list($y1, $m1, $d1) = explode(' ', date('Y m d', $ts));
list($y2, $m2, $d2) = explode(' ', date('Y m d', time()));
$age = $y2 - $y1 - ((($m2 < $m1) || ($d2 < $d1)) ? 1 : 0);
return $age;
}

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



Re: [PHP] newbie question

2003-10-12 Thread Eugene Lee
On Sun, Oct 12, 2003 at 06:57:35PM +1000, Wang Feng wrote:
: 
: If I get rid of the 0 and tried this:
: 
: $price=.65;
: $f_price=sprintf("%1.2f",$price);
: 
: It displays "0.65" in my Mozilla browser correctly. What do you say then?

I say, "I dunno".  :-)  It seems to follow C's printf(3) conversion
specification.  If a decimal point is needed for a float, it must also
have a digit in front of the decimal point.  This is kind of annoying if
I want to print decimal-only values without preceding zeroes.  Maybe
money_format() is a better solution.

: BTW, what's the 1 used for?

Specifies the minimum character width of the conversion.  See PHP's
sprintf() docs for more details.


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



Re: [PHP] https detection

2003-10-12 Thread Eugene Lee
On Sun, Oct 12, 2003 at 01:09:15PM +0200, Rosen wrote:
: 
: Is there a way to determite with PHP thath site visitor is in https (SSL)
: mode or in normal mode ?

Check for the existence of $_SERVER['HTTPS'] which gets set only on SSL
pages.  I wonder why it's still not mentioned in the official docs.

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



Re: [PHP] https detection

2003-10-12 Thread Eugene Lee
On Sun, Oct 12, 2003 at 01:24:40PM +0200, Rosen wrote:
: 
: I.e. if  I use _SERVER["SERVER_PORT"] = 443  - for https connection and 80
: for "normal" - i'll be able to determite if user is in https mode - I think
: thath should be works . ?

Technically, you can't guarantee that anything running over port 443
will be HTTPS.  This is part of the more general problem of running your
web server on non-standard ports.

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



Re: [PHP] https detection

2003-10-12 Thread Eugene Lee
On Sun, Oct 12, 2003 at 08:52:30PM +1000, Tom Rogers wrote:
: Sunday, October 12, 2003, 8:46:41 PM, Eugene wrote:
: EL> On Sun, Oct 12, 2003 at 01:24:40PM +0200, Rosen wrote:
: EL> : 
: EL> : I.e. if  I use _SERVER["SERVER_PORT"] = 443  - for https connection
: EL> : and 80 for "normal" - i'll be able to determite if user is in https
: EL> : mode - I think thath should be works . ?
: 
: EL> Technically, you can't guarantee that anything running over port 443
: EL> will be HTTPS.  This is part of the more general problem of running your
: EL> web server on non-standard ports.
: 
: His script will only see valid ssl connections as all other attempts should be
: ditched by apache or whatever before php gets involved...in theory anyway :)

Unless Apache is configured so that both SSL and non-SSL virtualhosts
to point to the same directory containing said script, or said script is
shared (via PHP include(), require(), etc.) by other PHP scripts in both
SSL and non-SSL virtualhosts.  :-)

And $_SERVER['HTTPS'] is so much easier to check for existence!

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



Re: [PHP] Age from date field?

2003-10-12 Thread Eugene Lee
On Sun, Oct 12, 2003 at 02:49:53PM +, Curt Zirzow wrote:
: * Thus wrote Eugene Lee ([EMAIL PROTECTED]):
: > On Sun, Oct 12, 2003 at 02:09:38AM +0200, DvDmanDT wrote:
: > : 
: > : Does anyone have a good solution on how to get the age of someone from a
: > : date column in mysql... This is what I have, but it's not really the
: > : truth... What's the right way to do it?
: > : 
: > : floor((time()-$a["born"])/(3600*24*365.25))
: > : 
: > : where $a["born"] is the timestamp of the birthdate... Current query:
: > 
: > This should work for well-formed timestamps, i.e. they are not in the
: > future:
: > 
: > function age($ts)
: > {
: > list($y1, $m1, $d1) = explode(' ', date('Y m d', $ts));
: > list($y2, $m2, $d2) = explode(' ', date('Y m d', time()));
: > $age = $y2 - $y1 - ((($m2 < $m1) || ($d2 < $d1)) ? 1 : 0);
: 
: What happens if the month is the same but the day hasnt been
: reached?
: 
: Shouldnt this be:
:  $age = $y2 - $y1 - ((($m2 < $m1) || ($m2 == $m1 && $d2 < $d1)) ? 1 : 0);
: 
: To account for it being the same month but not yet the day.

You're right.  I got lost trying to short-circuit the expression and
forgot to explicitly test for same month.  :-)

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



Re: [PHP] newbie question

2003-10-12 Thread Eugene Lee
On Mon, Oct 13, 2003 at 03:23:53AM +1000, Wang Feng wrote:
: 
:  "1. An optional padding specifier that says what character will be used for
: padding the results to the right string size. This may be a space character
: or a 0 (zero character). The default is to pad with spaces. An alternate
: padding character can be specified by prefixing it with a single quote (').
: See the examples below."
: "3. An optional number, a width specifier that says how many characters
: (minimum) this conversion should result in."
:  http://au.php.net/manual/en/function.sprintf.php
: 
: Assume that $price=.65; then the "%0.2f" yields 0.65.
: 
: If we follow what the manual says, then can you tell me what the 0 is used
: for? Is it a (optional) paddinng spcifier OR is it a (optional) width
: specifier OR both? And why does it yiled 0.65 rather than .65?
: 
: (The manual doesn't explain things clear, man.)

The PHP manual is vague in several sections.  I wonder how bug reports
get submitted for it?

The optional specifiers to the left of the decimal place have a psuedo
last-to-first precedence.  For example:

$price = .65;

printf("'%8.2f'\n", $price);
-> '   0.65'

This shows that there are 8 characters reserved for the number to the
left of the decimal.  Therefore, '8' is the width specifier.

printf("'%-8.2f'\n", $price);
-> '0.65   '

printf("'%08.2f'\n", $price);
-> '.65'

printf("'%0-8.2f'\n", $price);
-> '0.65000'

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



Re: [PHP] awful newbie question

2003-10-12 Thread Eugene Lee
On Sun, Oct 12, 2003 at 07:09:32PM +0200, Marek Kilimajer wrote:
: 
: Paul Freedman wrote:
: >
: >In the php statement
: >$q->qzml();
: >what is the symbol '->' called? What does it mean?
:
: It calls *member* function of object $q.
[...]
: >I have also come across the symbol '=>'. I assume it is not the same 
: >symbol. What is it, and what does it mean?
: 
: It is used to assign values to keys in array() construct:
: http://sk.php.net/manual/en/function.array.php

But as for the first question, I don't know if '->' or '=>' have any
specific *names* in PHP.

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



Re: [PHP] newbie question

2003-10-13 Thread &#x27;Eugene Lee'
On Mon, Oct 13, 2003 at 10:32:18AM +0100, Ford, Mike   [LSS] wrote:
: 
: On 12 October 2003 23:36, Eugene Lee wrote:
: > 
: > The PHP manual is vague in several sections.  I wonder how bug
: > reports get submitted for it? 
: 
: http://bugs.php.net/report.php and select "Documentation problem" from
: the "Type of bug" drop-down.  (But read the bug-reporting guidelines
: at http://php.bugs.php.net/ first!)

Thanks Mike, I'll give it a read when I get free!

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



Re: [PHP] \n \t don't work!!!

2003-10-13 Thread Eugene Lee
On Mon, Oct 13, 2003 at 09:48:56PM +1000, Wang Feng wrote:
: 
: Ok, Now I see what happen (maybe).
: 
: So, the "\n" is not for the browser output, but for the *view source*? So,
: it's different from the "echo "?
: 
: If so, what's the deal to do that? --- Makes it look nice if the user view
: the source code?

When normally rendering HTML text, multiple continuous whitespace
characters (i.e. "\s+") as a single space.  So HTML source code:


How are
you?
I am fine.

What else is new?



gets displayed as this:


How ar you. I am fine. What else is new?


To force a visual linebreak in rendered HTML pages, as you already
discovered you need to manually insert "" tags.

However, if you don't want to litter your HTML source code with a bunch
of gratuitous "" tags all over the place, use the "" container
tag to make the browser render newlines as visual linebreaks.

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



Re: [PHP] \n \t don't work!!!

2003-10-13 Thread Eugene Lee
On Mon, Oct 13, 2003 at 08:10:39AM -0500, Jay Blanchard wrote:
: 
: [snip]
: To give tabs in html, you might want to try using       
: instead of \t
: [/snip]
: 
: And one other thing I didn't see mentioned http://www.php.net/nl2br

Note that nl2br() is XHTML compliant, which means it sends out ""
tags instead of "" tags.  This is a problem on browsers that do
poorly with mixed HTML and XHTML tag styles in the same body content.

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



Re: [PHP] preg_replace newb

2003-10-13 Thread Eugene Lee
On Mon, Oct 13, 2003 at 11:00:36PM +1000, Justin French wrote:
: 
: On Monday, October 13, 2003, at 10:17  PM, Mohamed Lrhazi wrote:
: 
: >I would try a petern like this:
: >
: >$pattern="!([^<]*)!"
: >
: >check the docs for greedy not greedy thingy...
: 
: Mohamed,
: 
: I still can't seem to get it working:
: 
: foo";
: $str = preg_replace("!([^<]*)!",'blah',$str);
: echo $str;
: ?>
: 
: echo's 'foo' rather than 'blah'

Justin,

Your code snippet works for me.  My output says "blah".  :-)

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



Re: [PHP] Passing variables between pages

2003-10-14 Thread Eugene Lee
On Tue, Oct 14, 2003 at 10:20:44AM -0500, Jay Blanchard wrote:
: "KB" <[EMAIL PROTECTED]> asked:
: > 
: > Simple one for anyone who wants to help out a novice.  How do you
: > pass a variable from one page to another?
: 
: Through either a $_POST or a $_GET variable array. 

And cookies and sessions and database backends oh my!

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



Re: [PHP] Makeing automatic tags for email and www.

2003-10-15 Thread Eugene Lee
On Wed, Oct 15, 2003 at 03:41:01AM -0500, Gabriel Peugnet wrote:
: 
: I want to convert
: [EMAIL PROTECTED]
: into
: (a href='mailto:[EMAIL PROTECTED]') [EMAIL PROTECTED] (/a)
: 
: (I sustitued tags with parenthesis)
: 
: It's a little tedious makeing the function.

Nah.

function emaillink($url)
{
$email = htmlentities($email);
return '' . $email .  '';
}

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



Re: [PHP] Re: Makeing automatic tags for email and www.

2003-10-15 Thread Eugene Lee
On Wed, Oct 15, 2003 at 04:16:14AM -0500, Gabriel Peugnet wrote:
:
: Thanks Eugene.
:
: I'm afraid I didn't explain my self as I should.
:
: What I want is this to be automaticaly generated in a text.
: For example, in:
:
: "Some text some text some text some text [EMAIL PROTECTED] some text some text
: some text and www.mywebpage.com some text some text some text
: [EMAIL PROTECTED] some text some text some text ."

You're so close...

' . $email .  '';
}
function emaillink_callback($matches)
{
return emaillink($matches[0]);
}
$word = "Some text some text some text some text [EMAIL PROTECTED] some text some 
text some text and www.mywebpage.com some text some text some text [EMAIL PROTECTED] 
some text some text some text ."
echo preg_replace_callback('|([EMAIL PROTECTED])|', 'emaillink_callback', $word) . 
"\n";
?>

Of course, the equivalent code for web sites is left as an exercise.
But you get the idea.  :-)  The tough part is figuring out the regular
expression pattern.


: "Gabriel Peugnet" asked:
: >
: > I want to convert
: > [EMAIL PROTECTED]
: > into
: > (a href='mailto:[EMAIL PROTECTED]') [EMAIL PROTECTED] (/a)

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



Re: [PHP] preg help please :)

2003-10-15 Thread Eugene Lee
On Thu, Oct 16, 2003 at 02:23:45PM +1000, Justin French wrote:
: 
: I have the following:
: 
: \\1",
:   $text
:   );
: ?>
: 
: It basically matches "link text":"url" with the added twist of having 
: the quotes converted to “ or “ by a previous function.
: 
: It works fine if there is one link found inside a string, but falls 
: over horribly if there's two links inside a string.
: 
: How can I improve the (.*) to exclude $quote ?

Try inverting the greediness with a "U" pattern modifier:

"/$quote(.*)$quote:$quote(.*)$quote/U"

For more details:

http://www.php.net/manual/en/pcre.pattern.modifiers.php

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



Re: [PHP] Regular Expressions

2003-10-16 Thread Eugene Lee
On Thu, Oct 16, 2003 at 03:35:57PM +0300, Shmuel wrote:
: 
: I have a misspelled sentence like this: "I am not aIone".
: I want to change the capital I to small l, but only in
: the beginning of a word.

This doesn't make sense.  It sounds like you want to replace every
occurance of 'I' inside a word with a 'l'.

preg_replace('/(\B)I(\B)/', '\1l\2', $yourstring)

Then again, I could be misreading.

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



Re: [PHP] Regular Expressions

2003-10-16 Thread Eugene Lee
On Thu, Oct 16, 2003 at 09:41:39PM +0300, Shmuel wrote:
: Eugene Lee wrote:
: >On Thu, Oct 16, 2003 at 03:35:57PM +0300, Shmuel wrote:
: >: 
: >: I have a misspelled sentence like this: "I am not aIone".
: >: I want to change the capital I to small l, but only in
: >: the beginning of a word.
: >
: >This doesn't make sense.  It sounds like you want to replace every
: >occurance of 'I' inside a word with a 'l'.
: >
: > preg_replace('/(\B)I(\B)/', '\1l\2', $yourstring)
: >
: >Then again, I could be misreading.
: 
: I want to replace every occurance of 'I' inside a word with a 'a',
: but *NOT* in the beginning of the word. ie. Ill doesn't change,
: but miIk changes to Milk.
: 
: This is a problem that occurs whit subrip. It can't distinguish
: between those two letters.

Okay... so did my preg_replace() above work for you?  Or not?  If not,
do you have examples of it not working?

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



Re: [PHP] date for mysql

2003-10-17 Thread Eugene Lee
On Fri, Oct 17, 2003 at 03:28:50PM +0200, Diana Castillo wrote:
: 
: how can I format the current date and time so that I can insert it into a
: mysql table with an insert query?

That depends on the column type of your MySQL table.  Is it a DATETIME?
DATE?  TIMESTAMP?  TIME?  Or just a YEAR?

http://www.mysql.com/doc/en/Date_and_time_types.html

Once you know the column type and its format, you can use PHP's date()
function to do the correcting formatting for MySQL.

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



Re: [PHP] SQL security

2003-10-17 Thread Eugene Lee
On Fri, Oct 17, 2003 at 09:38:12AM -0500, Jeremy Russell wrote:
: 
:I was just sitting here thinking how to secure my php code and
: thought I would run it by the pros.  I don't know what the standard
: practice is to secure against sql injection and malformed information
: passed from forms.  This probably has been done several times I just
: would like to know if I should do it this way or if there is a better
: way.

If you're using MySQL, you can use mysql_real_escape_string().  If
you're using another database, hopefully there is a similar function.

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



  1   2   3   >