OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
 
php-general Digest 1 May 2003 15:23:13 -0000 Issue 2031

php-general-digest-helplists.php.net
Date: Thu May 01 2003 - 10:23:13 CDT


php-general Digest 1 May 2003 15:23:13 -0000 Issue 2031

Topics (messages 145889 through 145970):

Re: Replacing first character in a string
        145889 by: Weston Houghton
        145908 by: Pierrick LE GALL
        145940 by: Mark

Re: Help - Register Globals
        145890 by: Petras Virzintas

template engine choices (was Re: [PHP] template engine...why???)
        145891 by: Seairth Jacobs
        145918 by: rush
        145929 by: Ryan A
        145942 by: rush

Re: Using PHP with special fonts
        145892 by: Justin French
        145901 by: Ron Allen

Re: Replacing file access backend
        145893 by: Edward Rudd

Translate easy the language of the web site
        145894 by: Orlando Pozo
        145895 by: Luke Woollard

wierd header output to pdf problems
        145896 by: electroteque

Translate web site language
        145897 by: Orlando Pozo
        145899 by: Luke Woollard
        145967 by: Peter Clarke

Date Localization - Australian
        145898 by: Luke Woollard
        145904 by: Justin French
        145906 by: Luke Woollard
        145909 by: Bob Irwin
        145913 by: Luke Woollard
        145922 by: Justin French

[Newbie] Cascade delete manually
        145900 by: Bobby Rahman
        145925 by: Bobby Rahman
        145945 by: Don Read

Re: Results from is_dir() not consistent with documentation (?)
        145902 by: Jason B. Standing

fopen won't work :(
        145903 by: Police Trainee
        145910 by: Police Trainee
        145912 by: Jason B. Standing

where is php error log?
        145905 by: Merlin

Replacing a space with an underscore
        145907 by: Ron Allen
        145914 by: Burhan Khalid
        145915 by: Luke Woollard
        145934 by: Chris Boget
        145949 by: John W. Holmes
        145969 by: James

NewB Q: email from php?
        145911 by: Inpho
        145920 by: Justin French

Zip code search script
        145916 by: blade xtreme

Re: template engine...why???
        145917 by: rush
        145923 by: Justin French
        145926 by: rush
        145930 by: Justin French

Custom Session Handlers and User Tracking
        145919 by: Rob Lacey
        145921 by: Awlad Hussain
        145951 by: John W. Holmes

PHP syntax
        145924 by: Ron Allen
        145928 by: Chris Hayes
        145932 by: Ron Allen
        145939 by: John W. Holmes
        145968 by: Ron Allen

Extra ob_start(""); in phpbb?
        145927 by: Vek, Marvin (RW-NL)

Ticks and finding out where the script currently is.
        145931 by: William Bailey
        145944 by: William Bailey

hyperlinking results from a sql query
        145933 by: bob pilly
        145935 by: Awlad Hussain
        145938 by: George Pitcher

Looping results problem
        145936 by: Matt MacLeod
        145948 by: John W. Holmes

Re: BENJAMIN WILLIAMS
        145937 by: David Robley

function question
        145941 by: Shaun
        145947 by: John W. Holmes
        145964 by: dwalker

problem with require()
        145943 by: Nene

Easier: optimized php.ini for responsetime?
        145946 by: Vek, Marvin (RW-NL)

Error undefined index
        145950 by: Michael Timinger

Question about include_once and require_once
        145952 by: Al
        145954 by: John W. Holmes
        145958 by: Al
        145959 by: Al
        145960 by: Gavin Nouwens
        145961 by: Al

PHP Class question
        145953 by: Miguel Angelo

Whats SAFEMODE
        145955 by: Henrik Sune Pedersen
        145956 by: Gavin Nouwens
        145957 by: Henrik Sune Pedersen

Getting variables before the submit button is hit
        145962 by: bob pilly
        145963 by: Gavin Nouwens
        145966 by: James

Re: [SOLVED] Ticks and finding out where the script currently is.
        145965 by: William Bailey

Recommendations
        145970 by: Ron Allen

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscribelists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscribelists.php.net

To post to the list, e-mail:
        php-generallists.php.net

----------------------------------------------------------------------

attached mail follows:


Why not just reference the character directly and test against that?
It's not much different, but I would guess that it is slightly faster.

if ($str{0} == ",") {
        $str{0} = 0;
}

Wes

On Wednesday, April 30, 2003, at 11:20 PM, Hugh Bothwell wrote:

>
> "Lee P. Reilly" <lreillylanl.gov> wrote in message
> news:3EB02C14.79845983lanl.gov...
>> I wonder if anyone can help me? I have a string something like this:
>> ",.00109863,.00219725,.00329588.... and so on....".
>>
>> If the *first character* in the string is a comma (as in the case
>> above)
>> then I want to replace it with "0,", but I cannot find a way to do it.
>
> Of all the replies, only one was
> correct, and it was pretty obfuscated.
> Try this:
>
> if (substr($str,0,1) == ",")
> $str = "0" . substr($str,1);
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>

------------------------------------------------------------------------
---
The selection and placement of letters on this page was
determined automatically by a computer program. Any
resemblance to actual words, sentences, or paragraphs is
pure coincidence, and no liability will be assumed for
such coincidences.
------------------------------------------------------------------------
---

attached mail follows:


"Lee P. Reilly" <lreillylanl.gov> writes:

> Hi there,

Hi

> If the *first character* in the string is a comma then I want to
> replace it with "0,", but I cannot find a way to do it.

try this :

preg_replace( '/^,/', '0', $string );

--
Pierrick LE GALL | http://www.phpwebgallery.net

attached mail follows:


--- Hugh Bothwell <hugh_bothwellhotmail.com> wrote:
>
> "Lee P. Reilly" <lreillylanl.gov> wrote in message
> news:3EB02C14.79845983lanl.gov...
> > I wonder if anyone can help me? I have a string something like
> this:
> > ",.00109863,.00219725,.00329588.... and so on....".
> >
> > If the *first character* in the string is a comma (as in the case
> above)
> > then I want to replace it with "0,", but I cannot find a way to
> do it.
>
> Of all the replies, only one was
> correct, and it was pretty obfuscated.
> Try this:
>
> if (substr($str,0,1) == ",")
> $str = "0" . substr($str,1);

Actually, from the original post, this will specifically NOT do what
he asks. Whether it's what he actually wants is something else. He
asks to replace the comma with a zero and a comma (actually, prepend
a zero), not replace the comma with a zero, which is what your
"correct" script does.

Make the last line:

$str = "0" . $str;

and it'll do what is asked.

=====
Mark Weinstock
mark_weinstockyahoo.com
***************************************
You can't demand something as a "right" unless you are willing to fight to death to defend everyone else's right to the same thing.
***************************************

__________________________________
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.
http://search.yahoo.com

attached mail follows:


Hi Jason, thanks for the reply. Perhaps I've missed the point somewhere.

We have Windows applications which use the Microsoft Browser Control and create/post URLs such as:
webserver/webpage.php?User=uuuuu&Pass=ppppp&Var1=xxxxx&Var2=yyyyy etc.

These applications are running on the LAN where the user has already logged on with their username and password. The above will not work if Register-Globals=Off. We don't want to use Register-Globals=On because the webserver is also open to the rest of the world where the users log on before getting to the web page.

Hope it makes sense
Petras

From: Jason Wong <php-generalgremlins.biz>
Reply-To: php-generallists.php.net
To: php-generallists.php.net
Date: Tue, 29 Apr 2003 17:22:36 +0800
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Message-Id: <200304291722.36121.php-generalgremlins.biz>
Subject: Re: [PHP] Help - Register Globals

On Tuesday 29 April 2003 11:28, Petras Virzintas wrote:
> Hi, I followed a recent thread about the "Register Globals" flag and got
> the impression that there may be a way to have it "on" for local
> connections (ie. LAN) and "off" for the rest of the world. Is this true? If
> so, could someone give me an example of the .htaccess entries.

It's possible, kind of ...

... but, I'm curious as to what would be the purpose of such a setup. It could
make debugging slightly easier but I really can't think of any *real* reason.

Perhaps if you say what kind of problem you're trying to solve there may be a
more obvious solution.

--
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
------------------------------------------
/*
You've always made the mistake of being yourself.
  -- Eugene Ionesco
*/

attached mail follows:


Okay... now to take another shot at the question...

It's not a question of whether to use templating or not. It's a question of
what level of abstraction you want to use when templating.

Using include() to insert a header and footer *is* templating. However,
this approach has certain trade-offs. For instance, the placement of the
include() relative to other generated screen elements is more rigid.
However, it is an extremely simple form of templating that's easily
implemented.

From here, you could go to another level. You could generate a "template"
which consists of nothing but calls to "presentation helper" code, as Rasmus
suggests. In this case, you have a bit more flexbility, since you can
possibly relocate includes() and calls to helper functions, as well as
insert presentation elements directly. The trade-off is additional
complexity because some of the presentation has been moved to a series of
helper functions, where it is likely that presentation elements and code
will be more mixed.

If you want to go even more "abstract", you could attempt to separate *all*
presentation elements into templates and template snippets, likely using
some form of str_replace() to build the final presentation. In it's simpler
incarnation, the formatting of the data itself (e.g. showing thousands
separator in a number or not) will still be embedded in the code. More
complex versions may allow additional control over the formatting from
within the templating system itself. Whichever way you go, this approach
adds more flexibility at the cost of complexity. In a sense, generating XML
and running it through XSLT would be an example of this flexibility. As
Rasmus points out, once you get to this level, you have practically
re-created PHP (ever notice just how complex XSLT can get?).

There are certainly other approaches that I have not covered. They may be
hybrids of the above. They may be entirely different approaches.
Regardless, they all have trade-offs that should be considered before using.
Also, it is also important to note that some of the above approaches may
have runtime performance constraints (notably the "abstract" version
detailed above). In a sense, you are writing an interpreter in an
interpreter (fortunately, the sabltron xslt processor is not written in PHP,
or we would see just how slow an "interpreter written in an interpreter"
could get). There are likely ways to optimize all of these approaches, one
of which is to go through a "one-time" compilation process that takes the
presentation and code and merges them into something that is resumably as
free of "templating" overhead as you can get. Even in this case, there are
trade-offs....

So, which way should you go? It depends on all sorts of factors:

* Your comfort level with each style of templating.
* What your application may require:
    * who will be editing the presentation portions
    * how complex the presentations will be
    * whether processing times will be significantly affected
    * etc.
* etc.

So... if include()s work for your needs, go with it! If you later on have
a need for a different approach, go with it! As we have seen from this
thread, there is no one right answer...

---
Seairth Jacobs
seairthseairth.com

"Ryan A" <ryanjumac.com> wrote in message
news:001501c30f66$c46bdd30$1301400al2zcaxu7emppqh...
> > Agreed as well. :) So... did we answer the original question? I've
lost
> > track of what it was...
>
>
> Let me help, I started this thread with a very simple question (or so i
> thought).
> Here the email below:
> *************************************************
> Hi,
> I'm a kind of newbie to PHP but have been with Java Servlets for years...I
> would appreciate it if someone would answer this question for me please.
>
> Why use a template engine?
>
> isnt it much easier to include a header and footer file with "include"?
>
> eg:
> <?php include "headerblah.php" ?>
>
> thats soooo much easier that learning some templating "language"...isnt
it?
> I visited the smarty template site.....
>
> Cheers,
> -Ryan
> ******************************************************************
>
> Hope that brought back your memory :-)
>
> Cheers,
> -Ryan
>

attached mail follows:


"Seairth Jacobs" <seairthseairth.com> wrote in message
news:20030501040636.73655.qmailpb1.pair.com...
> If you want to go even more "abstract", you could attempt to separate
*all*
> presentation elements into templates and template snippets, likely using
> some form of str_replace() to build the final presentation. In it's
simpler
> incarnation, the formatting of the data itself (e.g. showing thousands
> separator in a number or not) will still be embedded in the code. More
> complex versions may allow additional control over the formatting from
> within the templating system itself. Whichever way you go, this approach
> adds more flexibility at the cost of complexity. In a sense, generating
XML
> and running it through XSLT would be an example of this flexibility. As
> Rasmus points out, once you get to this level, you have practically
> re-created PHP (ever notice just how complex XSLT can get?).

TemplateTamer is closest to this approach, since your program basically
have to prepare data tree that contains the data, and then engine assembles
html page from templates. The important differences from xml+xslt are:

1) you prepare a data tree as php array, not a dom tree
2) you do not have to write xslt or anything similar, since TT generates
necessary PHP code to handle this part of functionality. (this is also in my
opinion biggest weaknes of xml+xslt: need to hack xslt, which contain both
design and code)
3) There are much less "initialization" code you have to write like load
this load that, call transform .. , allmost all of that is handled by TT
4) transformations done by TT engine are simpler than chores sablotron needs
to endure.

> So, which way should you go? It depends on all sorts of factors:
>
> * Your comfort level with each style of templating.
> * What your application may require:
> * who will be editing the presentation portions
> * how complex the presentations will be
> * whether processing times will be significantly affected
> * etc.
> * etc.
>
> So... if include()s work for your needs, go with it! If you later on
have
> a need for a different approach, go with it! As we have seen from this
> thread, there is no one right answer...

Yup I agree with that.

rush
--
http://www.templatetamer.com/

attached mail follows:


Hi Rush,
Thank you for taking the time to reply to me.

Right now my "templating" is really really basic...I just have the header
and footer HTML (no php) as an include at the top and bottom of my site so I
dont think I really need a "templating system".Coming from JAVA servlets I
LOVE the way you can include stuff like this, its saves me hours.
PHP rocks and I dont think I will ever leave it.

But in the next few weeks I may be working on a big project and I think I
might be needing a templating system to work with, I know you are connected
with TT (as a developer or owner I dont know), I have visited your site and
found little details...
I was originally thinking of going with SMARTY as that seems to be the
popular choice for some time for people I know...

Since you are connected with TT I think you will know the insides of a
templating system better than the average PHP person (although there are
some wizards on everything PHP on the php general list)

a few questions if you dont mind:
(most important) Is TT free like SMARTY? :-)
Learning curve?
can you give me a few features that TT has that SMARTY fails at?
Any suggestions advise also welcome.

Cheers,
-Ryan

----- Original Message -----
From: "rush" <piparush.avalon.hr>
To: <php-generallists.php.net>
Sent: Thursday, May 01, 2003 11:55 AM
Subject: [PHP] Re: template engine choices (was Re: [PHP] template
engine...why???)

> "Seairth Jacobs" <seairthseairth.com> wrote in message
> news:20030501040636.73655.qmailpb1.pair.com...
> > If you want to go even more "abstract", you could attempt to separate
> *all*
> > presentation elements into templates and template snippets, likely using
> > some form of str_replace() to build the final presentation. In it's
> simpler
> > incarnation, the formatting of the data itself (e.g. showing thousands
> > separator in a number or not) will still be embedded in the code. More
> > complex versions may allow additional control over the formatting from
> > within the templating system itself. Whichever way you go, this
approach
> > adds more flexibility at the cost of complexity. In a sense, generating
> XML
> > and running it through XSLT would be an example of this flexibility. As
> > Rasmus points out, once you get to this level, you have practically
> > re-created PHP (ever notice just how complex XSLT can get?).
>
> TemplateTamer is closest to this approach, since your program basically
> have to prepare data tree that contains the data, and then engine
assembles
> html page from templates. The important differences from xml+xslt are:
>
> 1) you prepare a data tree as php array, not a dom tree
> 2) you do not have to write xslt or anything similar, since TT generates
> necessary PHP code to handle this part of functionality. (this is also in
my
> opinion biggest weaknes of xml+xslt: need to hack xslt, which contain both
> design and code)
> 3) There are much less "initialization" code you have to write like load
> this load that, call transform .. , allmost all of that is handled by TT
> 4) transformations done by TT engine are simpler than chores sablotron
needs
> to endure.
>
>
> > So, which way should you go? It depends on all sorts of factors:
> >
> > * Your comfort level with each style of templating.
> > * What your application may require:
> > * who will be editing the presentation portions
> > * how complex the presentations will be
> > * whether processing times will be significantly affected
> > * etc.
> > * etc.
> >
> > So... if include()s work for your needs, go with it! If you later on
> have
> > a need for a different approach, go with it! As we have seen from this
> > thread, there is no one right answer...
>
> Yup I agree with that.
>
> rush
> --
> http://www.templatetamer.com/
>
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

attached mail follows:


"Ryan A" <ryanjumac.com> wrote in message
news:005e01c30fd6$e627eca0$1301400al2zcaxu7emppqh...

> But in the next few weeks I may be working on a big project and I think I
> might be needing a templating system to work with, I know you are
connected
> with TT (as a developer or owner I dont know), I have visited your site
and
> found little details...

I am both actually :)

> I was originally thinking of going with SMARTY as that seems to be the
> popular choice for some time for people I know...

Smarty is by all means very well known and established with many happy
users. I also believe it is currently most popular template system, although
recent php kitchen poll points patTemplate as most popular:

http://www.phpkitchen.com/pollbooth.php?qid=bestTemplateEngine&aid=-1

> a few questions if you dont mind:
> (most important) Is TT free like SMARTY? :-)

No. TT is closest to shareware, and it commes in two flavours:

- Free edition: free of charge, includes promotional link in the footer of
all generated pages. You can use this version without time limit. The
developer environment (the one you are using while developing, not the pages
generated with) occasionaly promotes Developer's edition.

- Developer's edition: costs $28, you can use it to produce unlimited number
of the sites with.

> Learning curve?

Probably steep, especially because:
- it has "other way around" feeling to it, which one needs to get
comfortable with
- i am not very skilled with documentation.

I try to step in with extra advice whenever I can to compensate for that,
but it is not somethhing I can promise, especially if suddenly larger number
people write to me.

> can you give me a few features that TT has that SMARTY fails at?

it would not be fair to say that SMARTY fails, since it has many users, and
many of them are very happy. The main differences are in approach, and
focus. Here are the main differences:

SMARTY
- includes logic of the templates within a template, you define logic in
form of SMARTY expressions.
- SMARTY does not come with development environment. It is basically library
and runtime system that you install.
- established, with large user base

TT
- logic is in php files separated from templates. Logic is defined in php
language.
- TT commes with development environment; editor, project, tree view of your
template structure, simple code wizard.
- TT requires you to use at least some OO. For each page you need to define
a coresponding class. If OO is not your preffered approach this can be an
obstacle. Othervise I believe it leads to nicer design where you develop
hierarchy of classes for pages, where you have a general class describing
elements common to all pages on your site, and than you gradually add
specialization in each page. Also you usually develop classes that drive
common elements or components on your site.
- TT is new, at least in public. I have been using it for about 2,5 years in
my projects, but only recently put it out as product.

> Any suggestions advise also welcome.

No, except that if you would have some questions about your project, like
"how would I go on doing this in TT", or "what would be a best way to
solve/divide/organize/approach this with TT", you could drop me an e-mail,
and I will try to give advice on it. It is beneficiall for me in 2 ways, it
might help spread TT and at same time gives me idea about usuall problems
and questions.

rush
(a.k.a. rush the butcher ;)
--
http://www.templatetamer.com/

attached mail follows:


If by "retrieving station" you mean "HTML browser", then you would do it
with CSS:

<p style='font-family: theNameOfMyBarcodeFont; font-size: 30px;'>
    91826739837
</p>

Remember, PHP is JUST GENERATING HTML SOURCE CODE... if you need to know how
to change fonts, size, colours, etc etc, then learn HTML, CSS, etc, and use
PHP and your knowledge of HTML/CSS to generate pages.

Justin

on 01/05/03 10:35 AM, Ron Allen (Ronald.Allenbondsteel2.areur.army.mil)
wrote:

> How would I go about using PHP to format fonts.
>
> What I would like to do.
>
> Import some text into a database. Use mysql to extract into another area,
> but use a special font (barcoding) to show the text instead.
>
> I can insert and extract the data no problem, but I have tried to change the
> font to avail....any ideas?
>
> The server and the receiving station have the special font installed on
> them.
>
>

attached mail follows:


Thanks I was being a moron....I thought I had the right font name, but it
turned out that I didn't.....now I do. Thanks for the help!!!

"Ron Allen" <Ronald.Allenbondsteel2.areur.army.mil> wrote in message
news:20030430144639.9474.qmailpb1.pair.com...
> How would I go about using PHP to format fonts.
>
> What I would like to do.
>
> Import some text into a database. Use mysql to extract into another area,
> but use a special font (barcoding) to show the text instead.
>
> I can insert and extract the data no problem, but I have tried to change
the
> font to avail....any ideas?
>
> The server and the receiving station have the special font installed on
> them.
>
>

attached mail follows:


OK.. I've spent the past week working my way through the PHP file wrapper
code. And have found that include and require statements DO actually go
through the wrapper code.. I have a physfs wrapper written and registered
as physfs://. Now I just need to make PHP use my wrapper instead of the
php_plain_files_wrapper... Now is there any reason as to why the
structures for the php_plain_files are defined as static??
As the real easy way to do this would be to replace the default structure
with pointers to my functions.. but it is defined as static..
so, most likely I'm going to have to create a patch to the PHP code for my
own uses...
Any other ideas on how I can accomplish this?

> On Sat, 2003-04-26 at 17:33, Rasmus Lerdorf wrote:

> But you said you wanted to intercept include and require calls as well. 
> There is no hook for doing that.  We go directly to the filesystem.

> On Sat, 26 Apr 2003 17:29:17 -0500, Edward Rudd wrote:

> Well, I'm using the SAPI Embed module to embed the PHP "engine" in my
> program similar to using python or TCL as a "scripting engine".
> So I'm not wanting to override things in PHP, but in my C code at the
> engine level.. I just need to find some better documentation/pointers as
> to where to start.
>
> On Sat, 26 Apr 2003 15:14:23 -0700, Rasmus Lerdorf wrote:
>
>> On Sat, 26 Apr 2003, Edward Rudd wrote:
>>> That's not quite what I'm wanting.. but it'll do to hack things
>>> in for now, what I'm wanting is native code implementation of this
>>> and be able to override ALL file access. Including include and require
>>> statements..
>>
>> Then you need to do it at your kernel level or somewhere below PHP. We do
>> not wrap all file access as it would be way too slow.
>>
>> -Rasmus

attached mail follows:


Hello all mailing-list people, I need help, my question is: How could I build a web site that I can translate easy the language of it?

Thanks for all your help, bye.

attached mail follows:


good question..

Theres a good tutorial on localization on java.sun.com somewhere.. (Java
centric of course but easily adapted to PHP)

LW

-----Original Message-----
From: Orlando Pozo [mailto:o_j_p_picnet.com.ve]
Sent: Sunday, 6 December 2065 10:13 AM
To: php-generallists.php.net
Subject: [PHP] Translate easy the language of the web site

Hello all mailing-list people, I need help, my question is: How could I
build a web site that I can translate easy the language of it?

Thanks for all your help, bye.

attached mail follows:


hi guys i have having some wierd intermittant header output to pdf
problems , i have made a system where i can make reports to pdf , either
having the option to download or output to the screen and print , i am
having some issues , where the download option is working fine , but when i
try and header output to the screen i just get a blank screen sometime it
loads acrobat's splash screen and thats it :\

here is the code

header("Content-Type: application/pdf");
Header('Content-disposition: inline; filename=doc.pdf');
flush();
$this->convert();

where convert is the passthru output from htmldoc

i have tried heaps of different things sometimes it works then i do
something then it doesnt , i have tried this in the header

header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");

i have also tried
session_cache_limiter('nocache');
session_start();

as aparantly sessions cause error , i dont know what the problem is any
ideas let me know thanks

attached mail follows:


I think that PHP have libraries to translate one language into another, if you have information about it, please, give me a hand, thanks, bye.

attached mail follows:


Unfortunatly PHP doesnt have any [core] libraries that can perform this
functionality.

LW

-----Original Message-----
From: Orlando Pozo [mailto:o_j_p_picnet.com.ve]
Sent: Sunday, 6 December 2065 10:30 AM
To: php-generallists.php.net
Subject: [PHP] Translate web site language

I think that PHP have libraries to translate one language into another, if
you have information about it, please, give me a hand, thanks, bye.

attached mail follows:


Orlando Pozo wrote:
> I think that PHP have libraries to translate one language into another, if you have information about it, please, give me a hand, thanks, bye.
>
>
Have a look at the gettext functions:
http://www.php.net/manual/en/ref.gettext.php

attached mail follows:


I need help with displaying an australian version of the current date and
time.

I've set the locale for my application using: setlocale (LC_ALL, 'en');

Here is a class method I am using to return a date/time string

 /**
 * Displays a human-readable version of a unix timestamp.
 *
 * access public
 * param string timestamp A unix timestamp
 * return string
 */
  function dateAndTime($timestamp)
  {
   // Parse input as a unix timestamp and list each part as separate
variable
      list($year,$month,$day,$hour,$minute,$second) =
sscanf($timestamp,"%4s%2s%2s%2s%2s%2s");

   // Return a formatted date/time according to our preferred locale
      return strftime('%c',
mktime($hour,$minute,$second,$month,$day,$year));
  }

 Here is a sample command with a timestamp as input: echo
dateAndTime('20030430121556');

 Here is output from the above command: 04/30/03 12:15:56 PM

 NOTE THAT THE DATE AND MONTH NEED TO BE INTERCHANGED!!!!!!!!

 Please help, this is driving me nuts.. I dont know how to set the locale
speficically for Australia or if it is even possible with PHP..

> Luke Woollard
> .......................................................
> Programmer / Analyst
> TABORVISION
> luketaborvision.com
> 03.9886.0881 ext 105
> www.taborvision.com
> .......................................................
>
> This document is confidential and may contain legally privileged
> information. If you are not the intended recipient you must not copy,
> distribute or act in reliance on it. The sender cannot guarantee that this
> email or any attachment to it is free of computer viruses or other
> conditions that may damage or interfere with data, hardware or software
with
> which it might be used. If you have received this document in error,
please
> advise us toll free on 1.800.50.50.42 Australia :: 973.556.1107 USA
>

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

attached mail follows:


Luke,

Please don't the same message over and over... people will answer it when/if
they can.

For starters, 20030430121556 doesn't look like a unix (epoch) timestamp to
me... it looks more like YYYYMMDDHHMMSS.

Secondly, I'm not sure your problem is directly related to locale.

For argument's sake, let's take a different approach:

<?
function formatDateFromStamp($stamp)
    {
    $year4 = substr($stamp,0,4);
    $year2 = substr($stamp,2,2);
    $month = substr($stamp,4,2);
    $day = substr($stamp,6,2);
    $hour = substr($stamp,8,2);
    $min = substr($stamp,10,2);
    $sec = substr($stamp,12,2);
    if($hour >= 12) { $ampm = "pm"; } else { $ampm = "am"; }

    return "{$day}/{$month}/{$year2} {$hour}:{$min}:{$sec}{$ampm}";
    }
    
echo formatDateFromStamp('20030430121556');
?>

This will echo 30/04/03 12:15:56pm, which seems to be what you want -- why
do you need to go through mktime, and where is the locale issue?

Really, I'd be throwing away the stamps you're currently using, and just
using unix epoch time stamps (the number of seconds since 1970).

They can easily be obtained at any time in a script using time(), can easily
have a number of seconds added, subtracted and dived to them, are easily
compared (one is greater than the other, etc).

Better still, they're easily converted to human-readable dates using date():

echo date('d/m/y h:i:s a',$mystamp);

Anyway, I guess you should do a few inserts, and retrievals, to see how the
above function stacks up against the existing one... then if there's still a
locale issue, we can tackle that.

Justin French

on 01/05/03 4:11 PM, Luke Woollard (luketaborvision.com) wrote:

> I need help with displaying an australian version of the current date and
> time.
>
> I've set the locale for my application using: setlocale (LC_ALL, 'en');
>
> Here is a class method I am using to return a date/time string
>
> /**
> * Displays a human-readable version of a unix timestamp.
> *
> * access public
> * param string timestamp A unix timestamp
> * return string
> */
> function dateAndTime($timestamp)
> {
> // Parse input as a unix timestamp and list each part as separate
> variable
> list($year,$month,$day,$hour,$minute,$second) =
> sscanf($timestamp,"%4s%2s%2s%2s%2s%2s");
>
> // Return a formatted date/time according to our preferred locale
> return strftime('%c',
> mktime($hour,$minute,$second,$month,$day,$year));
> }
>
> Here is a sample command with a timestamp as input: echo
> dateAndTime('20030430121556');
>
> Here is output from the above command: 04/30/03 12:15:56 PM
>
> NOTE THAT THE DATE AND MONTH NEED TO BE INTERCHANGED!!!!!!!!
>
> Please help, this is driving me nuts.. I dont know how to set the locale
> speficically for Australia or if it is even possible with PHP..
>
>
>> Luke Woollard
>> .......................................................
>> Programmer / Analyst
>> TABORVISION
>> luketaborvision.com
>> 03.9886.0881 ext 105
>> www.taborvision.com
>> .......................................................
>>
>> This document is confidential and may contain legally privileged
>> information. If you are not the intended recipient you must not copy,
>> distribute or act in reliance on it. The sender cannot guarantee that this
>> email or any attachment to it is free of computer viruses or other
>> conditions that may damage or interfere with data, hardware or software
> with
>> which it might be used. If you have received this document in error,
> please
>> advise us toll free on 1.800.50.50.42 Australia :: 973.556.1107 USA
>>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

attached mail follows:


<?
function formatDateFromStamp($stamp)
    {
    $year4 = substr($stamp,0,4);
    $year2 = substr($stamp,2,2);
    $month = substr($stamp,4,2);
    $day = substr($stamp,6,2);
    $hour = substr($stamp,8,2);
    $min = substr($stamp,10,2);
    $sec = substr($stamp,12,2);
    if($hour >= 12) { $ampm = "pm"; } else { $ampm = "am"; }

    return "{$day}/{$month}/{$year2} {$hour}:{$min}:{$sec}{$ampm}";
    }

echo formatDateFromStamp('20030430121556');
?>

This will echo 30/04/03 12:15:56pm, which seems to be what you want -- why
do you need to go through mktime,
http://www.php.net/manual/en/function.mktime.php
AS YOU SEE ON THE MANUAL PAGE, mktime() GIVES A UNIX 'epoch' TIMESTAMP

and where is the locale issue?

THE LOCALE ISSUE IS, MY APP HAS OPTIONS FOR NUMEROUS LANGUAGES.
DATES ARE DISPLAYED DIFFERENTLY TO AUSTRALIA IN THE USA
I WANT TO USE ONE SIMPLE FUNCTION (THAT USES strftime() ) TO OUTPUT A
LOCALE-SPECIFIC TIME WITH A GIVEN TIMESTAMP (EPOCH OR OTHER), THE SPECIFIC
LOCALE IS SET USING setlocale() AT APPLICATION CONFIG TIME..

Really, I'd be throwing away the stamps you're currently using, and just
using unix epoch time stamps (the number of seconds since 1970).
DOING SO WOULDNT SOLVE MY PROBLEM.

ANY MORE SUGGESTIONS WOULD BE APPRECIATED.

attached mail follows:


> // Return a formatted date/time according to our preferred locale
> return strftime('%c',
> mktime($hour,$minute,$second,$month,$day,$year));

Have you tried the strftime outside the function? To me it looks like what
you're doing should be OK.

Sorry - that's all I've got when the clock ticks over past 5 and I can leave
work :)

> Here is a sample command with a timestamp as input: echo
> dateAndTime('20030430121556');
>
> Here is output from the above command: 04/30/03 12:15:56 PM
>
> NOTE THAT THE DATE AND MONTH NEED TO BE INTERCHANGED!!!!!!!!
>
> Please help, this is driving me nuts.. I dont know how to set the locale
> speficically for Australia or if it is even possible with PHP..
>
>
> > Luke Woollard
> > .......................................................
> > Programmer / Analyst
> > TABORVISION
> > luketaborvision.com
> > 03.9886.0881 ext 105
> > www.taborvision.com
> > .......................................................
> >
> > This document is confidential and may contain legally privileged
> > information. If you are not the intended recipient you must not copy,
> > distribute or act in reliance on it. The sender cannot guarantee that
this
> > email or any attachment to it is free of computer viruses or other
> > conditions that may damage or interfere with data, hardware or software
> with
> > which it might be used. If you have received this document in error,
> please
> > advise us toll free on 1.800.50.50.42 Australia :: 973.556.1107 USA
> >
>
>
> --
> 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
>
>
> Scanned by PeNiCillin http://safe-t-net.pnc.com.au/
>

Scanned by PeNiCillin http://safe-t-net.pnc.com.au/

attached mail follows:


Thanks Bob,

I have an it fails.

LW

-----Original Message-----
From: Bob Irwin [mailto:bobstaff.pnc.com.au]
Sent: Thursday, 1 May 2003 5:13 PM
To: Luke Woollard; PHP-general
Subject: Re: [PHP] Date Localization - Australian

> // Return a formatted date/time according to our preferred locale
> return strftime('%c',
> mktime($hour,$minute,$second,$month,$day,$year));

Have you tried the strftime outside the function? To me it looks like what
you're doing should be OK.

Sorry - that's all I've got when the clock ticks over past 5 and I can leave
work :)

> Here is a sample command with a timestamp as input: echo
> dateAndTime('20030430121556');
>
> Here is output from the above command: 04/30/03 12:15:56 PM
>
> NOTE THAT THE DATE AND MONTH NEED TO BE INTERCHANGED!!!!!!!!
>
> Please help, this is driving me nuts.. I dont know how to set the locale
> speficically for Australia or if it is even possible with PHP..
>
>
> > Luke Woollard
> > .......................................................
> > Programmer / Analyst
> > TABORVISION
> > luketaborvision.com
> > 03.9886.0881 ext 105
> > www.taborvision.com
> > .......................................................
> >
> > This document is confidential and may contain legally privileged
> > information. If you are not the intended recipient you must not copy,
> > distribute or act in reliance on it. The sender cannot guarantee that
this
> > email or any attachment to it is free of computer viruses or other
> > conditions that may damage or interfere with data, hardware or software
> with
> > which it might be used. If you have received this document in error,
> please
> > advise us toll free on 1.800.50.50.42 Australia :: 973.556.1107 USA
> >
>
>
> --
> 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
>
>
> Scanned by PeNiCillin http://safe-t-net.pnc.com.au/
>

Scanned by PeNiCillin http://safe-t-net.pnc.com.au/

attached mail follows:


Luke,

Let's start from the start.

1. The Timestamp:

a HOW was this timestamp generated -- by PHP? MySQL? Something else?

b WHERE was it generated -- I assume on the live server in the US?

c what TIMEZONE is the timestamp in? GMT? US?

2. The Conversion:

a is the conversion taking place on the same server as the stamp was
generated?

Thanks,

Justin

attached mail follows:


Hiya I just wanted to know if there was any tips people could offer me
regarding cascade deletes. im using mysql and want to hard code delete query
that traverses the necesssary tables using php.

For e.g. I had a Project table, which contains loads of bugs (in the bug
table). Every bug is stored with the foreign key projid so to know which
bugs are related to which projects. Now inside every bug I allow the option
to add a followup to update the bug such as status of the bug....(This data
stored in the bug_followup table).

Now say I want to delete a project I can get all the bugs in that project
with:
select bugid from bug, project where bug.projid=project.projid;

Now I can get all the followups of the bug also doing(im guessing):
select * from bug_followup, bug where bugid=bug.bugid. But just not sure how
to join up the queries?I should do this?

Is there a way to build a nested query such as in php:

delete * from bug_followup where bugid =(select bugid from bug where
projid=$projid;

Thanx

Bobster

_________________________________________________________________
Hotmail messages direct to your mobile phone http://www.msn.co.uk/mobile

attached mail follows:


So if mysql doesnt support cascade and nested queries can someone tell me
how they get around deleting from more than one table. I suppose im really
stuck on looping through one table and deleting all the rows.

Here I go again:

I can see the projid of the project wishes to delete and also I can see
all the bugs which exist in that project by doing:

select * from bug where bug.projid='$projid'
But how do I do the logic for every bug that is within that project check to
see if it has bug followups and if so delete them per bug untill all bug
followups have been deleted then delete the bug then finally delete the
project.

DO I need to use some sort of loop to delete?

Going into my example in first email:

would I use:
Delete * from bug_follow_up where bug_follow_up.bugid=bug.bugid.
Delete * from bug where bug.bugid=project_followup.bugid
Delete * from project where projid='$projid'

Cheers

Bobby

>From: "Bobby Rahman" <bobby_rahman2002hotmail.com>
>To: php-generallists.php.net
>Subject: [PHP] [Newbie] Cascade delete manually
>Date: Thu, 01 May 2003 05:22:38 +0000
>
>
>
>Hiya I just wanted to know if there was any tips people could offer me
>regarding cascade deletes. im using mysql and want to hard code delete
>query that traverses the necesssary tables using php.
>
>For e.g. I had a Project table, which contains loads of bugs (in the bug
>table). Every bug is stored with the foreign key projid so to know which
>bugs are related to which projects. Now inside every bug I allow the option
>to add a followup to update the bug such as status of the bug....(This data
>stored in the bug_followup table).
>
>Now say I want to delete a project I can get all the bugs in that project
>with:
>select bugid from bug, project where bug.projid=project.projid;
>
>Now I can get all the followups of the bug also doing(im guessing):
>select * from bug_followup, bug where bugid=bug.bugid. But just not sure
>how to join up the queries?I should do this?
>
>Is there a way to build a nested query such as in php:
>
>delete * from bug_followup where bugid =(select bugid from bug where
>projid=$projid;
>
>Thanx
>
>Bobster
>
>_________________________________________________________________
>Hotmail messages direct to your mobile phone http://www.msn.co.uk/mobile
>
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php
>

_________________________________________________________________
Get Hotmail on your mobile phone http://www.msn.co.uk/mobile

attached mail follows:


On 01-May-2003 Bobby Rahman wrote:
>
>
> So if mysql doesnt support cascade and nested queries can someone tell me
> how they get around deleting from more than one table. I suppose im
> really
> stuck on looping through one table and deleting all the rows.
>
> Here I go again:
>
> I can see the projid of the project wishes to delete and also I can see
> all the bugs which exist in that project by doing:
>
> select * from bug where bug.projid='$projid'
> But how do I do the logic for every bug that is within that project check
> to
> see if it has bug followups and if so delete them per bug untill all bug
> followups have been deleted then delete the bug then finally delete the
> project.
>
> DO I need to use some sort of loop to delete?

I get all the id's into an array then:

$list= implode(',', $ids);

$qry="DELETE FROM foo WHERE id IN ($list)";
mysql_query($qry);

$qry="DELETE FROM bar WHERE idref IN ($list)";
mysql_query($qry);

Regards,
--
Don Read dreadtexas.net
-- It's always darkest before the dawn. So if you are going to
   steal the neighbor's newspaper, that's the time to do it.

attached mail follows:


> Looks like the stat system over smb is not 100% reliable.
> Maybe on the null ones you could try changing to it as if it was a
> directory and if that fails then it is not a directory..

OK, here's the code I wound up with :

Importantly, I needed to have

 error_reporting(1);

at the top of the script, otherwise all those warnings would have driven me
crazy :)

The recursive function thereafter was:

function traverseDir($item_to_test, $level, $file_path) {
 $level = $level + 1;

 if (strcmp($item_to_test, ".") == 0) {
  $fullpath = <some path>;
 }
 else {
  $fullpath = $file_path . "/" . $item_to_test;
 }

 if((boolean)opendir($fullpath) == 1) {
  if ($handle = opendir($fullpath)) {
   while (false !== ($file = readdir($handle))) {
    //exclude the . and .. files
    if ($file != "." && $file != "..") {
     traverseDir($file, $level, $fullpath);
    }
   }
  }
 }
 else {
  echo str_repeat("&nbsp;&nbsp;&nbsp;", $level * 2) . $file_path . "/" .
$item_to_test . "<br>\n";
 }
}

All that $level really was for was to indent the echo during the script
output, but it servers as a kind of counter to find how many levels deep
your directory structure goes...

Thanks everyone for your help :)

Jason =)

attached mail follows:


hello. i have been asking for help to get a remote
html file echoed onto my webpage since include()
doesn't seem to work with it anymore since the new php
version/server.

one of the list users suggested fopen(). I have used
the following code both with and without the trailing
url slash:

<?$fp=fopen("http://www.wiu.edu/stu/","r");
while (!feof ($fp)){
$buffer=fgets($fp,4096);
echo $buffer;}?>

but i get the following results with the errors on
line 2 and 3 repeating over and over and over below
what is displayed below:

Warning: fopen(http://www.wiu.edu/stu/)
[function.fopen]: failed to create stream: Invalid
argument in
/hsphere/local/home/user/domain/index.phtml on line 1

Warning: feof(): supplied argument is not a valid
stream resource in
/hsphere/local/home/user/domain/index.phtml on line 2

Warning: fgets(): supplied argument is not a valid
stream resource in
/hsphere/local/home/user/domain/index.phtml on line 3

what's wrong? it works with yahoo.com but it takes
like 15 seconds (just like include() does now for the
sites that work with it). is this possibly a server
config problem? allow url fopen is on. what should i
check or do? thanks

__________________________________
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.
http://search.yahoo.com

attached mail follows:


didn't work. got:

Warning: fopen(http://www.wiu.edu/stu/)
[function.fopen]: failed to create stream: Invalid
argument in
/hsphere/local/home/user/domain/index.phtml on line 2

Warning: fread(): supplied argument is not a valid
stream resource in
/hsphere/local/home/user/domain/index.phtml on line 3

Warning: fclose(): supplied argument is not a valid
stream resource in
/hsphere/local/home/user/domain/index.phtml on line 7

tried both with and without trailing slash. worked
once again for yahoo (but also slowly)

--- dwalker <dwalkerhealthyproductsplus.com> wrote:
> try something like:
>
> <?php
> $filedata=fopen("http://www.someplace.com","r") ;
> while ($line=fread($filedata,100))
> {
> $ var.=$line;
> }
> fclose ($filedata);
>
>
>
>
> ?><?php $text = $var; ?><?php
> function safeHTML($text)
>
> // $text = stripslashes($text);
> // $text = ereg_replace ("<a[^>]+href *= *([^
> ]+)[^>]*>", "<a
> href=\\1>", $text);
> // $text = ereg_replace ("<([b|i|u])[^>]*>",
> "<\\1>", $text);
> $text = preg_replace
> ("/<title[^>]*>/","&lt!--",$text);
> // $text = strip_tags($text, '<table>');
> // $text=
> preg_replace("/<table[^>]*?/>.*?","kk",$text);
> // $text=
>
ereg_replace("&lt;script[^&gt;]*&gt;[\w|\t|\r|\W]*&lt;/script&gt;","",$test)
> ;
> file://$text=
>
ereg_replace("&lt;title[^&gt;]*&gt;*&lt;/title&gt;","",$test);
> file://$text=
>
ereg_replace("&lt;[^&gt;\s]*\btitle\b[^&gt;]*&gt;","lll",$test);
> return $text;
>
> }
> ?>
>
> -----Original Message-----
> From: Police Trainee <policetraineeyahoo.com>
> To: PHP <php-generallists.php.net>
> Date: Thursday, May 01, 2003 12:52 AM
> Subject: [PHP] fopen won't work :(
>
>
> >hello. i have been asking for help to get a remote
> >html file echoed onto my webpage since include()
> >doesn't seem to work with it anymore since the new
> php
> >version/server.
> >
> >one of the list users suggested fopen(). I have
> used
> >the following code both with and without the
> trailing
> >url slash:
> >
> ><?$fp=fopen("http://www.wiu.edu/stu/","r");
> >while (!feof ($fp)){
> >$buffer=fgets($fp,4096);
> >echo $buffer;}?>
> >
> >but i get the following results with the errors on
> >line 2 and 3 repeating over and over and over below
> >what is displayed below:
> >
> >Warning: fopen(http://www.wiu.edu/stu/)
> >[function.fopen]: failed to create stream: Invalid
> >argument in
> >/hsphere/local/home/user/domain/index.phtml on line
> 1
> >
> >Warning: feof(): supplied argument is not a valid
> >stream resource in
> >/hsphere/local/home/user/domain/index.phtml on line
> 2
> >
> >Warning: fgets(): supplied argument is not a valid
> >stream resource in
> >/hsphere/local/home/user/domain/index.phtml on line
> 3
> >
> >
> >what's wrong? it works with yahoo.com but it takes
> >like 15 seconds (just like include() does now for
> the
> >sites that work with it). is this possibly a server
> >config problem? allow url fopen is on. what should
> i
> >check or do? thanks
> >
> >__________________________________
> >Do you Yahoo!?
> >The New Yahoo! Search - Faster. Easier. Bingo.
> >http://search.yahoo.com
> >
> >--
> >PHP General Mailing List (http://www.php.net/)
> >To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>

__________________________________
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.
http://search.yahoo.com

attached mail follows:


Why aren't you using curl ?

$url = "http://www.wiu.edu/stu/";
$ch = curl_init($url); //--> Sets session handle for CURL to use

curl_setopt($ch, CURLOPT_TIMEOUT, 4); //--> CURL session options :
number of seconds to allow each CURL command to execute
curl_setopt($ch, CURLOPT_FAILONERROR, 1); //--> :silent failure if the
HTTP code <> 300
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //--> :tells CURL to return
the transfer rather than print it to stdout

$content = curl_exec($ch); //--> executes CURL session and returns
output to a string.

The entire HTML for that page should now be stored in $content

Jason =)

attached mail follows:


Hi there,

I would like to check for an error in the php error log.

PHPinfo says that error log is called: error_log_php
end loging is on.

I cant locate this file on the server. Can anybody give me hint on this?

Thanx,

Merlin

--
Worldwide Travel Community
http://www.globosapiens.net

attached mail follows:


What I would like to do...
I would like to have either MySql or PHP replace a space with an underscore
from a MySql query. Any ideas on how to do that?

I have something like this
select * from table1 where blah = blah

echo "*$blah*";

I could use Excel to remove all the spaces, but that would not be a true
script....kind of cheating.....any help would be appreciated!!!

attached mail follows:


Hello Ron,

Thursday, May 1, 2003, 10:44:01 AM, you wrote:

RA> What I would like to do...
RA> I would like to have either MySql or PHP replace a space with an underscore
RA> from a MySql query. Any ideas on how to do that?

http://www.php.net/manual/en/function.eregi-replace.php

$foo = "goat cheese jim zoo";
$bar = eregi_replace(" ","_",$foo);
echo $bar;

--
Best regards,
 Burhan
 phplist[at]meidomus[dot]com

attached mail follows:


str_replace(' ', '_', $someString);

-----Original Message-----
From: Burhan Khalid [mailto:phplistmeidomus.com]
Sent: Thursday, 1 May 2003 6:26 PM
To: Ron Allen; php-generallists.php.net
Subject: Re: [PHP] Replacing a space with an underscore

Hello Ron,

Thursday, May 1, 2003, 10:44:01 AM, you wrote:

RA> What I would like to do...
RA> I would like to have either MySql or PHP replace a space with an
underscore
RA> from a MySql query. Any ideas on how to do that?

http://www.php.net/manual/en/function.eregi-replace.php

$foo = "goat cheese jim zoo";
$bar = eregi_replace(" ","_",$foo);
echo $bar;

--
Best regards,
 Burhan
 phplist[at]meidomus[dot]com

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

attached mail follows:


> What I would like to do...
> I would like to have either MySql or PHP replace a space with an underscore
> from a MySql query. Any ideas on how to do that?

str_replace()
preg_replace()
ereg_replace()

all fit the bill and will do what you need.

Chris

attached mail follows:


> > What I would like to do...
> > I would like to have either MySql or PHP replace a space with an
> underscore
> > from a MySql query. Any ideas on how to do that?
>
> str_replace()
> preg_replace()
> ereg_replace()
>
> all fit the bill and will do what you need.

But you SHOULD use str_replace()... Using regular expressions for a
simple replace like this is a waste of resources.

In general, you should always benchmark your solutions. Just because
something is a single line of code in a regular expression, a couple
lines of individual str_replace()es might be faster. Been there, seen
that. :)

---John W. Holmes...

PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/

attached mail follows:


Mysql:

        SELECT REPLACE(blah,' ','_') as blahWithUnderScore WHERE x=x

PHP:

                $string = str_replace(" ","_", $string);
                $string = preg_replace("/[\s]/","_",$string);
                $string = eregi_replace("[[:space:]]","_",$string);

I would use the mySql way.

Ron Allen wrote:
> What I would like to do...
> I would like to have either MySql or PHP replace a space with an underscore
> from a MySql query. Any ideas on how to do that?
>
> I have something like this
> select * from table1 where blah = blah
>
> echo "*$blah*";
>
> I could use Excel to remove all the spaces, but that would not be a true
> script....kind of cheating.....any help would be appreciated!!!
>
>

attached mail follows:


Hey All,

Not asking anyone here to write me a script or anything, just after some
pointers on where to start (other than php.net).

What I want to do is grab a whole heap of variables that a user puts in ie-
email, address, phone, name etc. And put them in to a "template" email that
will be sent to them and BCC'd to my email address.

I know how to put all the variables into place, just after a start on the
email side... thanks

- paul -

attached mail follows:


http://php.net/mail

Justin

on 01/05/03 6:41 PM, Inpho (inphormgmx.net) wrote:

> Hey All,
>
> Not asking anyone here to write me a script or anything, just after some
> pointers on where to start (other than php.net).
>
> What I want to do is grab a whole heap of variables that a user puts in ie-
> email, address, phone, name etc. And put them in to a "template" email that
> will be sent to them and BCC'd to my email address.
>
> I know how to put all the variables into place, just after a start on the
> email side... thanks
>
> - paul -
>
>

attached mail follows:


Does anyone know where I could obtain a php script so my members can search
by zip code?

Thanks in advance
Blade

_________________________________________________________________
STOP MORE SPAM with the new MSN 8 and get 2 months FREE*
http://join.msn.com/?page=features/junkmail

attached mail follows:


"Rasmus Lerdorf" <rasmuslerdorf.com> wrote in message
news:Pine.LNX.4.44.0304301310500.868-100000thinkpad.lerdorf.com...
> I think you guys are missing the point I was trying to make. My first
> point was that it is not possible to build a general-purpose templating
> system that won't eventually evolve into PHP.

I have understood your statement. TemplateTamer uses full and native PHP as
"logic" language for it's templates, so there is no separate language used
to control templates. It is just full and plain PHP at your disposall. The
trick is, that templates are not controled by some intermideate language
embeded in the template, but by php code preparing the data tree to be
displayed. So you have a full php strength at your disposal, you are not
working in some brewed up language but in php.

>Then my second point was
> that it is very possible to build very specific templating solutions using
> PHP.

Well, yes, I believe you can, and that many or some people find this method
more natural, or simpler. But for me tools like TT offer me more power, and
simplify coding and improve separation of code and html. I do understand
that things like that are highly subjective, and that it is not necessarily
the same for everyone else.

>As far as I am concerned templates should not have any sort of logic in
>them, including iterators. But this is a religious issue that nobody can
>agree on and I don't expect to see agreement here.

Well, if it is of any comfort, TemplateTamer does not have any sort of logic
embeded in templates, and specially not iterators, so we actually have very
similar opinion on the topic :)

rush
--
http://www.templatetamer.com/

attached mail follows:


In all honesty, I find it very hard to listen to your arguments.

They may be right, and they may be wrong, but the fact remains that you have
a commercial interest in arguing the side of templates (and your product
TemplateTamer), which is just like a butcher arguing the benefits of
including meat in your diet.

Justin

attached mail follows:


"Justin French" <justinindent.com.au> wrote in message
news:BAD736E9.25D0A%justinindent.com.au...
> In all honesty, I find it very hard to listen to your arguments.
>
> They may be right, and they may be wrong, but the fact remains that you
have
> a commercial interest in arguing the side of templates (and your product
> TemplateTamer), which is just like a butcher arguing the benefits of
> including meat in your diet.

In the signature of all my posts I am including link to the TemplateTamer,
so I think I have made quite clear that I am connected to it, and from that
it follows that I do have interest that it succedes.

However I do not think that excludes me form arguing about templates, what
are prons and cons, and how does the TT fit in the scene from my view. I
also often try to point out that many of the issues are in the area of
personal and style, that there other approaches as well, and I often point
readers to other template systems, and that people should lear about the
options but in the end use what they find best for them.

In the end, I believe that arguments and opinons should be able to stand by
themselves, regardless of who made them. I have made known my relation to
the TT so that people can put what I am saying to more scrutiny, but I think
that there is really nothing wrong with me expressing what I think here, and
explaining how TT works when the subject is templates.

It is by all means your choice what will you read, and with how much effort,
but if my posts fail in non-credible for you, I am sorry, and I will
certanly miss your (or everyone elses with same stance) reading, since I
have tried to sincerely express what do I think.

Thanks for the honesty, however, it was as always very valuable.

Sincerely,

rush
--
http://www.templatetamer.com/

attached mail follows:


on 01/05/03 10:28 PM, rush (piparush.avalon.hr) wrote:

> Thanks for the honesty, however, it was as always very valuable.

Hey, as long as everyone knows if you're a "butcher" or "vegeterian",
everything is fine :)

Justin

attached mail follows:


I am trying to develop a way of tracking users on my site. I have read a few
articles on Custom Session Handlers that suggest this as a way of expanding
the usefulness of sessions. I currently use sessions on every page of my site
so I can track unique vistors to my site and I want to be able to display how
many users are browsing the site, how many are logged in and who is logged
in.

Can anyone recommend and good tutorials or any further research? Or has anyone
got a tried and tested method of doing this sort of thing?

Rob

attached mail follows:


phpbb forum uses sessions really nicely and stores sessions details in the
database, i would say download their code and go through the sessions.php
file and workout how they done it.. i am donig the same thing ;)

http://www.phpbb.com

-awlad

----- Original Message -----
From: "Rob Lacey" <phpextrememetal.co.uk>
To: <php-generallists.php.net>
Sent: Thursday, May 01, 2003 11:15 AM
Subject: [PHP] Custom Session Handlers and User Tracking

> I am trying to develop a way of tracking users on my site. I have read a
few
> articles on Custom Session Handlers that suggest this as a way of
expanding
> the usefulness of sessions. I currently use sessions on every page of my
site
> so I can track unique vistors to my site and I want to be able to display
how
> many users are browsing the site, how many are logged in and who is logged
> in.
>
> Can anyone recommend and good tutorials or any further research? Or has
anyone
> got a tried and tested method of doing this sort of thing?
>
> Rob
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

attached mail follows:


> I am trying to develop a way of tracking users on my site. I have read
a
> few
> articles on Custom Session Handlers that suggest this as a way of
> expanding
> the usefulness of sessions. I currently use sessions on every page of
my
> site
> so I can track unique vistors to my site and I want to be able to
display
> how
> many users are browsing the site, how many are logged in and who is
logged
> in.
>
> Can anyone recommend and good tutorials or any further research? Or
has
> anyone
> got a tried and tested method of doing this sort of thing?

You'll be using this function:

http://www.php.net/manual/en/function.session-set-save-handler.php

You should find some examples there. Searching for tutorials on your
subject with Google should yield some more results.

---John W. Holmes...

PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/

attached mail follows:


What I would like to do is use what Luke or Burhan gave me to try as far as
replacing the spaces with an underscore, but I am having a hard time placing
the variable for me to manipulate!

Overall all result will be 3 columns with different record fields represnted
by a bar code with spaces taken out.

I have been looking at this for several hours now and I am still scrathcing
my head. Any suggestions?

<?PHP
include 'drop.php';
$DBName = "******";
$table = "*****";
$db = mysql_connect("$DBhost","$DBuser","$DBpass") or die("Problem
connecting");
mysql_select_db("$DBName") or die("Problem selecting database");
$query = "SELECT * FROM $table";
$result = mysql_query($query) or die ("Query failed");
//let's get the number of rows in our result so we can use it in a for loop
$numofrows = mysql_num_rows($result);
?>

<?PHP
echo "<body>";
echo "<TABLE align=left BORDER=\"1\">\n";
echo "<TR width=75%<TD WIDTH=150><font size=2><center><b>BLDG ROOM
CABINET</b></center></TD>\n";
for($i = 0; $i < $numofrows; $i++) {
    $row = mysql_fetch_array($result); //get a row from our result set

    //$Bldgroomcabpost = ".$row['Bldgroomcab'].";
    //$Bldgroomcabspace = str_replace(" ", "_", $Bldgroomcabpost);
    echo "<TD><font size=3
face=********><center>".$row['Bldgroomcab']."</TD>\n";
    echo "</TR>\n";
}
//now let's close the table and be done with it
echo "</TABLE>\n";
echo "</body>"

?>

attached mail follows:


At 12:59 1-5-03, you wrote:
>What I would like to do is use what Luke or Burhan gave me to try as far as
>replacing the spaces with an underscore, but I am having a hard time placing
>the variable for me to manipulate!

I hope I get your question right: Am i right that the replacing of the
space to an underscore works now?

>Overall all result will be 3 columns with different record fields represnted
>by a bar code with spaces taken out.
So your question is how to present the results in 3 columns?

simplest would be:
echo '<tr>';
for($i = 0; $i < $numofrows; $i++) {
     $row = mysql_fetch_array($result); //get a row from our result set
    echo "<TD><etc>".$row['Bldgroomcab']."</TD>\n";
         //make new row after every 3rd item
        if (($i+1)%3==0) echo "</TR>\n<tr>";
    }
echo '</tr>';

About your query: if you are only using the field Bldgroomcab, you can
replace the * in the query with Bldgroomcab, without quotes, to reduce the
result set.

>I have been looking at this for several hours now and I am still scrathcing
>my head. Any suggestions?
>
>for($i = 0; $i < $numofrows; $i++) {
> $row = mysql_fetch_array($result); //get a row from our result set
>
> //$Bldgroomcabpost = ".$row['Bldgroomcab'].";
> //$Bldgroomcabspace = str_replace(" ", "_", $Bldgroomcabpost);
> echo "<TD><font size=3
>face=********><center>".$row['Bldgroomcab']."</TD>\n";
> echo "</TR>\n";
>}
>//now let's close the table and be done with it
>echo "</TABLE>\n";
>echo "</body>"
>
>?>
>
>
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php

attached mail follows:


I want to be able to use the str_replace function so that I do not have
spaces and replace them with underscores.

"Chris Hayes" <chayesantenna.nl> wrote in message
news:5.2.0.9.0.20030501131245.020cdb60pop4.antenna.nl...
> At 12:59 1-5-03, you wrote:
> >What I would like to do is use what Luke or Burhan gave me to try as far
as
> >replacing the spaces with an underscore, but I am having a hard time
placing
> >the variable for me to manipulate!
>
> I hope I get your question right: Am i right that the replacing of the
> space to an underscore works now?
>
> >Overall all result will be 3 columns with different record fields
represnted
> >by a bar code with spaces taken out.
> So your question is how to present the results in 3 columns?
>
> simplest would be:
> echo '<tr>';
> for($i = 0; $i < $numofrows; $i++) {
> $row = mysql_fetch_array($result); //get a row from our result set
> echo "<TD><etc>".$row['Bldgroomcab']."</TD>\n";
> //make new row after every 3rd item
> if (($i+1)%3==0) echo "</TR>\n<tr>";
> }
> echo '</tr>';
>
>
>
> About your query: if you are only using the field Bldgroomcab, you can
> replace the * in the query with Bldgroomcab, without quotes, to reduce the
> result set.
>
>
>
> >I have been looking at this for several hours now and I am still
scrathcing
> >my head. Any suggestions?
> >
> >for($i = 0; $i < $numofrows; $i++) {
> > $row = mysql_fetch_array($result); //get a row from our result set
> >
> > //$Bldgroomcabpost = ".$row['Bldgroomcab'].";
> > //$Bldgroomcabspace = str_replace(" ", "_", $Bldgroomcabpost);
> > echo "<TD><font size=3
> >face=********><center>".$row['Bldgroomcab']."</TD>\n";
> > echo "</TR>\n";
> >}
> >//now let's close the table and be done with it
> >echo "</TABLE>\n";
> >echo "</body>"
> >
> >?>
> >
> >
> >
> >--
> >PHP General Mailing List (http://www.php.net/)
> >To unsubscribe, visit: http://www.php.net/unsub.php
>

attached mail follows:


> What I would like to do is use what Luke or Burhan gave me to try as
far
> as
> replacing the spaces with an underscore, but I am having a hard time
> placing
> the variable for me to manipulate!
>
> <?PHP
> include 'drop.php';
> $DBName = "******";
> $table = "*****";
> $db = mysql_connect("$DBhost","$DBuser","$DBpass") or die("Problem
> connecting");
> mysql_select_db("$DBName") or die("Problem selecting database");
> $query = "SELECT * FROM $table";
> $result = mysql_query($query) or die ("Query failed");
> //let's get the number of rows in our result so we can use it in a for
> loop
> $numofrows = mysql_num_rows($result);
> ?>
>
> <?PHP
> echo "<body>";
> echo "<TABLE align=left BORDER=\"1\">\n";
> echo "<TR width=75%<TD WIDTH=150><font size=2><center><b>BLDG ROOM
> CABINET</b></center></TD>\n";
> for($i = 0; $i < $numofrows; $i++) {
> $row = mysql_fetch_array($result); //get a row from our result set
>
> //$Bldgroomcabpost = ".$row['Bldgroomcab'].";
> //$Bldgroomcabspace = str_replace(" ", "_", $Bldgroomcabpost);
> echo "<TD><font size=3
> face=********><center>".$row['Bldgroomcab']."</TD>\n";

echo "<TD><font size=3
face=********><center>".str_replace("
","_",$row['Bldgroomcab'])."</TD>\n";

---John Holmes...

attached mail follows:


I would like to thank everybody that helped me with this issue....Here is
the end result!

echo "<table>";
  //echo "<br><br><br><br><br>";
echo '<tr valign=top>';
  for($i = 0; $i < $numofrows; $i++) {
      $row = mysql_fetch_array($result); //get a row from our result set
     echo "<TD width=950 height=93><font face=**** size=3><center>*"
                 .str_replace(' ','_',$row['blah'])
                 ."*<br>*"
                 .str_replace(' ','_',$row['blah'])
                 ."*<br>*"
                 .str_replace(' ','_',$row['blah'])
                 ."*</TD>\n";
          //make new row after every 3rd item
         if (($i+1)%3==0) echo "</TR>\n<tr valign=top>";
     }
  echo '</tr>';

echo "</table>";
Once again thanks!!!

"John W. Holmes" <holmes072000charter.net> wrote in message
news:005c01c30fe0$a62cf140$7c02a8c0coconut...
> > What I would like to do is use what Luke or Burhan gave me to try as
> far
> > as
> > replacing the spaces with an underscore, but I am having a hard time
> > placing
> > the variable for me to manipulate!
> >
> > <?PHP
> > include 'drop.php';
> > $DBName = "******";
> > $table = "*****";
> > $db = mysql_connect("$DBhost","$DBuser","$DBpass") or die("Problem
> > connecting");
> > mysql_select_db("$DBName") or die("Problem selecting database");
> > $query = "SELECT * FROM $table";
> > $result = mysql_query($query) or die ("Query failed");
> > //let's get the number of rows in our result so we can use it in a for
> > loop
> > $numofrows = mysql_num_rows($result);
> > ?>
> >
> > <?PHP
> > echo "<body>";
> > echo "<TABLE align=left BORDER=\"1\">\n";
> > echo "<TR width=75%<TD WIDTH=150><font size=2><center><b>BLDG ROOM
> > CABINET</b></center></TD>\n";
> > for($i = 0; $i < $numofrows; $i++) {
> > $row = mysql_fetch_array($result); //get a row from our result set
> >
> > //$Bldgroomcabpost = ".$row['Bldgroomcab'].";
> > //$Bldgroomcabspace = str_replace(" ", "_", $Bldgroomcabpost);
> > echo "<TD><font size=3
> > face=********><center>".$row['Bldgroomcab']."</TD>\n";
>
> echo "<TD><font size=3
> face=********><center>".str_replace("
> ","_",$row['Bldgroomcab'])."</TD>\n";
>
> ---John Holmes...
>
>

attached mail follows:


I was learning about ob_start and how it can help you with posting more
headers without problems, and later on how it could compress the output.

Then i thought about the phpbb forum.

There already is a ob_start('ob_gzhandler') in a header which is included,
and in the phpbb configuration the Enable Gzip compression option.

On php.net i read about Gzip en Zlib compression, gzip gives slower response
times because it waits for the complete page, and then starts compressing
while zlib starts compressing at the first bytes it receives from a page..
parrallel compressing. Therefore gzip produces more cpu load.

Then, ignoring the fact that there already is an ob_start in a included
header, i put ob_start(""); at the beginning of index.php and watched the
response times then. I tried i lot more actually, and ob_start(""); with the
"" gives better results as a normal ob_start();.

response times, with gzip compression on (in phpbb configuration) AND the
extra ob_start(""); at the top of index.php, give a increase of 0.25 avg to
0.18 avg response time.

Now, with this large introduction.. how can it be? They don't give usable
answers on phpbb.com.. Is it that this extra ob_start("") creates a stacking
buffer? And why seems ob_start() to differ from ob_start("") ?

(response times mod (puts a line like "phpBB Created this page in 2.902957
seconds : 16 queries executed : GZIP compression disabled" at the bottom):
http://www.phpbb.com/mods/downloads/uploads/generation_creation_1.0.0.txt)

Thank you very much in advance!

Greets,

Marvin Vek

attached mail follows:


Hi all,

        I am using ticks to time one of my scripts and was just wondering if there
was a way to find out where the script is (filename & line or current
function/scope) at the time the tick function was called. It be nice to be
able to follow the script as it runs.

--
Regards,
        William Bailey.
        Pro-Net Internet Services Ltd.
        http://www.pro-net.co.uk
        http://wb.pro-net.co.uk

attached mail follows:


I think that i have this worked out. Below is the code i'm using, if there is
something wrong of i'm not doing things correctly then please tell me.

<?php

function get_microtime ( ) {
    list($usec, $sec)=explode(' ', microtime());
    return ((float)$usec + (float)$sec);
}

function profile ( $dump = false) {
    static $profile;
    if(!$dump){

        $debug = debug_backtrace();
        if(!isset($debug[count($debug)-2])){
      &