php-general Digest 9 Aug 2006 11:06:30 -0000 Issue 4283
Topics (messages 240346 through 240365):
Re: Strip non-alphanumerics from beginning and end?
240346 by: Adam Zey
Re: question about how php handles post'd and get'd data
240347 by: Ligaya Turmelle
select tag doesn't update post or get
240348 by: Roel Dillen
240351 by: Jochem Maas
Re: Greek Characters from MySQL to PHP to the Browser: ??????
240349 by: Ligaya Turmelle
Have a SQL Server COM question
240350 by: Todd Cary
Re: PHP Frameworks - Opinion
240352 by: Manuel Lemos
240353 by: Manuel Lemos
Re: Using preg_match to find Japanese text
240354 by: Dave M G
Re: Regular expression to find from start of string to first space [SOLVED]
240355 by: Dave M G
Dividing, and keeping, text from the first space
240356 by: Dave M G
240357 by: Robert Cummings
240358 by: Robert Cummings
240361 by: Dave M G
Re: Cron running 'Hello world' script dies with "Could not startup."
240359 by: Ivo F.A.C. Fokkema
240360 by: Ivo F.A.C. Fokkema
240364 by: Colin Guthrie
preg_match
240362 by: Peter Lauri
240363 by: Dave Goodchild
240365 by: Jochem Maas
Administrivia:
To subscribe to the digest, e-mail:
[EMAIL PROTECTED]
To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]
To post to the list, e-mail:
php-general@lists.php.net
----------------------------------------------------------------------
--- Begin Message ---
In that case you may find Regex Coach (http://weitz.de/regex-coach/)
handy. It essentially does the match in real-time as you watch, and
shows you exactly what each part of the regex is matching.
Essentially, you paste the text to search through in the bottom pane,
and start typing the regex in the top pane. It makes writing regular
expressions enormously easier. It uses LISP to emulate Perl's regular
expressions (PHP in turn uses "Perl Compatible Regular Expressions"), so
sometimes it doesn't translate a hundred percent, but it's still an
enormous help.
Regards, Adam.
Brian Dunning wrote:
Perfect, thanks very much. I think I'll probably die before I'm ever
handy with regex.
On Aug 4, 2006, at 7:57 PM, Robert Cummings wrote:
On Fri, 2006-08-04 at 19:12 -0700, Brian Dunning wrote:
Is there a command to strip all non-alphanumerics form the beginning
and end of a string?
Ex.: '&^%kj.h,kj..*(' becomes 'kj.h,kj'
<?php
$text = ereg_replace( '^[^[:alnum:]]+', '', $text );
$text = ereg_replace( '[^[:alnum:]]+$', '', $text );
?>
Cheers,
Rob.
--.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'
--PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
jonathan wrote:
i was having a conversation and was wondering where in the source code
for php is the process for writing get'd and post'd data to their
corresponding arrays? Also, is there a way to view the source code online?
thanks,
jonathan
PHP's cvs is available online at http://cvs.php.net/viewvc.cgi/php-src/.
Drill down far enough and you will get the source code.
Ex:
http://cvs.php.net/viewvc.cgi/php-src/main/fopen_wrappers.c?revision=1.183&view=markup
--
life is a game... so have fun.
--- End Message ---
--- Begin Message ---
I have a xhtml form with a <select> with options
if I click submit the processing page is loaded and the result of the form is
shown.
The option given to the processing page however is always the same: the first
in the list. It doesn't matter what I select in the drop down menu, the value
of $_POST['nameOfSelectTag'] (or get for that matter) never differs from the
first value in the drop down list. I don't use a default selected value
because the <option> tag values are dependent on the contents of a certain
table in my database.
The weird thing is that in get mode the field nameOfSelectTag does take the
right value in the adress bar but that doesn't get translated into the correct
value in $_GET so i am thinking the same happens in $_POST.
Ideas anyone
Roel
----------
Scarlet Club: Iedereen wint! Indien u nu klant wordt van Scarlet via een
bestaande Scarlet klant kunnen jullie beide cadeaucheques ontvangen ter waarde
van 50 euro! Bezoek snel http://www.scarletclub.be
--- End Message ---
--- Begin Message ---
Roel Dillen wrote:
> I have a xhtml form with a <select> with options
>
> if I click submit the processing page is loaded and the result of the form is
> shown.
> The option given to the processing page however is always the same: the first
> in the list. It doesn't matter what I select in the drop down menu, the value
> of $_POST['nameOfSelectTag'] (or get for that matter) never differs from the
> first value in the drop down list. I don't use a default selected value
> because the <option> tag values are dependent on the contents of a certain
> table in my database.
>
> The weird thing is that in get mode the field nameOfSelectTag does take the
> right value in the adress bar but that doesn't get translated into the correct
> value in $_GET so i am thinking the same happens in $_POST.
sounds like you have another field also named 'nameOfSelectTag', probably
near the bottom of your form.
>
> Ideas anyone
>
> Roel
>
> ----------
> Scarlet Club: Iedereen wint! Indien u nu klant wordt van Scarlet via een
> bestaande Scarlet klant kunnen jullie beide cadeaucheques ontvangen ter
> waarde van 50 euro! Bezoek snel http://www.scarletclub.be
>
--- End Message ---
--- Begin Message ---
John Wells wrote:
Hi Everybody,
Despite all of my Googling and noodling, I can't seem to figure this
out, and am hoping someone might be able to point me in the right
direction.
Scenario:
- Running Apache 1.3 on OSX 10.4, PHP 5.1.4, MySQL 5.0.19
- Greek text is stored in a MySQL database, encoding set to UTF-8
- From within a db admin like CocoaMySQL, the greek text looks normal
- PHP queries the db table for the greek text
- no matter how I echo the text to screen (see below), it only
produces '?????' marks
What I've tried:
- force utf-8 headers to be sent ---> header("Content-type:
text/html; charset=UTF-8");
- indicate utf-8 in the meta tag --> <meta http-equiv=Content-Type
content="text/html; charset=utf-8" />
- simpley echo the string as is --> echo $greek_string;
- wrap output in htmlentities() --> echo htmlentities($greek_string,
ENT_NOQUOTES, 'UTF-8');
- wrap output in utf8_decode() --> echo utf8_decode($greek_string);
- If I copy and paste greek characters from the db table into a string
in my PHP script, and output that, it works just FINE, without any
htmlentities() or other functions.
I'm at a loss. What am I doing wrong?
Thanks in advance,
John W
Can't you set PHP's internal encoding to utf8...
; language for internal character representation.
mbstring.language = utf8
--
life is a game... so have fun.
--- End Message ---
--- Begin Message ---
I am in the process of converting my clients PHP scripts that are
using Interbase so they will work with SQL Server (their request;
not mine).
Is there a reference where I can get the COM Methods and Properties?
Also, without loading the large AdoDb, is there a Prepare()
method if I use the
$db = new COM("ADODB.Connection")
connection?
Any suggestions are greatly appreciated.
Todd
--- End Message ---
--- Begin Message ---
Hello,
on 08/05/2006 11:47 PM Robert Cummings said the following:
>>>> This is necessary to escape wildcards characters that should be taken
>>>> literally in patterns. It is needed to implement the auto-complete
>>>> feature using SQL conditions of type field LIKE 'typed-text%'. If
>>>> typed-text contains % or _, it must be escaped. Some databases like MS
>>>> SQL need to escape other characters too.
>>> If there was enough need for Metabase to support other layers then I'm
>>> sure the community would be submitting the code for you. But then again,
>>> you probably wouldn't accept outside code into your own codebase since
>>> that would violate your internal dislike for external code *lol*.
>>> Touché!
>> Your obcession to diss everything I say is preventing you to see the
>> things the way they are.
>
> You're deluding yourself as to your importance. I really don't have an
> obsession with you. Having had very little interaction with you in the
> past leaves me with a generally agnostic opinion. Furthermore I'm npt
> having any trouble whatsoever seeing the way things are. Perhaps you are
> the one having clarity trouble.
If you go and read your replies to my messages throughout this thread
you may notice a pattern of you trying to contradict almost everything I
said. When you ended the phrase above with the word "Touché", it seemed
that winning the argument was very important for you.
Robert, relax! I am not in this thread to compete with anyone. If
expresses disagreement with me, I think to myself that since I am not a
native english speaker, I may have not expressed myself clearly.
Therefore, I try to explain myself better.
If you still disagree after my explanations, that is ok, I will not be
upset because of that. I am not making myself important. My opinion is
mine, yours is yours, neither is necessarily better than the other.
There is no need for manifestations of excessive joy, as if winning an
argument is a big deal. That is my opinion, of course.
>> I do not have a problem using other people's code, my problem is relying
>> on packages that need to be evolved to address my needs but I do not
>> control of their development. I control Metabase development, therefore
>> there is no problem in accepting other peoples contributions of patches
>> or even complete drivers.
>>
>> As a matter of fact Metabase always had many, many contributions, unlike
>> you imagined, as you may see in the contributors roll with the
>> respective credit for the contributed work here:
>>
>> http://www.meta-language.net/metabase.html#3.1.4
>
> That's nice. So what are you complaining about?
I was not complaining, remember? I was just explaining that unlike you
stated, I do not have a problem with other people's code. I just would
rather not rely on packages that I don't control their development, as
it may cause inconvinient effects to the progress of my projects.
Somehow, I explained that in my post with advice for instance, of
excessive framework class interdependencies, PHP 5 dependent frameworks,
frameworks developed by people that did not try them much in real world
applications, etc..
>>> >From your earlier statement, he could supposedly choose a framework just
>>> from browsing the source code. At any rate, he probably wasted time
>>> reading your article that purported to recommend a framework when in
>>> fact it had nothing of substantial value to say about any particular
>>> framework.
>> If you ever paid attention to what I wrote, my recommendation to the
>> original poster to read the article was about giving recommendations on
>> how to pick frameworks that suit his needs, rather than recommending any
>> specific frameworks. I am pasting the relevant quote of my original
>> reply so you can get a grip for once.
>>
>>
>>> Anyway, you may want to read this more in depth reflection of the state
>>> of the PHP framework world and recommendations on how to pick what suits
>>> best for you:
>>>
>>> http://www.phpclasses.org/blog/post/52-Recommended-PHP-frameworks.html
>
> Oh I paid perfect attention. If you read what I originally wrote you'll
> see that I was commenting on the article itself that you suggested since
> I and many others find great fault with it. For your benefit I've pasted
> below my original comment:
I am afraid that you still do not get the point that I wrote an article
that I wanted to be green, it is written in the summary that it is
green, so people that do not like green do not bother reading it. Still
you are complaining that the article is not red as you think it should
be. What can I do for you? Nothing. Never mind.
--
Regards,
Manuel Lemos
Metastorage - Data object relational mapping layer generator
http://www.metastorage.net/
PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/
--- End Message ---
--- Begin Message ---
Hello,
on 08/06/2006 09:52 PM Martin Alterisio said the following:
>> >> Anyway, you may want to read this more in depth reflection of the
>> state
>> >> of the PHP framework world and recommendations on how to pick what
>> suits
>> >> best for you:
>> >>
>> >> http://www.phpclasses.org/blog/post/52-Recommended-PHP-frameworks.html
>> >
>> >
>> > Sorry to intrude with my usual obnoxious behaviour, but this is
>> starting
>> to
>> > affect my self-esteem (what's left of it). Am I the only one who has a
>> > really hard time reading the blog posts in phpclasses.org? Everytime a
>> > reference to this blog is posted I lose track of the discussion,
>> because
>> I
>> > can't really grasp what Lemos is talking about.
>> >
>> > I'd like to make some some constructive criticism, not just to Lemos
>> but
>> to
>> > the community in general, since I think many of us need to improve our
>> > writing skills:
>> >
>> > 1 - Don't make loooong boooring posts.
>>
>> This blog in reality is the site monthly announcement newsletter. Some
>> months there is more to tell than in others. I usually put a list of
>> contents when the post is about many subjects.
>
>
> Then maybe you should consider making it a _weekly_ announcement
> newsletter,
> 'cause some of those posts are really really too long to digest in only one
> shot.
Unfortunately I do not have so much time to post site announcements that
often.
Anyway, this one was not an announcement. I am commited to post
something at least once every month to put something interesting in the
site editors newsletter.
When there are new features to announce, I try to fill the space with an
opinion article. Some people like it, other people are not interested.
In any case, at the top of the article there is a summary of the topics
in the article so anybody can figure whether there is anything of
interest in the article, so they do not have to read it all the way.
>> 2 - Get to the point. Introduction are great when they are not two pages
>> > long.
>>
>> I don't know what you mean by introduction. Usually there is a summary
>> that goes in the RSS feed that is no longer than 3 or 4 paragraphs.
>
>
> I mean all the things you need to say before actually getting into what you
> want to talk about. Just take for example the post about "recommend php
> framework", look how much you have to read before actually get any info
> relating directly to php frameworks. Is true that there are many things to
> say before about frameworks hype, but couldn't it be explained in less
> words?
I suppose it is a matter of style. As I said, some people appreciate a
more articulated style, other people prefer a more objective style like
you. Actually I also prefer a more objective style when I am reading
other people's articles. That is why I split the article in sections so
you can jump to whatever has what matters to you.
>> 3 - Stick to the topic. Or use appropiate titles.
>>
>> > 4 - If the topic is inherently long, use distinguishable headers and
>> > subheaders. It's a pain in the ass to read a 5 pages long article that
>> > looks
>> > the same everywhere, with no easy way to know what is the subtopic of
>> what
>> > are you reading now.
>>
>> As I said, these posts often cover many topics. It may not seem by topic
>> sections use titles. The problem is that this newsletter posts used to
>> go by e-mail to the site subscribers in plain text, so there was no way
>> to format titles.
>
>
> I was unaware of that, I understand now. It's really a pain in the ass to
> format a text only email for proper reading.... even more if the same text
> has to be used in a website.
Currently I no longer send the whole article by e-mail. Only the summary
is sent now. These posts were being sent to near 150,000 people and that
made the site spend too much bandwidth.
I just did not had the time to integrate an HTML or BBCode based editor
where the articles are posted to make it look better. It is on my todo list.
>> 5 - Don't talk so much about your life! You can always make another blog
>> > for
>> > that... Unless your personal experience can bring an unique insight of
>> the
>> > point you're trying to make.
>>
>> I suppose you may be talking about other peoples blogs. Personal blogs
>> are supposed to be personal. This is the PHPClasses site blog. Usually
>> it covers matters about the site developments and matters of interest to
>> the site users. It does not talk about my life. It may talk about my
>> experience when it is relevant to the post topic.
>
>
> Generally speaking, yes, I'm talking about other peoples blogs. I'm sick
> tired of all the holy crusades out there, specially when it comes to
> Web2.0evangelists. You may have not noticed it but somewhere here or
> there you let
> your subconcious write for you, specially on the topic of Web2.0 (I used
> the
> term twice already, please stop me before I have to pay royalties to
> O'reilly). It may be just an adjective, but that's all it takes to make a
> mildly objetive point of view turn into a completely subjective point of
> view.
heheheh ;-)
I do not have a personal blog. I do not have the time even if I wanted.
On defense of people that write posts about their personal life, I think
they do that to satisfy they egos. It is not a bad thing. It is just
normal on human beings. Some need more attention than others. Some
achieve that by writing personal blog posts.
> Just check your article about "is php ready for ..." *that thing I said
> before*, and you'll see that how, without noticing it, personal feelings
> tend to appear and change the article completely. Probably that's what made
> you write so much about how you believe phpclasses.org is a *that term*
> enabled site, and why. Was all that really necesary for the purpose of the
> article? Or you were just uncounciously trying to prove something to all
> those lamers out there? Does it really matter if your site is "in" or
> "out"?
> We are not fashion designers...
I understand what you mean but in reality my point it is quite the
opposite. I meant to clarify that what is being called Web 2.0 is not
about technology or social networks, but rather about providing better
sites to people by giving the users means to participate in relevant way
that is appreciated by others. Technology and social networks can help
providing that, but those are just means to reach the ends.
When I mentioned what the PHPClasses site has been doing that fit the
Web 2.0 spirit, was not really to state that the site is in fashion. It
was rather to say a) this is not a new thing, b) here are some examples
of how you can provide a better site allowing your site users to take a
relevant participation role.
Now, I completely agree that it is irritating when people keep talking
about Web 2.0, as if they really know what they are talking about, and
claim that it is a panacea that everybody should follow.
--
Regards,
Manuel Lemos
Metastorage - Data object relational mapping layer generator
http://www.metastorage.net/
PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/
--- End Message ---
--- Begin Message ---
Richard, Madoka,
Thank you for your insights into searching for Japanese characters.
I've decided to stick with searching for words as determined by the
placement of spaces within the source text.
Thank you for your time and advice.
--
Dave M G
--- End Message ---
--- Begin Message ---
Richard, Adam, Barry, Dave, David,
Thank you all for your helpful advice regarding expressions.
I was able to combine all your advice, and made some additional
discoveries along the way.
The winning expression is:
"#^(.*)\s#iU"
First, I discovered that sometimes the source text had an unexpected
space character at the very beginning. So I realized that I needed to do
trim() to ensure proper functionality of the expression.
Next, it seems it's better to use \s than an actual space, " ". It might
be the case that both are okay, but I've had success with \s, so I
decided to stop experimenting.
I tried, as Adam suggested, to use substr() instead of a regular
expression. The syntax he provided may work as far as finding the right
text to extract. But I can't be sure because it seems to have problems
with the character encoding.
The word being extracted is in UTF-8 encoded Japanese. The regular
expression seems to input and output it fine. But I couldn't find a way
of using the substr() function without the text coming out as ASCII
gibberish.
So I'm calling this one solved for me, as I have working code. Although
if anyone believes that it could be more efficient or something, of
course I'm all ears.
Thank you for all your time and advice.
--
Dave M G
--- End Message ---
--- Begin Message ---
PHP List,
This regular expression stuff is way tricky.
Thanks to help from this list, I have an expression that will select the
first word of a string, up to the first white space:
"#^(.*)\s#iU"
But after some consideration, I realized that I wanted to keep both
parts of the original text. The first word, and then everything that
came after it, should be divided and stored in separate variables.
I looked through the php.net manual, and found preg_split().
At first I thought using my original expression would work, if I
included the PREG_SPLIT_DELIM_CAPTURE parameter. It would pull out the
first word, but also keep it.
Turns out that's not true. It removes the first word and the space, and
looks for something before and after and only finds something after.
Thus, in my current situation, it returns only one variable, which
contains everything after the first space.
I realized what I need to do in this case is not select everything up to
the first space, but to find the first space without selecting what
comes before it. So the expression I had wasn't suitable for preg_split().
So then, what is the right expression?
Looking back over previous discussion and resources about regular
expression syntax, I thought I had to say:
Start at the beginning: ^
Ignore anything that isn't a space: [^\s]
Select the space character: \s
Be case insensitive and not greedy: iU
Thus, my expression should be (using hash marks, #, as delimiters):
#^[^\s]|s#iU
More specifically, my preg_split() syntax is:
$parts = preg_split("#^[^\s]|s#iU", $word, PREG_SPLIT_DELIM_CAPTURE);
But it returns a two element array, where the first element is empty,
and the second element is the whole original string.
Where did I go wrong this time?
Thank you for all your time and help.
--
Dave M G
--- End Message ---
--- Begin Message ---
On Wed, 2006-08-09 at 15:30 +0900, Dave M G wrote:
> PHP List,
>
> This regular expression stuff is way tricky.
>
> Thanks to help from this list, I have an expression that will select the
> first word of a string, up to the first white space:
> "#^(.*)\s#iU"
>
> But after some consideration, I realized that I wanted to keep both
> parts of the original text. The first word, and then everything that
> came after it, should be divided and stored in separate variables.
>
> I looked through the php.net manual, and found preg_split().
>
> At first I thought using my original expression would work, if I
> included the PREG_SPLIT_DELIM_CAPTURE parameter. It would pull out the
> first word, but also keep it.
>
> Turns out that's not true. It removes the first word and the space, and
> looks for something before and after and only finds something after.
> Thus, in my current situation, it returns only one variable, which
> contains everything after the first space.
>
> I realized what I need to do in this case is not select everything up to
> the first space, but to find the first space without selecting what
> comes before it. So the expression I had wasn't suitable for preg_split().
>
> So then, what is the right expression?
>
> Looking back over previous discussion and resources about regular
> expression syntax, I thought I had to say:
> Start at the beginning: ^
> Ignore anything that isn't a space: [^\s]
> Select the space character: \s
> Be case insensitive and not greedy: iU
>
> Thus, my expression should be (using hash marks, #, as delimiters):
> #^[^\s]|s#iU
>
> More specifically, my preg_split() syntax is:
> $parts = preg_split("#^[^\s]|s#iU", $word, PREG_SPLIT_DELIM_CAPTURE);
>
> But it returns a two element array, where the first element is empty,
> and the second element is the whole original string.
>
> Where did I go wrong this time?
Use preg_match() and pay special attention to the manual as it refers to
the third parameter :) The expression you need follows:
"#^([^\\s]*)\\s(.*)$#U"
You don't need the insensitive modifier btw since you aren't actually
matching anything that is applicable.
Cheers,
Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'
--- End Message ---
--- Begin Message ---
On Wed, 2006-08-09 at 02:57 -0400, Robert Cummings wrote:
> On Wed, 2006-08-09 at 15:30 +0900, Dave M G wrote:
> > PHP List,
> >
> > This regular expression stuff is way tricky.
> >
> > Thanks to help from this list, I have an expression that will select the
> > first word of a string, up to the first white space:
> > "#^(.*)\s#iU"
> >
> > But after some consideration, I realized that I wanted to keep both
> > parts of the original text. The first word, and then everything that
> > came after it, should be divided and stored in separate variables.
> >
> > I looked through the php.net manual, and found preg_split().
> >
> > At first I thought using my original expression would work, if I
> > included the PREG_SPLIT_DELIM_CAPTURE parameter. It would pull out the
> > first word, but also keep it.
> >
> > Turns out that's not true. It removes the first word and the space, and
> > looks for something before and after and only finds something after.
> > Thus, in my current situation, it returns only one variable, which
> > contains everything after the first space.
> >
> > I realized what I need to do in this case is not select everything up to
> > the first space, but to find the first space without selecting what
> > comes before it. So the expression I had wasn't suitable for preg_split().
> >
> > So then, what is the right expression?
> >
> > Looking back over previous discussion and resources about regular
> > expression syntax, I thought I had to say:
> > Start at the beginning: ^
> > Ignore anything that isn't a space: [^\s]
> > Select the space character: \s
> > Be case insensitive and not greedy: iU
> >
> > Thus, my expression should be (using hash marks, #, as delimiters):
> > #^[^\s]|s#iU
> >
> > More specifically, my preg_split() syntax is:
> > $parts = preg_split("#^[^\s]|s#iU", $word, PREG_SPLIT_DELIM_CAPTURE);
> >
> > But it returns a two element array, where the first element is empty,
> > and the second element is the whole original string.
> >
> > Where did I go wrong this time?
>
> Use preg_match() and pay special attention to the manual as it refers to
> the third parameter :) The expression you need follows:
>
> "#^([^\\s]*)\\s(.*)$#U"
>
> You don't need the insensitive modifier btw since you aren't actually
> matching anything that is applicable.
Also you don't need the ungreedy modifier either since you can't
overshoot with the above expression.
Cheers,
Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'
--- End Message ---
--- Begin Message ---
Robert,
Thank you for your quick response and helpful advice.
Use preg_match() and pay special attention to the manual as it refers to
the third parameter :) The expression you need follows:
"#^([^\\s]*)\\s(.*)$#U"
This works perfectly.
I now see that the preg_match() function returns an array with the
original text, the selected text, and the discarded text. That wasn't
clear to me before when I wasn't looking for that kind of behavior. But
now that you point it out I see how it works.
But I am still confused about the expression you used. I can't quite
break it down:
The opening "^" says to start at the beginning of the line.
The brackets indicate a sub-expression.
The square brackets indicate a character class (?).
The "^" inside the square brackets means "not".
First question, why is there an extra backslash before the space marker
"\s"? Isn't that an escape character, so wouldn't that turn the
following space marker into a literal backslash followed by an "s"?
The "*" says to select everything matching the preceeding conditions.
There's that double backslash and "s" again.
Hmm... does the (.*) after the second "\s" mean to match all the
whitespace found? For example if there happened to be two space
characters instead of just one?
The PHP manual says the "$" means to "assert end of subject". Which I
think means "stop looking for any more matches".
So basically I'm confused about the extra escape slashes.
--
Dave M G
--- End Message ---
--- Begin Message ---
On Tue, 08 Aug 2006 17:01:13 +0200, Arno Kuhl wrote:
> Is there anything in your error log that says why it failed? (whatever
> error_log points to in php.ini, or maybe what ErrorLog points to in
> httpd.conf)
>
> Arno
Hi Arno, thanks for your reply.
However, the PHP-cli binary doesn't use the Apache error logs to dump
error information. I have tracked this problem down to the PHP-cli's
php.ini (see other post).
Thanks for thinking with me!
Ivo
--- End Message ---
--- Begin Message ---
On Tue, 08 Aug 2006 17:07:29 +0200, Ivo F.A.C. Fokkema wrote:
> On Tue, 08 Aug 2006 10:01:41 -0500, Ray Hauge wrote:
>
>> On Tuesday 08 August 2006 09:01, Ivo F.A.C. Fokkema wrote:
>>> On Tue, 08 Aug 2006 09:01:42 -0500, Ray Hauge wrote:
>>> > On Tuesday 08 August 2006 08:47, Ivo F.A.C. Fokkema wrote:
>>> >> > Does the user running the cron have permission to execute the php
>>> >> > binary?
>>> >>
>>> >> Yes, the file's owner is me and it's my crontab. Also, I've made the
>>> >> file readable to all, just in case. All directories up the directory
>>> >> tree are readable/executable, as well.
>>> >
>>> > I think he's asking if the php program is executable to you, the user.
>>> > It is possible that it would only have execute for owner and group, not
>>> > other.
>>>
>>> Sorry, yes, The PHP binary is executable by all. Actually, I'm very sure
>>> the error message "Could not startup." is generated by PHP-cli. When
>>> googling on that exact message, I found it in the PHP-cli source code
>>> (including the period at the end). However, I cannot determine from the
>>> PHP-cli source code what's up.
>>
>> It looks like when you run the script, then it works just fine, but it blows
>> up when you run it through cron.
>>
>> Two things I would check:
>>
>> 1) Cron can read your *.php files.
>>
>> 2) Cron can run php
>>
>> to test #2, have cron do a php -i and see what happens.
>
> 1) was OK, but 2) didn't return anything, not even an error... this has
> started me thinking, and when using -ni it works...! -n makes PHP-cli
> ignore the .ini file. When looking at my .ini file, the modification date
> is July 31st, the day it all stopped working. I need to leave now, but
> will investigate tomorrow to see what's up with my .ini files, on both
> machines, and check if my scripts run with -n or after tweaking of the
> .ini.
>
> Thanks!
OK guys... guess what? It was the php.ini file from PHP-cli. I had been
messing around with PHP-GTK and had edited PHP-cli's php.ini to load the
gtk.so library (on both machines). Apparently, this stops PHP-cli to
function completely from cron. Even the 'Hello world' script didn't run.
The suggestion to try php -i got me thinking. Since that
didn't return anything, I thought about trying php -h (worked) and php -ni
(ignore .ini file). Suddenly, it worked...
SO: Loading the GTK library in your /etc/php4/cli/php.ini, KILLS the
PHP-cli functionality from cron. On Ubuntu Dapper, that is. Not sure about
other distros.
Thanks guys, for all of your suggestions!
--- End Message ---
--- Begin Message ---
Ivo F.A.C. Fokkema wrote:
SO: Loading the GTK library in your /etc/php4/cli/php.ini, KILLS the
PHP-cli functionality from cron. On Ubuntu Dapper, that is. Not sure about
other distros.
Thanks guys, for all of your suggestions!
Ahh it probably *needs* an X Server to work properly. I'll bet if you
logged into your machine via SSH or the console without beign logged
into a graphical env. that it would also fail.
Well found tho', this would seem like a bug in the GTK stuff tho'.
Col.
--- End Message ---
--- Begin Message ---
Hi,
How do I add so that it checks for a comma , in this preg_match. I think the
documentation is not that good for the pref_match:
preg_match('/^[a-z0-9-_\'() +]*$/i', $s);
/Peter
--- End Message ---
--- Begin Message ---
On 09/08/06, Peter Lauri <[EMAIL PROTECTED]> wrote:
Hi,
How do I add so that it checks for a comma , in this preg_match. I think
the
documentation is not that good for the pref_match:
preg_match('/^[a-z0-9-_\'() +]*$/i', $s);
Check for a comma inside a range - use a comma!
--
http://www.web-buddha.co.uk
http://www.projectkarma.co.uk
--- End Message ---
--- Begin Message ---
Peter Lauri wrote:
> Hi,
>
>
>
> How do I add so that it checks for a comma , in this preg_match. I think the
> documentation is not that good for the pref_match:
it's a lot better than you spelling of preg_match. the subject of regexps is
very
complex, the documentation reflects that - but to call them 'not that good' is
rather a disservice to the people that wrote them imho.
I taught myself regexps primarily using the php docs -
which is a testament to how good they are. :-)
>
>
>
> preg_match('/^[a-z0-9-_\'() +]*$/i', $s);
$q = chr(39); // makes for easier cmdline testing !?E#$@
function test($s) {
global $q;
echo "\"$s\" is ",(preg_match("#^[a-z0-9\\-_\\$q\\(\\), \\+]*$#i",
$s)?"true":"false"),"\n";
// I escaped everything char that has special meaning in a regexp
// backslashes are themselves escaped in double quotes strings.
// I used different regexp delimiters (#) - just my preference
}
test("foo");
test(",");
test("()");
test("(123)");
test("(123,456)");
test("(+123,456)");
test(" (+123,456) ");
test(" $q(+123,456) $q");
>
>
>
> /Peter
>
>
>
>
>
>
--- End Message ---