Re: [PHP] Regex in PHP

2008-06-03 Thread Liran Oz

You can use this:
$str = '[EMAIL PROTECTED]';

preg_match('/[EMAIL PROTECTED]@(.+)/', $str, $matches);
var_dump($matches);//will be in $matches[1]


Or without regex:
echo substr($str, strpos($str, '@')+1);

Liran

- Original Message - 
From: VamVan [EMAIL PROTECTED]

To: php-general@lists.php.net
Sent: Wednesday, June 04, 2008 3:39 AM
Subject: [PHP] Regex in PHP



Hello All,

For example I have these email addressess -

[EMAIL PROTECTED]
[EMAIL PROTECTED]
[EMAIL PROTECTED]

What would be my PHP function[Regular expression[ to that can give me some
thing like

yahoo.com
hotmail.com
gmail.com

Thanks




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



Re: [PHP] function returns no value

2008-04-20 Thread Liran Oz

Can't really know without the rest of the code.
Check if the function really returns and not Dying (Add some messege like: 
die(help me I'm dying);  ).

Also use print_r or something like to see what's inside the fields array.
it is possible that it's an associative array and you are using the wrong 
index (0)


Liran
- Original Message - 
From: Ali Reza Sajedi [EMAIL PROTECTED]

To: php-general@lists.php.net
Sent: Sunday, April 20, 2008 11:51 PM
Subject: [PHP] function returns no value



Hello,

with the following call I try to print a string out of DB

echo $allg-translate($db, $lang, 14, auth/authCallback, 4);

function translate () should do a DB querry and returns the requested 
string. Although the querry yields a positive result, the function returns 
no value.


Here is the function:

function translate ($db, $lang, $MaiKey, $page, $pid) {

 $statement = SELECT fa FROM language WHERE MaiKey='$MaiKey' AND 
page='$page' AND pid='$pid';


 $result = $db-Execute($statement);

 if ($result=== false) die();

 return $result-fields[0];
}

Could anybody see what is going wrong here?

I appreciate any hint.

Ali

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




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



Re: [PHP] What means Fatal error: pcntl_fork(): Error 11?

2006-05-04 Thread Oz

Hi again,

After lots of testing I can say: It helped.
I do still not exactly know why forking failed, but it seems to be somehow 
related to the high number of processes. I also do not understand why this is a 
*fatal* error, since it could easily be handled by returning -1 (like in the 
PHP docs).

First I wanted to create a queue for tasks; instead of forking directly only a limited number of processes should be run from the queue, when one finishes another should start. But I decided not to do this, because the queue can easily grow to reach the 
memory limit.


At last I decided to simply pause the script just before forking, if a maximum 
number of processes has been reached, until one has finished. Not optimal, 
since the parent process has a higher priority task, but at least it's stable 
now.

To me it appears to be impossible to track if it was the maximum number of 
processes or a lack of any system resource.

However, thank you all for your help.
 - Oz

Robin Vickery wrote:

On 02/05/06, Oz [EMAIL PROTECTED] wrote:


Hi,

My script dies with the following line (after a few hours running 
without other errors/warnings/notices):

Fatal error: pcntl_fork(): Error 11 in /home/foo/bar.php on line 297

Is there any documentation for pcntl_fork(): Error 11?
Does anybody know what causes pcntl_fork(): Error 11?

(It's PHP5 and the scripts source is top secret.)



The 11 is from errno.h and it corresponds to EAGAIN.


From the docs for fork()

The fork() function shall fail if:

[EAGAIN]
The system lacked the necessary resources to create another 
process, or
 the system-imposed limit on the total number of processes under 
execution

 system-wide or by a single user {CHILD_MAX} would be exceeded.



Does that help?

-robin



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



Re: [PHP] What means Fatal error: pcntl_fork(): Error 11?

2006-05-03 Thread Oz

Richard Lynch wrote:


On Wed, May 3, 2006 12:51 am, Oz wrote:
 


Richard Lynch wrote:

   


On Tue, May 2, 2006 11:29 am, Oz wrote:

 


My script dies with the following line (after a few hours running
without other errors/warnings/notices):
Fatal error: pcntl_fork(): Error 11 in /home/foo/bar.php on line 297

Is there any documentation for pcntl_fork(): Error 11?
Does anybody know what causes pcntl_fork(): Error 11?

(It's PHP5 and the scripts source is top secret.)
   


I believe that if you installed my perror extension:
http://l-i-e.com/perror/
you would be able to easily print out the error message corresponding
to 11.

 


I can't it's cursed.

   


I suppose you could be old-school and just use a shell with:
perror 11
but that is not nearly as much fun.

 


That puts something out, but where is the realtion?
Doesn't help.
   



H.  It IS a rather terse message...

Allow me to translate, rather freely, into plain English.


bash:
System error:  11 = Resource deadlock avoided
 


Oh, on my system it's:
OS error code  11:  Resource temporarily unavailable


English:
Your script was about to fork, and I, the Operating System, realized
that if I allowed that, you would create a deadlock condition in
resource management.

What that means is that you would have the original process, and the
forked child process, BOTH needing access to a single resource.

Since it would be impossible to give them both access to that
resource, I simply had no choice but to fail to fulfill your request
to fork, because it would have created a Resource deadlock.

Therefore, I did not fork, and gave you a rather cryptic error message:
System error:  11 = Resource deadlock avoided

Sorry.
---

Hopefully you now understand what is wrong, on some level of
understanding.

What resource is required by both parent and child process, we don't
know, since we have no idea what your script is doing, much less what
resources it might be needing to do what it is doing.

 


I could have made a mistake with a file pointer.


You could try several things at this point:

#1.
Attempt to simplify your script to do nothing BUT fork.
Then start adding in bits and pieces of your script until you figure
out what resource is in deadlock.
Then figure out how to avoid the deadlock, by cloning/duplicating that
resource.

#1A. Rip bits and pieces OUT of your current script, until it forks okay.

#2.
Put your script up on http://pastebin.com (or similar) and ask experts
to look at it and help you.

#3.
I vaguely recall that you had many many many forks going at once
maybe?...  Or was that another guy?  If you have TOO many forks,
don't do that is the answer.  Your machine has finite resources. 
You tried to run too many processes.  Don't.


 



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



[PHP] What means Fatal error: pcntl_fork(): Error 11?

2006-05-02 Thread Oz

Hi,

My script dies with the following line (after a few hours running without other 
errors/warnings/notices):
Fatal error: pcntl_fork(): Error 11 in /home/foo/bar.php on line 297

Is there any documentation for pcntl_fork(): Error 11?
Does anybody know what causes pcntl_fork(): Error 11?

(It's PHP5 and the scripts source is top secret.)

Thanks for your time,
 - Oz

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



Re: [PHP] What means Fatal error: pcntl_fork(): Error 11?

2006-05-02 Thread Oz

Jay Blanchard wrote:


[snip]
My script dies with the following line (after a few hours running
without other errors/warnings/notices):
Fatal error: pcntl_fork(): Error 11 in /home/foo/bar.php on line 297

Is there any documentation for pcntl_fork(): Error 11?
Does anybody know what causes pcntl_fork(): Error 11?

(It's PHP5 and the scripts source is top secret.)
[/snip]

It means Cut and paste this into Google and you will see entries
concerning this error.
 


No, nice try.


I could tell you the answer, but then I'd have to kill you.

 



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



Re: [PHP] What means Fatal error: pcntl_fork(): Error 11?

2006-05-02 Thread Oz

Richard Lynch wrote:


On Tue, May 2, 2006 11:29 am, Oz wrote:
 


My script dies with the following line (after a few hours running
without other errors/warnings/notices):
Fatal error: pcntl_fork(): Error 11 in /home/foo/bar.php on line 297

Is there any documentation for pcntl_fork(): Error 11?
Does anybody know what causes pcntl_fork(): Error 11?

(It's PHP5 and the scripts source is top secret.)
   



I believe that if you installed my perror extension:
http://l-i-e.com/perror/
you would be able to easily print out the error message corresponding
to 11.

 


I can't it's cursed.


I suppose you could be old-school and just use a shell with:
perror 11
but that is not nearly as much fun.

 


That puts something out, but where is the realtion?
Doesn't help.


PS
My amp goes to 11.

 



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



[PHP] I am not able to download domxml for PHP5

2006-04-11 Thread Oz
Please help, I am not able to download domxml for PHP5
I have tried this location,
http://us3.php.net/manual/en/ref.domxml.php

I get a message file not found.

is there a mirror site.

Thanks

Please also mail response to
[EMAIL PROTECTED] 

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



Re: [PHP] I am not able to download domxml for PHP5

2006-04-11 Thread Oz
For some reason my PHP5 does not have DOM. ( I have the version that 
comes with fedora core 5). Is there a way to activate it.


-thanks
Oz

Joe Wollard wrote:

Of course you said you're running PHP5so that won't work.
According to the site it would be best for you to use the DOM that
comes pre compiled with PHP. http://us3.php.net/manual/en/ref.dom.php

Sorry about the mix up on my part.


On 4/11/06, Joe Wollard [EMAIL PROTECTED] wrote:

Oz,

From your command line, try:

pecl install domxml

You'll need to be root to do so, but as long as you have PECL/PEAR
installed this should give you domxml. Remember to restart your web
server after doing so.

- Joe


On 4/11/06, Oz [EMAIL PROTECTED] wrote:

Please help, I am not able to download domxml for PHP5
I have tried this location,
http://us3.php.net/manual/en/ref.domxml.php

I get a message file not found.

is there a mirror site.

Thanks

Please also mail response to
[EMAIL PROTECTED]

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