[PHP] usort inside a class

2008-05-09 Thread It Maq
Hi,

i'm trying to build a class that sorts a multidimensional array.
I'm using the php function usort.

I declared the comparision function as a method of my class but i'm unable to 
give it as argument to the function usort.

this usort($this-arr, $this-cmpi) gaves the following error: usort() 
[function.usort]: Invalid comparison function

i tried to do usort($this-arr, 'cmpi') but it does not work either.

Thanks


  

Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  
http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ


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



[PHP] adding the results of mysql_query

2008-05-06 Thread It Maq
Hi,

I need to add the result of 4 calls to mysql_query (4 different queries) to the 
same object so that i can mysql_fetch_object in the same loop.

Is that possible? otherwise is there any other alternative?

Thank you


  

Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  
http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ


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



[PHP] XHTML Validation problem

2008-05-02 Thread It Maq
Hi,

I have a page that displays data entered by the user. There is one user that 
entered the character  inside the text he typed. For this case the xhtml 
validation fails and gives me the following error:
character  is the first character of a delimiter but occurred as data.

I'm wondering if there is a way to avoid this error. The page itself is valid 
and fails just in the case the user enters the  character.

Thank you


  

Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  
http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ


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



[PHP] How to write simpleXML object to a file

2008-04-04 Thread It Maq
Hi,

I am reading an xml file. After that i modify one
node. IN the xml object that i'm handling it is
modified but not in the original file. Can you tell me
how i can make   the modification to an xml file or
how to write an xml object to a file?

Thank you


  

You rock. That's why Blockbuster's offering you one month of Blockbuster Total 
Access, No Cost.  
http://tc.deals.yahoo.com/tc/blockbuster/text5.com


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



[PHP] convert associative array to ordinary array

2008-03-28 Thread It Maq
Hi,

i have an associative array and i want to use it as an
ordinary array, is that possible?

what i mean is instead of $arr['fruit'] i want to call
it   by its position in the array $arr[3]

thanks


  

Never miss a thing.  Make Yahoo your home page. 
http://www.yahoo.com/r/hs


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



Re: [PHP] convert associative array to ordinary array

2008-03-28 Thread It Maq
thank you, it works!

--- Casey [EMAIL PROTECTED] wrote:

 On Fri, Mar 28, 2008 at 10:33 AM, Daniel Brown
 [EMAIL PROTECTED] wrote:
  On Fri, Mar 28, 2008 at 2:27 PM, It Maq
 [EMAIL PROTECTED] wrote:
Hi,
   
 i have an associative array and i want to use
 it as an
 ordinary array, is that possible?
   
 what i mean is instead of $arr['fruit'] i want
 to call
 it   by its position in the array $arr[3]
 
  Did you try?
 
   --
   /Daniel P. Brown
   Forensic Services, Senior Unix Engineer
   1+ (570-) 362-0283
 
 
 
 
 $numbered_array = array_values($associative_array);
 
 -- 
 -Casey
 



  

Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  
http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ


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



[PHP] algorithm of pages beaking

2008-03-19 Thread It Maq
Hi,

I am working in page breaking (dividing the result of
a select query in multiple pages).

Now my problem is not with the php code, but with the
algorithm that organize the links to the pages. I want
to do something like google, the pages numbers at the
bottom of the page must not exceed a maximum number,
the actual page must be in the center of the links to
other pages and there are a lot of other conditions
that arise.

Do you know about a site that describe these
conditions or may be propose the whole algorithm for
that?

Thank you


  

Looking for last minute shopping deals?  
Find them fast with Yahoo! Search.  
http://tools.search.yahoo.com/newsearch/category.php?category=shopping


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



Re: [PHP] Fastest way to get table records' number

2008-03-19 Thread It Maq
Hi,

did you try mysql_num_rows ?

--- Andrew Ballard [EMAIL PROTECTED] wrote:

 On Wed, Mar 19, 2008 at 1:04 PM, TG
 [EMAIL PROTECTED] wrote:
 
   It seems that count(*) pulls all the data from
 the row then performs a count
   increment whereas count(did) only pulls the 'did'
 column.
 
 Again, I don't believe COUNT(*) pulls any data. If
 there is a row, it
 simply counts it. The row could be full of NULLS (if
 allowed by your
 schema - yikes) and it will still be counted. I'd
 guess that COUNT(1)
 does the same thing. COUNT(did) does only examine
 the `did` column,
 but NULL values are excluded from the count.
 
   I wonder if count(did) is the same speed as
 count(1) or if it will depend on
   how much/what type of data is in 'did'.
 
 
   I also wonder why count() takes a parameter. 
 Isn't it always going to count
   +1 for the row?   I'll have to look that up
 sometime.
 
 It takes a parameter because it depends on what you
 want to count.
 COUNT(*) will return the number of rows matching the
 WHERE clause.
 COUNT(`column_name`) will return the number of
 non-NULL values in the
 column `column_name`. You could have a million rows
 in the table, but
 if every row has NULL in `column_name`, the COUNT()
 will return 0.
 There is also COUNT(DISTINCT `column_name`), which
 counts the number
 of distinct, non-NULL values in the column.
 
 Andrew
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 



  

Never miss a thing.  Make Yahoo your home page. 
http://www.yahoo.com/r/hs


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



Re: [PHP] How to get error context

2008-03-14 Thread It Maq
Hi,

I maid the modifications you suggested. For the error
context when i display it, it gives a lot of
information, but not easy to understand how the array
is structured. If somebody knows about a site
explaining how to access the context it would be
great.
I also modified the error reporting to E_ALL as you
suggested. Now an other question arise: For the
connection to the database if i put a wrong username
or password the error is reported automatically to the
function that i defined as the error handling
function, but for the next statement (see code below)
if i put a wrong database name the error is not
reported automatically, i have to trigger it using
triger_error. So i'm wondering if there are some rules
that can help me know if an error will be reported
automatically or not. here is my code after
modification:

?php
function error_handler($errno, $errstr, $filename,
$lineno, $errcontext)
{
echo handling reported errorbr;

switch($errno) {
case E_USER_ERROR: $type = 
E_USER_ERROR;break;
case E_USER_WARNING: $type =
E_USER_WARNING;break; 
case E_USER_NOTICE: $type = 
E_USER_NOTICE;break;
case E_ERROR: $type = E_ERROR;break;
case E_WARNING: $type = E_WARNING;break;
case E_PARSE: $type = E_PARSE;break;
case E_NOTICE: $type = E_NOTICE;break;
case E_CORE_ERROR: $type = E_CORE_ERROR;break;
case E_CORE_WARNING: $type =
E_CORE_WARNING;break; 
case E_COMPILE_ERROR: $type =
E_COMPILE_ERROR;break;
case E_STRICT: $type = E_STRICT;break;
case E_COMPILE_WARNING: $type =
E_COMPILE_WARNING;break;  
case E_RECOVERABLE_ERROR: $type =
E_RECOVERABLE_ERROR;break;
default: echo brThis is an error not listed;

}
$str = ;
$str .= brbrERROR TYPE: . $type;
$str .= brbrERROR Number: . $errno;
$str .= brERROR MESSAGE: . $errstr;
$str.= brFile: . $filename;
$str.= brLine number: . $lineno;
echo $str;
echo Context: br;
print_r($errcontext);
}





echo h1Testing set_error_handler/h1;

error_reporting(E_ALL);  
set_error_handler('error_handler'); 
mysql_connect(localhost, admin, admin); 
mysql_select_db(wrongdb) or trigger_error(wrong
database);

?
--- Jim Lucas [EMAIL PROTECTED] wrote:

 It Maq wrote:
  Hi,
  
  i need help because I'm unable to retrieve error's
 context. Below is the code that is working perfectly
 except the context that is not displayed:
  
  ?php
  function error_handler($errno, $errstr,
 $filename, $lineno, $errcontext)
  {
  
 
 try doing a print_r($errcontext) here and see what
 you get?
 
 maybe the zero index does not exist.
 

  $str = ;
  $str .= brbrERROR Number: . $errno;
  $str .= brERROR MESSAGE: . $errstr;
  $str.= brFile: . $filename;
  $str.= brLine number: . $lineno;
  $str.= brContext: . $errcontext[0];
  echo $str;
  
  
  }
  
  echo h1Testing set_error_handler/h1;
  
 
 I have always used
 error_reporting(E_ALL);
 instead of this.
  error_reporting(0);  
  set_error_handler('error_handler'); 
  ini_set('error_reporting', 0);
 
 I have never seen the above line before.  This and
 the error_reporting(0) would 
 probably suppress all error messages generated by
 PHP.  Double check these 
 settings and make sure the you can still trigger an
 error with trigger_error() 
 if you have error_reporting() turned off.
 
  
  //trigger_error(The string for testing the
 error, E_USER_WARNING);
  $ourFileName = testFile.txt;
  $fh = fopen($ourFileName, 'X');// or die(Can't
 open file);
  fclose($fh);
  
  
  ?



  

Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  
http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ 



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



Re: [PHP] How to get error context

2008-03-14 Thread It Maq
For example mysql_connect reprted automatically the
error but in the manual
http://us3.php.net/manual/en/function.mysql-connect.php
 all they give as information is the return: Returns
a MySQL link identifier on success, or FALSE on
failure., where can i see if it throws an error, and
when you say throwing do you mean that i can catch the
error without throwing it myself?
 
--- Zoltán Németh [EMAIL PROTECTED] wrote:

 2008. 03. 14, péntek keltezéssel 07.20-kor It Maq
 ezt írta:
  So i'm wondering if there are some rules
  that can help me know if an error will be reported
  automatically or not. 
 
 there is no general rule for that. you have to check
 the manual for each
 function, some of them just returns false on error,
 others throw
 warnings/notices/errors...
 
 greets,
 Zoltán Németh
 
 



  

Never miss a thing.  Make Yahoo your home page. 
http://www.yahoo.com/r/hs


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



Re: [PHP] How to get error context

2008-03-14 Thread It Maq
Here is the error message captured by my error
handling function:

mysql_connect() [function.mysql-connect]: Access
denied for user 'admin'@'localhost' (using password:
YES)

i put a wrong password and username
--- Zoltán Németh [EMAIL PROTECTED] wrote:

 2008. 03. 14, péntek keltezéssel 07.40-kor It Maq
 ezt írta:
  For example mysql_connect reprted automatically
 the
  error but in the manual
 

http://us3.php.net/manual/en/function.mysql-connect.php
   all they give as information is the return:
 Returns
  a MySQL link identifier on success, or FALSE on
  failure., where can i see if it throws an error,
 and
  when you say throwing do you mean that i can catch
 the
  error without throwing it myself?
 
 hmm actually what error did mysql_connect throw?
 because if it just fails connecting, it returns
 false. on the other
 hand, if you provide it wrong arguments (e.g. less
 arguments, or wrong
 data type, or whatever) that raises a php error and
 the function does
 not even run.
 this is true for most functions which return false
 on error. the
 returning false means there was some error with the
 action itself, while
 php errors are raised when the action can not be
 executed because of
 some error in the code itself.
 
 greets,
 Zoltán Németh
 
   
  --- Zoltán Németh [EMAIL PROTECTED] wrote:
  
   2008. 03. 14, péntek keltezéssel 07.20-kor It
 Maq
   ezt írta:
So i'm wondering if there are some rules
that can help me know if an error will be
 reported
automatically or not. 
   
   there is no general rule for that. you have to
 check
   the manual for each
   function, some of them just returns false on
 error,
   others throw
   warnings/notices/errors...
   
   greets,
   Zoltán Németh
   
   
  
  
  
   


  Never miss a thing.  Make Yahoo your home page. 
  http://www.yahoo.com/r/hs
  
  
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 



  

Looking for last minute shopping deals?  
Find them fast with Yahoo! Search.  
http://tools.search.yahoo.com/newsearch/category.php?category=shopping


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



[PHP] Intercepting errors

2008-03-13 Thread It Maq
Hi,

Now i know how to create errors with trigger_error, but i am wondering how can 
I make my error handling class intercept any kind of error although i'm not 
aware about it and i don't know if it will happen. Is this possible?

Thank you




  

Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  
http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ 



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



Re: [PHP] Intercepting errors

2008-03-13 Thread It Maq
I'am already using that. When i call trigger_error the function set in 
set_error_handler handles the error. but now i don't know if this will handle 
all the other errors that i don't know about in case they happen. Is there 
anyway to test that?

- Original Message 
From: Richard Heyes [EMAIL PROTECTED]
To: It Maq [EMAIL PROTECTED]
Cc: php-general@lists.php.net
Sent: Thursday, March 13, 2008 10:36:20 AM
Subject: Re: [PHP] Intercepting errors

 Now i know how to create errors with trigger_error, but i am
 wondering how can I make my error handling class intercept any kind
 of error although i'm not aware about it and i don't know if it will
 happen. Is this possible?

You could use set_error_handler():

http://uk.php.net/manual/en/function.set-error-handler.php

-- 
Richard Heyes
Employ me:
http://www.phpguru.org/cv

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






  

Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  
http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ 



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



Re: [PHP] Intercepting errors

2008-03-13 Thread It Maq
I already read th page of the manual, but i still don't understand a lot of 
things. Below you will find a simple code that i ade for understanding more 
about this. In the code i'm triggering an error of type E_USER_ERROR, so now 
i'm wondering why it is not considered as E_USER_ERROR in set_error_handler(). 
And if somebody can suggest an error (something real not just trigger_error) 
that can be intercepted by set_error_handler(), this will be very useful.here 
is the code:

?php
function error_handler($errno, $errstr, $filename, $lineno, $context)
{
echo $errno. br;
echo $errstr. br;
switch($errno) {
case E_USER_ERROR:
$str = ;
$str = ERROR MESSAGE: . $errstr;
$str .= brThe application will be stopped just after the 
following error message:br;
$str.= brFile: . $filename;
$str.= brLine number: . $lineno;
$GLOBALS['toto'] = $str;
//return $GLOBALS['error'];
break;
case E_USER_WARNING:
echo ERROR MESSAGE: . $errstr;
echo brThe application will continue but there is a 
warning:br;
echo brFile: . $filename;
echo brLine number: . $lineno; 
break;
case E_USER_NOTICE:
echo ERROR MESSAGE: . $errstr;
echo brThe application will continue but there is a 
notice:br;
echo brFile: . $filename;
echo brLine number: . $lineno; 
break;
}
}

echo Testing set_error_handlerbrbrbr;

error_reporting(E_USER_ERROR|E_USER_WARNING|E_USER_NOTICE);  
set_error_handler('error_handler'); 
ini_set('error_reporting', 0);

trigger_error(The string for testing the error, E_USER_ERROR);


?



- Original Message 
From: Richard Heyes [EMAIL PROTECTED]
To: It Maq [EMAIL PROTECTED]
Cc: php-general@lists.php.net
Sent: Thursday, March 13, 2008 11:00:30 AM
Subject: Re: [PHP] Intercepting errors

 I'am already using that. When i call trigger_error the function set
 in set_error_handler handles the error. but now i don't know if this
 will handle all the other errors that i don't know about in case they
 happen. Is there anyway to test that?

Read the manual page. I believe it handles all except things like parse 
errors:

The following error types cannot be handled with a user defined 
function: E_ERROR, E_PARSE, E_CORE_ERROR, E_CORE_WARNING, 
E_COMPILE_ERROR, E_COMPILE_WARNING, and most of E_STRICT raised in the 
file where set_error_handler() is called.

Oh and Stephane: this is a mailing list. If you want off you can go to 
http://www.php.net.

-- 
Richard Heyes
Employ me:
http://www.phpguru.org/cv





  

Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  
http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ 



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



Re: [PHP] Intercepting errors (skip)

2008-03-13 Thread It Maq
sorry i just forgot to print the results. It 's my mistake

- Original Message 
From: It Maq [EMAIL PROTECTED]
To: php-general@lists.php.net
Sent: Thursday, March 13, 2008 11:22:36 AM
Subject: Re: [PHP] Intercepting errors

I already read th page of the manual, but i still don't understand a lot of 
things. Below you will find a simple code that i ade for understanding more 
about this. In the code i'm triggering an error of type E_USER_ERROR, so now 
i'm wondering why it is not considered as E_USER_ERROR in set_error_handler(). 
And if somebody can suggest an error (something real not just trigger_error) 
that can be intercepted by set_error_handler(), this will be very useful.here 
is the code:

?php
function error_handler($errno, $errstr, $filename, $lineno, $context)
{
echo $errno. br;
echo $errstr. br;
switch($errno) {
case E_USER_ERROR:
$str = ;
$str = ERROR MESSAGE: . $errstr;
$str .= brThe application will be stopped just after the 
following error message:br;
$str.= brFile: . $filename;
$str.= brLine number: . $lineno;
$GLOBALS['toto'] = $str;
//return $GLOBALS['error'];
break;
case E_USER_WARNING:
echo ERROR MESSAGE: . $errstr;
echo brThe application will continue but there is a 
warning:br;
echo brFile: . $filename;
echo brLine number: . $lineno; 
break;
case E_USER_NOTICE:
echo ERROR MESSAGE: . $errstr;
echo brThe application will continue but there is a 
notice:br;
echo brFile: . $filename;
echo brLine number: . $lineno; 
break;
}
}

echo Testing set_error_handlerbrbrbr;

error_reporting(E_USER_ERROR|E_USER_WARNING|E_USER_NOTICE);  
set_error_handler('error_handler'); 
ini_set('error_reporting', 0);

trigger_error(The string for testing the error, E_USER_ERROR);


?



- Original Message 
From: Richard Heyes [EMAIL PROTECTED]
To: It Maq [EMAIL PROTECTED]
Cc: php-general@lists.php.net
Sent: Thursday, March 13, 2008 11:00:30 AM
Subject: Re: [PHP] Intercepting errors

 I'am already using that. When i call trigger_error the function set
 in set_error_handler handles the error. but now i don't know if this
 will handle all the other errors that i don't know about in case they
 happen. Is there anyway to test that?

Read the manual page. I believe it handles all except things like parse 
errors:

The following error types cannot be handled with a user defined 
function: E_ERROR, E_PARSE, E_CORE_ERROR, E_CORE_WARNING, 
E_COMPILE_ERROR, E_COMPILE_WARNING, and most of E_STRICT raised in the 
file where set_error_handler() is called.

Oh and Stephane: this is a mailing list. If you want off you can go to 
http://www.php.net.

-- 
Richard Heyes
Employ me:
http://www.phpguru.org/cv





  

Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  
http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ 



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






  

Never miss a thing.  Make Yahoo your home page. 
http://www.yahoo.com/r/hs


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



[PHP] How to get error context

2008-03-13 Thread It Maq
Hi,

i need help because I'm unable to retrieve error's context. Below is the code 
that is working perfectly except the context that is not displayed:

?php
function error_handler($errno, $errstr, $filename, $lineno, $errcontext)
{

  
$str = ;
$str .= brbrERROR Number: . $errno;
$str .= brERROR MESSAGE: . $errstr;
$str.= brFile: . $filename;
$str.= brLine number: . $lineno;
$str.= brContext: . $errcontext[0];
echo $str;


}

echo h1Testing set_error_handler/h1;

error_reporting(0);  
set_error_handler('error_handler'); 
ini_set('error_reporting', 0);

//trigger_error(The string for testing the error, E_USER_WARNING);
$ourFileName = testFile.txt;
$fh = fopen($ourFileName, 'X');// or die(Can't open file);
fclose($fh);


?




  

Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  
http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ 



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



[PHP] best practices in error handling in PHP

2008-03-12 Thread It Maq
Hi,

I want to know what is the best solution for handling errors. After reading 
some documents dealing with the subject, i have three options:
* Using a class for error handling
* Using PEAR error object
* Using try and catch exceptions

The error handling i want to implement will be done in a big application that 
was developed from the beginning without any concern about error handling.

Thank you




  

Looking for last minute shopping deals?  
Find them fast with Yahoo! Search.  
http://tools.search.yahoo.com/newsearch/category.php?category=shopping

Re: [PHP] best practices in error handling in PHP

2008-03-12 Thread It Maq

Yes you are right i can use trigger_error that will use the function that 
handles errors from my class.

Thanks

- Original Message 
From: Christoph Boget [EMAIL PROTECTED]
To: It Maq [EMAIL PROTECTED]
Cc: php-general@lists.php.net
Sent: Wednesday, March 12, 2008 10:31:07 AM
Subject: Re: [PHP] best practices in error handling in PHP

  I want to know what is the best solution for handling errors. After reading 
 some
 documents dealing with the subject, i have three options:
  * Using a class for error handling
  * Using PEAR error object
  * Using try and catch exceptions
  The error handling i want to implement will be done in a big application 
 that was
 developed from the beginning without any concern about error handling.

It seems to me that 1 and 3 aren't necessarily mutually exclusive.  I
believe that you can use your own error classes in php's try/catch
functionality.  As for PEAR's error object, unless you are using PEAR
elsewhere in your app I'm not sure it would be worthwhile to just use
this very small piece.

This is all just IMO.

thnx,
Chris






  

Looking for last minute shopping deals?  
Find them fast with Yahoo! Search.  
http://tools.search.yahoo.com/newsearch/category.php?category=shopping

Re: [PHP] best practices in error handling in PHP

2008-03-12 Thread It Maq

I mean using calling trigger_error from the catch{}
 
Yes  you  are  right  i  can  use  trigger_error  that  will  use  the  
function  that  handles  errors  from  my  class.

Thanks

-  Original  Message  
From:  Christoph  Boget  [EMAIL PROTECTED]
To:  It  Maq  [EMAIL PROTECTED]
Cc:  php-general@lists.php.net
Sent:  Wednesday,  March  12,  2008  10:31:07  AM
Subject:  Re:  [PHP]  best  practices  in  error  handling  in  PHP

   I  want  to  know  what  is  the  best  solution  for  handling  errors.  
 After  reading  some
  documents  dealing  with  the  subject,  i  have  three  options:
   *  Using  a  class  for  error  handling
   *  Using  PEAR  error  object
   *  Using  try  and  catch  exceptions
   The  error  handling  i  want  to  implement  will  be  done  in  a  big  
 application  that  was
  developed  from  the  beginning  without  any  concern  about  error  
 handling.

It  seems  to  me  that  1  and  3  aren't  necessarily  mutually  exclusive.   
I
believe  that  you  can  use  your  own  error  classes  in  php's  try/catch
functionality.   As  for  PEAR's  error  object,  unless  you  are  using  PEAR
elsewhere  in  your  app  I'm  not  sure  it  would  be  worthwhile  to  just  
use
this  very  small  piece.

This  is  all  just  IMO.

thnx,
Chris






 

Looking  for  last  minute  shopping  deals?  
Find  them  fast  with  Yahoo!  Search.   
http://tools.search.yahoo.com/newsearch/category.php?category=shopping






  

Never miss a thing.  Make Yahoo your home page. 
http://www.yahoo.com/r/hs


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



[PHP] Error handling

2008-03-11 Thread It Maq
Hi,

I need help with a simple script that i made for handling errors. The problem 
is that the script displays the same message several times while i want it 
displayed just one time.
He is the code:

?php
function error_handler($errno, $errstr, $filename, $lineno, $context)
{
if ($errno == E_STRICT) {
echo you are in the function error_handlerbr;
echo $errno. br;
}
}
set_error_handler(error_handler, E_STRICT);
ini_set('error_reporting', 0);

$conn = mysql_connect(localhost, root, iolfsyd) or trigger_error(connection au 
serveur failed,WARNING);

?

Thanks




  

Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  
http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ 


Re: [PHP] Error handling (skip this message my mistake)

2008-03-11 Thread It Maq
Sorry,

i found the error. it was my mistake

- Original Message 
From: It Maq [EMAIL PROTECTED]
To: php-general@lists.php.net
Sent: Tuesday, March 11, 2008 11:38:10 AM
Subject: [PHP] Error handling

Hi,

I need help with a simple script that i made for handling errors. The problem 
is that the script displays the same message several times while i want it 
displayed just one time.
He is the code:

?php
function error_handler($errno, $errstr, $filename, $lineno, $context)
{
if ($errno == E_STRICT) {
echo you are in the function error_handlerbr;
echo $errno. br;
}
}
set_error_handler(error_handler, E_STRICT);
ini_set('error_reporting', 0);

$conn = mysql_connect(localhost, root, iolfsyd) or trigger_error(connection au 
serveur failed,WARNING);

?

Thanks




  

Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  
http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ 






  

Looking for last minute shopping deals?  
Find them fast with Yahoo! Search.  
http://tools.search.yahoo.com/newsearch/category.php?category=shopping

Re: [PHP] regular expressions question

2008-03-05 Thread It Maq
Hi,

I am using that right now and i have don't know how to include blank fields. 
For example if a user does not fill a field in a form i want to accept it. I 
tried the code you posted, for now it is blocking blank fields.

Thank you

- Original Message 
From: Richard Lynch [EMAIL PROTECTED]
To: Adil Drissi [EMAIL PROTECTED]
Cc: php-general@lists.php.net
Sent: Tuesday, March 4, 2008 3:09:09 PM
Subject: Re: [PHP] regular expressions question

On Tue, March 4, 2008 1:19 pm, Adil Drissi wrote:
 Is there any way to limit the user to a set of characters for example
 say i want my user to enter any character between a and z (case
 insensitive). And if the user enters just one letter not belonging to
 [a-z], this will not be accepted.

 I tried  eregi('[a-z]', $fname) but this allows the user to enter
 abdg4512kdkdk for example.

What you tried only requires ONE a-z character somewhere in the input.

Try this:

preg_match('^[a-z]+$', $fname);

This will:
^ anchor the string at the beginning
[a-z]+ a to z, with at least one letter
$ anchor the string at the end

Note, however, that some people have other characters in their first
name, such as apostrophe, space, and dash.

Oh, and the digit 3, for bo3b who was a programmer on the first
Apple Macintosh.  His parents were hippies, and that really is his
name...

You may want to obtain a LARGE list of first names and run them
through your validator as a test.

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?


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







  

Never miss a thing.  Make Yahoo your home page. 
http://www.yahoo.com/r/hs