f



php regular expression doesn't match

Hi
   PHP's regular expression look like doesn't support .*? syntax. So i
cannot match the shortest match. For exmaple:

$str="a1b a3b";
$str1=ereg_replace("a.*b", "peter", $str1);
will produce "peter", but i want "peter peter", so how to?

thanks
from Peter (cmk128@hotmail.com)

0
cmk128417 (501)
10/24/2007 6:50:48 AM
comp.lang.php 32646 articles. 0 followers. Post Follow

13 Replies
743 Views

Similar Articles

[PageSpeed] 46

cmk128@hotmail.com wrote:
> Hi

Hi,

>    PHP's regular expression look like doesn't support .*? syntax. So i
> cannot match the shortest match. For exmaple:
> 
> $str="a1b a3b";

Typo. That was $str1="a1b a3b" I expect.

> $str1=ereg_replace("a.*b", "peter", $str1);
> will produce "peter", but i want "peter peter", so how to?
> 

Yes, * is greedy.
I do not know your real-world example, but maybe using a wordboundary
can solve your problem?
eg:
$str1=ereg_replace("/a.*b\b/", "peter", $str1);

> thanks
> from Peter (cmk128@hotmail.com)
> 

Regards,
Erwin Moller
0
10/24/2007 8:21:44 AM
Erwin Moller wrote:
> cmk128@hotmail.com wrote:
>> Hi
> 
> Hi,
> 
>>    PHP's regular expression look like doesn't support .*? syntax. So i
>> cannot match the shortest match. For exmaple:
>>
>> $str="a1b a3b";
> 
> Typo. That was $str1="a1b a3b" I expect.
> 
>> $str1=ereg_replace("a.*b", "peter", $str1);
>> will produce "peter", but i want "peter peter", so how to?
>>
> 
> Yes, * is greedy.
> I do not know your real-world example, but maybe using a wordboundary
> can solve your problem?
> eg:
> $str1=ereg_replace("/a.*b\b/", "peter", $str1);

That is nonsense. (Erwin had a coffee now.)
It doesn't solve the greedinessproblem.
Excuse me for the noise.

A better solution would be to explode the string first on space, and use
a regexpr to modify if matched.

Regards,
Erwin Moller

> 
>> thanks
>> from Peter (cmk128@hotmail.com)
>>
> 
> Regards,
> Erwin Moller
0
10/24/2007 9:05:54 AM
cmk128@hotmail.com wrote:
> Hi
>    PHP's regular expression look like doesn't support .*? syntax. So i
> cannot match the shortest match. For exmaple:
> 
> $str="a1b a3b";
> $str1=ereg_replace("a.*b", "peter", $str1);
> will produce "peter", but i want "peter peter", so how to?
> 
> thanks
> from Peter (cmk128@hotmail.com)
> 

Hi Peter,

The coffe sunk in, and I gave it a new try:

What about this?

$str="a1b a3b";
$str=preg_replace("/a[^b]*b/", "peter", $str);

It matches a, then any non-b character as many times as possible, and
then the b itself.
Effectively demanding nongreediness (I think).

Seems to work here.

Regards,
Erwin Moller
0
10/24/2007 9:33:17 AM
On Wed, 24 Oct 2007 08:50:48 +0200, <cmk128@hotmail.com> wrote:

> Hi
>    PHP's regular expression look like doesn't support .*? syntax. So i=

> cannot match the shortest match. For exmaple:
>
> $str=3D"a1b a3b";
> $str1=3Dereg_replace("a.*b", "peter", $str1);
> will produce "peter", but i want "peter peter", so how to?

use the preg_* functions

<?php
$str=3D"a1b a3b";
echo preg_replace("/a.*?b/", "peter", $str);
?>
-- =

Rik Wasmus
0
10/24/2007 10:11:34 AM
On 24 Oct, 11:11, "Rik Wasmus" <luiheidsgoe...@hotmail.com> wrote:
> On Wed, 24 Oct 2007 08:50:48 +0200, <cmk...@hotmail.com> wrote:
> > Hi
> >    PHP's regular expression look like doesn't support .*? syntax. So i
> > cannot match the shortest match. For exmaple:
>
> > $str="a1b a3b";
> > $str1=ereg_replace("a.*b", "peter", $str1);
> > will produce "peter", but i want "peter peter", so how to?
>
> use the preg_* functions
>
> <?php
> $str="a1b a3b";
> echo preg_replace("/a.*?b/", "peter", $str);
> ?>
> --
> Rik Wasmus

Mine was similar:
$strl = preg_replace('/(a.*b)*/','Peter',$strl);

0
paul_lautman (2109)
10/24/2007 10:18:53 AM
On Tue, 23 Oct 2007 23:50:48 -0700, cmk128@hotmail.com wrote:

>   PHP's regular expression look like doesn't support .*? syntax. So i
>cannot match the shortest match. For exmaple:
>
>$str="a1b a3b";
>$str1=ereg_replace("a.*b", "peter", $str1);
>will produce "peter", but i want "peter peter", so how to?

 PHP supports two regular expression libraries, neither of which are "PHP
regular expressions" - there's POSIX expressions, and Perl-compatible
expressions (PCRE).

 The manual says that the ereg functions (the POSIX ones) are to be avoided in
favour of the PCRE ones which are better so many ways.

 .*? is a PCRE construct (match zero-or-more any character, greediness inverted
[see also U modifier]), so use the right function - preg_replace.

 http://uk3.php.net/manual/en/ref.regex.php
 http://uk3.php.net/manual/en/ref.pcre.php
-- 
Andy Hassall :: andy@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
0
andy171 (2271)
10/24/2007 11:56:06 AM
"Erwin Moller" 
<Since_humans_read_this_I_am_spammed_too_much@spamyourself.com> wrote in 
message news:471f0bf1$0$226$e4fe514c@news.xs4all.nl...
> Erwin Moller wrote:
>> cmk128@hotmail.com wrote:
>>> Hi
>>
>> Hi,
>>
>>>    PHP's regular expression look like doesn't support .*? syntax. So i
>>> cannot match the shortest match. For exmaple:
>>>
>>> $str="a1b a3b";
>>
>> Typo. That was $str1="a1b a3b" I expect.
>>
>>> $str1=ereg_replace("a.*b", "peter", $str1);
>>> will produce "peter", but i want "peter peter", so how to?
>>>
>>
>> Yes, * is greedy.
>> I do not know your real-world example, but maybe using a wordboundary
>> can solve your problem?
>> eg:
>> $str1=ereg_replace("/a.*b\b/", "peter", $str1);
>
> That is nonsense. (Erwin had a coffee now.)
> It doesn't solve the greedinessproblem.
> Excuse me for the noise.
>
> A better solution would be to explode the string first on space, and use
> a regexpr to modify if matched.

uhhh...bullshit. first, there is no need. second, you assume you know what 
he wants based on the test string. be logical! his string may very well be 
'a1ba2ba3b'. if he becomes more specific with us about what he wants, THEN 
you'll be able to make such leaps...and be a bit more accurate. your 'better 
solution' is tripe. as others have pointed out:

preg_replace('/a.*?b/', 'peter', 'a1ba2ba3b');

with heavy emphasis on PREG...THAT is the only solution warranting 
attention.

you seem to think coffee helps you out. i recommend you go make two or three 
more pots. 


0
no.one508 (1048)
10/24/2007 1:18:59 PM
Steve wrote:
> "Erwin Moller" 
> <Since_humans_read_this_I_am_spammed_too_much@spamyourself.com> wrote in 
> message news:471f0bf1$0$226$e4fe514c@news.xs4all.nl...
>> Erwin Moller wrote:
>>> cmk128@hotmail.com wrote:
>>>> Hi
>>> Hi,
>>>
>>>>    PHP's regular expression look like doesn't support .*? syntax. So i
>>>> cannot match the shortest match. For exmaple:
>>>>
>>>> $str="a1b a3b";
>>> Typo. That was $str1="a1b a3b" I expect.
>>>
>>>> $str1=ereg_replace("a.*b", "peter", $str1);
>>>> will produce "peter", but i want "peter peter", so how to?
>>>>
>>> Yes, * is greedy.
>>> I do not know your real-world example, but maybe using a wordboundary
>>> can solve your problem?
>>> eg:
>>> $str1=ereg_replace("/a.*b\b/", "peter", $str1);
>> That is nonsense. (Erwin had a coffee now.)
>> It doesn't solve the greedinessproblem.
>> Excuse me for the noise.
>>
>> A better solution would be to explode the string first on space, and use
>> a regexpr to modify if matched.
> 
> uhhh...bullshit.
  first, there is no need. second, you assume you know what
> he wants based on the test string. be logical! his string may very well be 
> 'a1ba2ba3b'. if he becomes more specific with us about what he wants, THEN 
> you'll be able to make such leaps...and be a bit more accurate. your 'better 
> solution' is tripe. as others have pointed out:
> 
> preg_replace('/a.*?b/', 'peter', 'a1ba2ba3b');
> 
> with heavy emphasis on PREG...THAT is the only solution warranting 
> attention.
> 
> you seem to think coffee helps you out. i recommend you go make two or three 
> more pots. 
> 


Bullshit? More pots of coffee?

If you want to appear smart, you better first read the other response I 
wrote in this same thread many hours ago.
It contained a better solution. One that actually works and solves the 
OP problem.

I fixed my own nonsense with a good solution that works in the other 
response.
Will you do the same and fix the insulting crap you wrote about me in here?

Erwin Moller
0
10/24/2007 2:07:36 PM
"Erwin Moller" 
<Since_humans_read_this_I_am_spammed_too_much@spamyourself.com> wrote in 
message news:471f52a9$0$241$e4fe514c@news.xs4all.nl...
> Steve wrote:
>> "Erwin Moller" 
>> <Since_humans_read_this_I_am_spammed_too_much@spamyourself.com> wrote in 
>> message news:471f0bf1$0$226$e4fe514c@news.xs4all.nl...
>>> Erwin Moller wrote:
>>>> cmk128@hotmail.com wrote:
>>>>> Hi
>>>> Hi,
>>>>
>>>>>    PHP's regular expression look like doesn't support .*? syntax. So i
>>>>> cannot match the shortest match. For exmaple:
>>>>>
>>>>> $str="a1b a3b";
>>>> Typo. That was $str1="a1b a3b" I expect.
>>>>
>>>>> $str1=ereg_replace("a.*b", "peter", $str1);
>>>>> will produce "peter", but i want "peter peter", so how to?
>>>>>
>>>> Yes, * is greedy.
>>>> I do not know your real-world example, but maybe using a wordboundary
>>>> can solve your problem?
>>>> eg:
>>>> $str1=ereg_replace("/a.*b\b/", "peter", $str1);
>>> That is nonsense. (Erwin had a coffee now.)
>>> It doesn't solve the greedinessproblem.
>>> Excuse me for the noise.
>>>
>>> A better solution would be to explode the string first on space, and use
>>> a regexpr to modify if matched.
>>
>> uhhh...bullshit.
>  first, there is no need. second, you assume you know what
>> he wants based on the test string. be logical! his string may very well 
>> be 'a1ba2ba3b'. if he becomes more specific with us about what he wants, 
>> THEN you'll be able to make such leaps...and be a bit more accurate. your 
>> 'better solution' is tripe. as others have pointed out:
>>
>> preg_replace('/a.*?b/', 'peter', 'a1ba2ba3b');
>>
>> with heavy emphasis on PREG...THAT is the only solution warranting 
>> attention.
>>
>> you seem to think coffee helps you out. i recommend you go make two or 
>> three more pots.
>
>
> Bullshit? More pots of coffee?
>
> If you want to appear smart, you better first read the other response I 
> wrote in this same thread many hours ago.
> It contained a better solution. One that actually works and solves the OP 
> problem.

oh, you mean this:

/a[^b]*b/

still missing a ? after the * ... unless you want mixed results.

/a[^b]*?b/

is appropriate. it may have worked with the test string, but not hardly a 
catch-all in the real world. since the op was confused about *?, your 
snippet pattern doesn't server to clear any of that up.


> I fixed my own nonsense with a good solution that works in the other 
> response.
> Will you do the same and fix the insulting crap you wrote about me in 
> here?

no...but i did justify my comment further. ;^) 


0
no.one508 (1048)
10/24/2007 5:31:03 PM
Steve wrote:

<snip>

>>
>> Bullshit? More pots of coffee?
>>
>> If you want to appear smart, you better first read the other response I 
>> wrote in this same thread many hours ago.
>> It contained a better solution. One that actually works and solves the OP 
>> problem.
> 
> oh, you mean this:
> 
> /a[^b]*b/

Yes.

> 
> still missing a ? after the * ... unless you want mixed results.

I have no clue what you are talking about.
What 'mixed results'?

I don't pretend to be a regex expert, so could you give me an example 
please where the results differ?

So where gives
/a[^b]*b/
gives a different result than
/a[^b]*?/



> 
> /a[^b]*?b/
> 
> is appropriate. it may have worked with the test string, but not hardly a 
> catch-all in the real world. since the op was confused about *?, your 
> snippet pattern doesn't server to clear any of that up.
> 
> 
>> I fixed my own nonsense with a good solution that works in the other 
>> response.
>> Will you do the same and fix the insulting crap you wrote about me in 
>> here?
> 
> no...but i did justify my comment further. ;^) 
> 

And you are definitely in a better mood than yesterday.
I saw you piss on more people yesterday in here....

Regards,
Erwin

0
10/25/2007 8:55:02 AM
Erwin Moller wrote:
> Steve wrote:

> So where gives
> /a[^b]*b/
> gives a different result than
> /a[^b]*?/
> 

should be:
Can you give an example where
/a[^b]*b/
differs from:
/a[^b]*?b/
of course.

Sloppy typing. Still the same coffee problem. ;-)

Erwin
0
10/25/2007 9:07:19 AM
"Erwin Moller" 
<Since_humans_read_this_I_am_spammed_too_much@spamyourself.com> wrote in 
message news:47205dcb$0$234$e4fe514c@news.xs4all.nl...
> Erwin Moller wrote:
>> Steve wrote:
>
>> So where gives
>> /a[^b]*b/
>> gives a different result than
>> /a[^b]*?/
>>
>
> should be:
> Can you give an example where
> /a[^b]*b/
> differs from:
> /a[^b]*?b/
> of course.
>
> Sloppy typing. Still the same coffee problem. ;-)

ahhh...the damned coffee. :)

it is interpreted differently in different engines. in preg, however, what 
you think you're saying is NOT what you're saying.

'aabb' may be a string. your pattern should return three matches. 1) aab, 2) 
ab and 3) aabb. this is because of greed inherent in your statement - which 
is what the op wanted to know about anyway. using this:

/a[^b]*?b/

keeps the greed at bay. essentially, find an 'a' and any character until you 
hit ONE 'b'. so, the above would have two matches...'aab' and 'ab'. it's all 
about setting the marker in the preg engine. from that spot, the next set of 
matching will begin. you're throwing yours down the street, when all you 
needed to do was slide the mug down the bar counter.

no big deal? try it with preg_replace. ;^)

as for my mood? it's pretty consistent. okham's razor would have it that 
more likely, two days ago, there were several people saying stupid things. 
being consistent, i correct stupid things being said. but, you own your 
perspective. see things how you will. 


0
no.one508 (1048)
10/25/2007 2:18:15 PM
Steve wrote:
> "Erwin Moller" 
> <Since_humans_read_this_I_am_spammed_too_much@spamyourself.com> wrote in 
> message news:47205dcb$0$234$e4fe514c@news.xs4all.nl...
>> Erwin Moller wrote:
>>> Steve wrote:
>>> So where gives
>>> /a[^b]*b/
>>> gives a different result than
>>> /a[^b]*?/
>>>
>> should be:
>> Can you give an example where
>> /a[^b]*b/
>> differs from:
>> /a[^b]*?b/
>> of course.
>>
>> Sloppy typing. Still the same coffee problem. ;-)
> 
> ahhh...the damned coffee. :)
> 
> it is interpreted differently in different engines. in preg, however, what 
> you think you're saying is NOT what you're saying.
> 
> 'aabb' may be a string. your pattern should return three matches. 1) aab, 2) 
> ab and 3) aabb. this is because of greed inherent in your statement - which 
> is what the op wanted to know about anyway. using this:
> 
> /a[^b]*?b/
> 
> keeps the greed at bay. essentially, find an 'a' and any character until you 
> hit ONE 'b'. so, the above would have two matches...'aab' and 'ab'. it's all 
> about setting the marker in the preg engine. from that spot, the next set of 
> matching will begin. you're throwing yours down the street, when all you 
> needed to do was slide the mug down the bar counter.
> 
> no big deal? try it with preg_replace. ;^)

Hi Steve,

Sorry, I hope you can keep this regex class running a little while 
longer, because I still don't get it.
I DID try it in preg_replace, and got excactly the result I expected.

Lets look at your example: aabb
You talk about 3 matches, being:
1) aab
2) ab
3) aabb

I do not get that.
Look at the the following example: It uses my own homebrew version of 
nongreedy *, being [^b]*b

$str="aabb";
$str=preg_replace("/a[^b]*b/", "peter", $str);
echo htmlentities($str);

That produces:
peterb

as exepted (by me at least), because * behaves nongreedy.


As far as I can tell, the feeded string starts matching as follows 
(based on what I learned in 'Mastering Regular Expression' book):

- a matches right away
- next another a: matches with the non-b class [^b] (one time)
- Third character is a b
This DOESN'T match the non-b class, so the engine runs on the see if it 
fits the next character, being a plain b in this example.
It matches (of course). So now we have a match (aab) and that gets 
replaced by 'peter'.
- Then comes a 'b', that doesn't match the /a[^b]*b/
- end of string, and replacements.

So the result we have now is: peterb.

So I don't see your point about the 3 matches (aab,ab,aabb).

I can imagine my approach is somehow hugely ineficient maybe in other 
cases/strings (I am not sure), but it does work OK.
Is that the case maybe? Efficiency?

As far as I can tell the /[^b]*b/ approach creates a nongreedy version 
of /b*/

I must still miss something.
Could you give me an example where the results differ?
Or tell me WHAT I am missing?

As you can tell, I didn't finish my 'Mastering Regular Expression' book 
yet. ;-)


> 
> as for my mood? it's pretty consistent. okham's razor would have it that 
> more likely, two days ago, there were several people saying stupid things. 
> being consistent, i correct stupid things being said. but, you own your 
> perspective. see things how you will. 

That fine. I don't behave nicely on usenet either all the time. ;-)


Regards,
Erwin
0
10/26/2007 9:31:35 AM
Reply:

Similar Artilces:

Regular Expression Question Why Doesn't this Match?
/([\w\s\.\'\-]*) does not match this: My Fictional Co. But it does match Product by abc company I don't understand why it matches the second one, but not the first. Doesn't my expresionsay match anything that has a word, space, dot, apostrophe, or a hyphen, one or more times? Thefirst one has a . in it and it should work. It does work on others like: Dr. Smith's Thank you for any help. jm wrote: > /([\w\s\.\'\-]*) > > does not match this: > > My Fictional Co. > > But it does match > > Product by abc company > > I don't understand why it matches the second one, but not the first. > Doesn't my expresionsay match anything that has a word, space, dot, > apostrophe, or a hyphen, one or more times? Thefirst one has a . in it > and it should work. It does work on others like: The RE above isn't closed, and I doubt that it is your complete expression. Give a short, working examples that illustrates what exactly you are trying to accomplish, and what goes wrong. Then people will be able to aid in solving your problem. Otherwise, to me the pattern seems to match just fine: C:\> perl use strict; use warnings; $_='My Fictional Co.'; print 'Matches: '.$1.$/ if( /([\w\s\.\'\-]*)/ ); ^Z Matches: My Fictional Co. C:\> -Chris jm schreef: > /([\w\s\.\'\-]*) thaT iS brokeN. > does not match this: > > My Fictional Co. witH thE m...

Regular expression to match any line that DOESN'T begin with a particular string
I would like to match lines that do NOT being with "http". Here is my regex: /^[^(http)]/ I am using a character class with negation and then counting on the grouping to force negation of the entire "http" string. Then of course, the first ^ anchors to the beginning of the string. Is this correct? Thanks, Wes weyus@att.net wrote in news:1143074916.738167.82330 @t31g2000cwb.googlegroups.com: > I would like to match lines that do NOT being with "http". Here is my > regex: > > /^[^(http)]/ > > I am using a character class with negation a...

Fatal error: main(): Failed opening required 'DB.php' (include_path='.:/usr/lib/php:/usr/local/lib/php')
I installed PEAR HTTP_Upload to my new server and now im getting this error when runnign the script. any help? Maximus wrote: > I installed PEAR HTTP_Upload to my new server > and now im getting this error when runnign the script. > > > any help? > permissions problem? where is DB.php located? does DB.php reside in the include_path directories? The message is self explanatory. -- Michael Austin. DBA Consultant Donations welcomed. Http://www.firstdbasource.com/donations.html :) Try on your command line as root: >pear install DB Alex http://prepared-stateme...

why does $_SERVER['PHP_SELF'] say /test.php/test.php for test.php?
I have a PHP script at 127.0.0.1/test.php. It's contents are as follows: <?php echo $_SERVER['PHP_SELF']; ?> And it's output isn't test.php, as I'd expect, or /test.php, but rather, /test.php/test.php. Why? And how do I fix it? El 06/10/2010 6:53, yawnmoth escribi�/wrote: > I have a PHP script at 127.0.0.1/test.php. It's contents are as > follows: > > <?php > echo $_SERVER['PHP_SELF']; > ?> > > And it's output isn't test.php, as I'd expect, or /test.php, but > rather, /test.php/test.php. Why? And how do I fix it? What output do you get if you change it to this? <?php echo '[' . $_SERVER['PHP_SELF'] . ']'; ?> What do your other $_SERVER values look like? <?php print_r($_SERVER); ?> -- -- http://alvaro.es - �lvaro G. Vicario - Burgos, Spain -- Mi sitio sobre programaci�n web: http://borrame.com -- Mi web de humor satinado: http://www.demogracia.com -- On 06/10/10 09:30, "�lvaro G. Vicario" wrote: > El 06/10/2010 6:53, yawnmoth escribi�/wrote: >> I have a PHP script at 127.0.0.1/test.php. It's contents are as >> follows: >> >> <?php >> echo $_SERVER['PHP_SELF']; >> ?> >> >> And it's output isn't test.php, as I'd expect, or /test.php, but >> rather, /test.php/test.php. Why? And how do I fix it? > > What output do you get if you change it ...

Using a simple regular expressions to check a filename has '.php' on the end of it
Hi, Im trying to write a regular expression in PHP to check if a submitted filename has .php on the end of it. For example, filename.html woulod return false whereas filename.php would return true. My code is: if (ereg ("$.php", $filename)) return true; else return false; Obviously my expression is wrong, could someone please tell me what Im doing wrong. Thanks Burnsy On Tue, 08 Jan 2008 14:07:31 +0100, bizt <bissatch@yahoo.co.uk> wrote: > Hi, > > Im trying to write a regular expression in PHP to check if a submitted > filename has .php on the end of it. For example, filename.html woulod > return false whereas filename.php would return true. > > My code is: > > if (ereg ("$.php", $filename)) > return true; > else > return false; > > Obviously my expression is wrong, could someone please tell me what Im > doing wrong. Thanks 1. Use PCRE not POSIX, the ereg* function will even disappear in PHP6 it seems. 2. preg_match('/\.php$/',$filename) -- Rik Wasmus bizt wrote: > Hi, > > Im trying to write a regular expression in PHP to check if a submitted > filename has .php on the end of it. For example, filename.html woulod > return false whereas filename.php would return true. > > My code is: > > if (ereg ("$.php", $filename)) > return true; > else > return false; > > Obviously my expression is wrong, could someone please tell me...

Failed opening required 'PEAR.php' (include_path='F:\www\include') in F:\Program Files\PHP\PEAR\Text\CAPTCHA.php on line 22
Hi, Guys=EF=BC=8Cwhen I run my site ,I got some errors: Warning: require_once(PEAR.php) [function.require-once]: failed to open stream: No such file or directory in F:\Program Files\PHP\PEAR \Text\CAPTCHA.php on line 22 Fatal error: require_once() [function.require]: Failed opening required 'PEAR.php' (include_path=3D'F:\www\include') in F:\Program Files \PHP\PEAR\Text\CAPTCHA.php on line 22 It appears that it cann't find the pear.php ,but i checked my dir,and this file was there,and also I have my php.ini file checked,the include_path=3Dinclude_path=3D".;F:\Program Files\PHP\pear;F:\www \include" ,it looks all right,was there anything I have missed in the config file?Or something wrong ? Wish somebody can help me out. Thanks, Mikay >Warning: require_once(PEAR.php) [function.require-once]: failed to >open stream: No such file or directory in F:\Program Files\PHP\PEAR >\Text\CAPTCHA.php on line 22 >Fatal error: require_once() [function.require]: Failed opening >required 'PEAR.php' (include_path='F:\www\include') in F:\Program Files >\PHP\PEAR\Text\CAPTCHA.php on line 22 So where is the pear.php file? >It appears that it cann't find the pear.php ,but i checked my dir,and >this file was there,and also I have my php.ini file checked,the >include_path=include_path=".;F:\Program Files\PHP\pear;F:\www >\include" ,it looks all right,was there anything I have missed in the >config...

php doesn't load
Hi group, I'm running 5.2.3_1 on FreeBSD 6.2. When I browse to a .php page, my browser asks me if I want to save the .php file... It's obviously not been interpreted at the server before sending to me. Any ideas? httpd.conf is laoding php5. Thanks! Oliver There are various ways to set the command, depending on your server configuration. One of the following will probably work. Add ONE the following lines at the end of your .htaccess file. If unsure which to use, check with your hosting provider on which version works best for your configuration. Code: AddType x-mapp-php5 .php AddHandler application/x-httpd-php5 .php AddHandler cgi-php5 .php ...

javascript from php doesn't work
Hi All, I tried a javascript function in a php form but the code doesn't seem to work. I have the following javascript function: <SCRIPT language="JavaScript"> <!-- function bcolor(bcol,d_name) { if (document.all) { var thestyle= eval ('document.all.'+d_name+'.style'); thestyle.backgroundColor=bcol; } } //--> </SCRIPT> It should change the backgroundcolor of a cell in a table. Now running this from within php: First I draw the cell: echo "<td ID=\'$the_day\' valign=\"top\" class=\"kaltexr\" onclick= \"window.location.href='jour.php?jour=$the_day&mois=$this_month&annee= $this_year'\" onMouseOver=\"this.style.backgroundColor='#E9ECEF';\" onMouseOut=\"this.style.backgroundColor='#CDD2D9'\" bgcolor=#CDD2D9><b> $the_day</b><br>"; Then if it matches my query I want to chane the backgroundcolor of the cell: if (mysql_num_rows($result) >= 1) { echo "<font style=\"color: black; font-size:90%; font-family: Verdana, Arial, Helvetica, sans-serif;\"><center><b>"; while ($row = mysql_fetch_array($result)) { echo "<SCRIPT LANGUAGE='javascript'>bcolor('green','$the_day');</ SCRIPT>"; echo "".$row['titel'].""; } echo "</b></center></...

embedded php doesn't work
Although a standalone .php page works just fine, if I embed php into an html page it doesn't work. Here's a part of what I'm trying: <body> <p>Hello World</p> <?php echo "<p>now is the time</p>"; ?> <p>Bye</p> </body> I've also tried: <script language='php'>echo "<p>now is the time</p>"; </script> Thanks. J wrote: > Although a standalone .php page works just fine, if I embed php into an > html page it doesn't work. Here's a part of what I'm trying: ...

PHP Sessions doesn't work on my localhost
On my computer, whenever a new page is opened, a new session id will be created instead of accessing the same session id. When I upload everything on my webhost, it seems to work normal. So there's no problem with my code. But I want it to work on my local machine too, because it's better for me to program my website. I've PHP running on my IIS server ( so, it's not Apache ). Is that the problem? I've heard about a problem with sessions under IIS. Or do I have incorrect settings in my php.ini. Can someone help my. I don't know what to do anymore. If it's the IIS ...

php cli doesn't work on a Mac
I don't think php from the command line is working but I get the info.php list. PHP is in /usr/lib/php . It is the Mac Lepard system install there are only two directories "build" & "extensions".. I tried these commands: janis-roughs-power-mac-g5:build jlrough$ #!/usr/lib/php --ini janis-roughs-power-mac-g5:build jlrough$ /usr/lib/php --ini -bash: /usr/lib/php: is a directory janis-roughs-power-mac-g5:build jlrough$ janis-roughs-power-mac-g5:build jlrough$ /usr/lib/php -c /etc/php.ini -bash: /usr/lib/php: is a directory janis-roughs-power-mac-g5:build jlrough$ #!/usr/lib/php -c /etc/ php.ini janis-roughs-power-mac-g5:build jlrough$ How can I get it to work at the CLI? thanks, In article <0cfff43f-7385-410c-9f9d-5cd7a3220940@o9g2000prg.googlegroups.com>, JRough <jlrough@yahoo.com> wrote: > I don't think php from the command line is working but I get the > info.php list. PHP is in /usr/lib/php . It is the Mac Lepard system > install there are only two directories "build" & "extensions".. > > I tried these commands: > > janis-roughs-power-mac-g5:build jlrough$ #!/usr/lib/php --ini > janis-roughs-power-mac-g5:build jlrough$ /usr/lib/php --ini > -bash: /usr/lib/php: is a directory > janis-roughs-power-mac-g5:build jlrough$ > janis-roughs-power-mac-g5:build jlrough$ /usr/lib/php -c /etc/php.ini > -bash: /usr/lib/php: is a directory > janis-roughs-power-mac-g5:buil...

Apache doesn't process PHP pages
Hello, installed Apache & PHP 4 under Linux via RPM packages Html pages work, not php's (every php script is displayed on the browser as text file) I check'd all the modules directives in httpd.conf, as explained on php.net, but things don't work In my error_log file, there is no trace of php having been installed Anybody has a hint or a link to something ??? I think I am doing a stupid error, but really can't find out which It's some where in your apache config file. httpd.conf some one else might be able to help you more, I can't remember. fab wrote: ...

PHP doesn't find MySQL extensions
Hello! I'm a newbie. I have installed PHP 5.2.5, MySQL 5.0.45 and PHPMyAdmin 2.11.3 When trying to start MyAdmin it says: ERROR - cannot load MySQL extension. Please check your PHP configauration I've checked that the extensions are enabled in the PHP.ini file and that the path to them are correct. Any suggestions? On 13 Pro, 08:20, Kungen <klashjorts...@telia.com> wrote: Hello, I know this is not solution for your problem, but try to use whole package like http://www.wampserver.com/en/. It would install apache, php 5, phpmyadmin and setup it. Cya reflex Kungen wrote: > Hello! > I'm a newbie. > I have installed PHP 5.2.5, MySQL 5.0.45 and PHPMyAdmin 2.11.3 > When trying to start MyAdmin it says: > ERROR - cannot load MySQL extension. Please check your PHP > configauration > > I've checked that the extensions are enabled in the PHP.ini file and > that the path to them are correct. > > Any suggestions? > What does phpinfo() show you? -- ================== Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. jstucklex@attglobal.net ================== Kungen wrote: > Hello! > I'm a newbie. > I have installed PHP 5.2.5, MySQL 5.0.45 and PHPMyAdmin 2.11.3 > When trying to start MyAdmin it says: > ERROR - cannot load MySQL extension. Please check your PHP > configauration > > I've checked that the extensions are enabled in the PHP.ini file an...

php doesn't ignore aborted fileuploads
Hello! Running my uploadscript on old server, php4.1.2 ignore aborted fileuploads. Now, the same script on new server doesn't ignore broken uploads. If anybody make a upload and abort this the uploaded part of file is present on server. I'm now running php 4.3.3 on redhat 9. Files will be moved with move_uploaded_file($userfile['tmp_name'], "$destination/$userfile_name") I want to ignore broken uploads. What must i change in php.ini or which compile-option must set. regards Thomas There is a PHP ini setting for this: ini_set('ignore_user_abort','...

Match doesn't match
arg1 = "(1)a" arg2 = "(1)a" if arg1.match(arg2) puts "Matched" else puts "Don't Matched" end gives me "Don't Matched" ?? Regards, Volkan -- Posted via http://www.ruby-forum.com/. arg2 should be escaped as () has a meaning in regexps. arg2 = "\\(1\\)a" p "match" if arg1.match(arg2) hth, /alex -- w( the_mindstorm )p. On 7/19/06, Volkan Civelek <vcivelek@yahoo.com> wrote: > > > arg1 = "(1)a" > arg2 = "(1)a" > > if arg1.match(arg2) > puts "Mat...

I couldn't understand why PHP is so popular. The PHP code looks so horrible compared with Java.
Could you put up with the horrible PHP code? Since you have already admitted in comp.lang.java.programmer (Is there any web programmer who is willing to help me...) "I'm poor at programming." What the hell would you know. On Tue, 29 Apr 2008 08:00:47 +0200, tenxian <hi.steven.tu@gmail.com> wro= te: > Could you put up with the horrible PHP code? No offcourse not, that's why we read this group. For comparison, here's some Perl: #!/usr/bin/perl -l s--@{[(gE^Ge)=3D~/[^g^e]/g]}[g^e]x((!!+~~g^e^g^e)<<pop).!gE-ge, s-[^ge^ge]-s,,,,s,@{[(g^';').(e^'?')]},(G^'/').(E^'|')^Ge,ge, print,s,(?<=3D/[^g^e])[^g^e][^g^e],$&^(G^'/').(E^'|')^gE,ge-ge -- = Rik Wasmus tenxian wrote: > Could you put up with the horrible PHP code? Yes, I can. PHP is a language that's easy to learn and easy to use, which is why so many choose to use it. IMO, it's not much more horrible than C++ or Java; it all depends on the programmer who makes use of it. -- Kim Andr� Aker� - kimandre@NOSPAMbetadome.com (remove NOSPAM to contact me directly) "tenxian" <hi.steven.tu@gmail.com> wrote in message news:9dc74d6a-7a68-4e57-9c47-313ebb02609e@n1g2000prb.googlegroups.com... > Could you put up with the horrible PHP code? It takes several months before one becomes productive in Java. All those abstract classes and interfaces are quite confusing. PHP is much simpler but very powerful. Btw ...

MS SQL + Sharepoint + PHP....Doesn't Work...
Okay, I've got MS SQL Installed for our Sharepoint Portal. And our web site is needing the use of PHP. I've got it all installed and everything. Now the only way that it'll work is if I have IIS 6 running in IIS 5 Isolation Mode. Well when I do this the only problem I get is this: Can't connect to configuration database. I've applied all the updates and the only thing I can determine is from MS Knowledgebase Article # 823287. And that is you can't have Sharepoint running with IIS 6 in IIS 5 isolation mode. Anyone know how to make PHP work with this off? Thanks, Seus ...

Match Regular Expression won't work with Null
Is that right? I don't see it in the documentation. I can use it on \01 , just not \00. &nbsp; Is there a way around this problem? I know that Match Pattern works, but I want to use it with separate partial matches (a|b) which Match Pattern does not support. ...

newbie: sending email from PHP doesn't work
Hello, I try to send an email with attachment. I installed (apt-get) postfix mail server in my Ubuntu. I use PHPMailer package or mail() function. I am not sure that the code is correct, I must say. function sendEmail($to, $recipients, $subject, $bodyText, $bodyHTML, $fullNo, $withAttachments, $logEntry) { global $db, $websiteRoot; try { $mail = new PHPMailer(); $mail->IsSMTP(); $mail->Host = 'localhost'; $mail->SMTPAuth = false; $mail->From = 'robert@pecet'; $mail->AddReplyTo('robert@pecet'); if (!empty($to)) { $mail->AddAddress($to); } if (!empty($recipients)) { foreach (explode(',', $recipients) as $bcc) { $mail->AddBCC($bcc); } } $mail->IsHTML(!empty($bodyHTML)); $mail->Subject = $subject; if (!empty($fullNo)) { getYearMonthNo($fullNo, $year, $month, $no); } $mail->MsgHTML($bodyHTML); $mail->AltBody = $bodyText; if ($withAttachments && !empty($fullNo)) { $result = $db->query('SELECT file_name, picture FROM pictures ' . "WHERE a_year = $year AND a_month = $month AND a_no = $no"); @mkdir($websiteRoot . '/tmp/' . $fullNo); while ($row = $result->fetch_row()) { createPicture($websiteRoot . '/tmp', $fullNo, $row[0], $row [1]); $mail->AddAttachment("$webs...

Using posix_kill and PHP doesn't understand SIGUSR1!!??
Hi, I've only been using PHP for a short time so there may be a simple solution which I haven't been able to spot yet. here's the line in question: posix_kill($PidSendTo, SIGUSR1); produces the following error: posix_kill() expects parameter 2 to be long, string given in Test.php on line XX. It seems that PHP is unable to understand any of the PCNTL signals constants. Any ideas? Thanks. Rob Horton schreef: > Hi, I've only been using PHP for a short time so there may be a simple > solution which I haven't been able to spot yet. > > here's the line in question: > > posix_kill($PidSendTo, SIGUSR1); > > produces the following error: > > posix_kill() expects parameter 2 to be long, string given in > Test.php on line XX. > > It seems that PHP is unable to understand any of the PCNTL signals > constants. > > Any ideas? > > Thanks. Hi, Not sure, but could pcntl_signal() help you out? http://nl3.php.net/pcntl_signal Regards, Erwin Moller ...

PHP Instalation problems. Browser doesn't know what to do
Loaded Apache and PHP on a Windows XP box. Apache is working fine. However when I load a .php page I get a "Forbidden Warning You don't have permission to access /php/php.exe/Chapter03/handle_form.php on this server." Any idea what I need to configure? paulsparrow@telus.net wrote: > Loaded Apache and PHP on a Windows XP box. Apache is working fine. > However when I load a .php page I get a "Forbidden Warning You don't > have permission to access /php/php.exe/Chapter03/handle_form.php on > this server." > > Any idea what I need to configure? Hi, A wild guess based on the VERY limitted information you posted is: the user that runs IIS (named IUSR_<machinename>) doesn't have permissions to read/execute your php.exe, or maybe also not handle_form.php. Also, start with a simple script like this: <?php phpinfo(); ?> instead of handle_form.php. Regards, Erwin Moller On Jan 17, 4:22=A0am, "paulspar...@telus.net" <paulspar...@telus.net> wrote: > Loaded Apache and PHP on a Windows XP box. =A0Apache is working fine. > However when I load a .php page I get a "Forbidden Warning You don't > have permission to access /php/php.exe/Chapter03/handle_form.php on > this server." > > Any idea what I need to configure? Paul, the '/php/php.exe' in the error seems to be the useful part. My guess is that you've misconfigured Apache somehow, unless you passed that in ...

form.php?action=sign doesn't work
If I type echo("$action"); I get nothing written and if I try some code into a conditional instruction like this if($action == "sign"){ echo("ciao"); } it doesn't work, but if I write if($action == ""){ echo("ciao"); } then it works fine meaning that it doesn't fill the $action variable with the string declared in the address. Any hint would be appreciated as I'm a complete newbie of php. Thank you, bye ..oO(InuY4sha) >If I type > echo("$action"); You should get a notice. Set error_reporting to E_ALL in your php.ini. Additionally read about register_globals and why it's turned off in recent PHP versions. The value you're looking for can be found in $_GET['action']. Micha ...

PHP was working, now after loading PHPEclipse, it doesn't
After installing PHPEclipse, I can no longer open php files in the browser - I simply get a white page - no errors. The funny thing is that php files CAN be opened in the embedded browser that is contained within the Eclipse IDE. I'd really appreciate any help you all can offer on this; I'm out of ideas. Thanks, Michael McDonnell >>I can no longer open php files in the browser so you have installed php + server ? do you look for errors in your server config file? Ksu, Thanks for you reply. 1. Regarding the first question, everything was working before I installed PHPEclip...

simple php script doesn't run on IIS
I installes PHP binaries windows intaller for XP file name: php-4.3.4-Win32.zip I installed it and I have a home page running on the IIS. So why the file "a.htm" containing: ----------------------------------------------- <html> <head> <title>test php4</title> </head> <body> <?php print ("abcd"); ?> </body> </html> ---------------------------------------------- doesn't print "abcd" on the internet explorer ??? Pleas help On Sun, 18 Jan 2004 16:22:01 +0200, "Asher Golan" <datamor@actcom.n...

Web resources about - php regular expression doesn't match - comp.lang.php

Resources last updated: 3/23/2016 7:21:22 PM