Re: [PHP] include "config.php" does not work anymore after PHP 5.2

2007-12-02 Thread Casey
Okay... show us config.php.

On Dec 1, 2007 11:22 PM, wmac <[EMAIL PROTECTED]> wrote:
>
> Hello,
>
> I have been working with PHP 5.0 and my "register_globals" has always been
> Off since PHP 4.1
>
> Today I upgraded to PHP 5.2 and now neither of my include "config.php" work.
>
> Neither of the variables defined in include files are even included. Anyone
> knows what has been changed and what can I do?
>
> This is what I normally use
>
> PHP Code:
>
> include("config.php");
>
> mysql_connect($host,$user,$password);
> @mysql_select_db("$db") or die("Unable to open database");
>
> I echoed those connection variables and all are empty.
>
> Thank you,
> Mac
> --
> View this message in context: 
> http://www.nabble.com/include-%22config.php%22-does-not-work-anymore-after-PHP-5.2-tf4930800.html#a14113233
> Sent from the PHP - General mailing list archive at Nabble.com.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>



-- 
-Casey

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



[PHP] Re: include "config.php" does not work anymore after PHP 5.2

2007-12-02 Thread Siamak Sarmady

Hello

This is the same thing I always use.



By the way, I installed php 4.4.7 and everything is fine with this 
version though "register_globals" is again Off.


Regards,
Mac

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



Re: [PHP] include "config.php" does not work anymore after PHP 5.2

2007-12-02 Thread wmac

Thank you People. Someone mentioned the problem.

It is the starting PHP tag.

I never never thought my config.php might have problem. I have used
this config.php for almost 6 years and never had problem (the first
time I have forgotten to add it 6 years ago because I had migrated
from ASP. I have copied this wrong config.php to some other projects.

Throughout the years I have upgraded PHP and Apache (on windows and
Linux) and I have never had this problem.

It's strange that how PHP has never had problem with it and finally
now it has found the problem! I am now doing J2EE for 3 years and this
bug caught me finally. (I think I need to update a few delivered
projects before they come up with the problem)

Thank you again.

Mac
-- 
View this message in context: 
http://www.nabble.com/include-%22config.php%22-does-not-work-anymore-after-PHP-5.2-tf4930800.html#a14113764
Sent from the PHP - General mailing list archive at Nabble.com.

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



RE: [PHP] include "config.php" does not work anymore after PHP 5.2

2007-12-02 Thread Andrés Robinet
> -Original Message-
> From: wmac [mailto:[EMAIL PROTECTED]
> Sent: Sunday, December 02, 2007 6:35 AM
> To: php-general@lists.php.net
> Subject: Re: [PHP] include "config.php" does not work anymore after PHP
> 5.2
> 
> 
> Thank you People. Someone mentioned the problem.
> 
> It is the starting PHP tag.
> 
> I never never thought my config.php might have problem. I have used
> this config.php for almost 6 years and never had problem (the first
> time I have forgotten to add it 6 years ago because I had migrated
> from ASP. I have copied this wrong config.php to some other projects.
> 
> Throughout the years I have upgraded PHP and Apache (on windows and
> Linux) and I have never had this problem.
> 
> It's strange that how PHP has never had problem with it and finally
> now it has found the problem! I am now doing J2EE for 3 years and this
> bug caught me finally. (I think I need to update a few delivered
> projects before they come up with the problem)
> 
> Thank you again.
> 
> Mac
> --
> View this message in context: http://www.nabble.com/include-
> %22config.php%22-does-not-work-anymore-after-PHP-5.2-
> tf4930800.html#a14113764
> Sent from the PHP - General mailing list archive at Nabble.com.
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

Hi Mac,

You don't need to sacrifice your coding practices if your apache
installation allows .htaccess files.
Try the following in an .htaccess file:

php_flag short_open_tag on

That will allow you to have  instead of 

Regards,

Rob


Andrés Robinet | Lead Developer | BESTPLACE CORPORATION
5100 Bayview Drive 206, Royal Lauderdale Landings, Fort Lauderdale, FL 33308
| TEL 954-607-4207 | FAX 954-337-2695
Email: [EMAIL PROTECTED]  | MSN Chat: [EMAIL PROTECTED]  |  SKYPE:
bestplace |  Web: http://www.bestplace.biz | Web: http://www.seo-diy.com

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



[PHP] Need help for DOM xsd validation

2007-12-02 Thread Matthias Reindl

Hi,

I'm trying to load XML data into my script. That's no problem. The  
problem is, that the schema validation fails all time after loading a  
new document:


Warning: DOMDocument::schemaValidate()  
[function.DOMDocument-schemaValidate]: Element  
'{http://www.desktopportal.de/Preferences}user': This element is not  
expected. Expected is ( user ).


Funny is, if I'm creating and adding elements with php (DOMDocument  
etc.) and then validate the xml structure, no error occures. But if I  
reload this saved file next time when the script is reloading, I get a  
warning.


Any ideas? Thanks,
Matthias

This is my xml file:

http://www.desktopportal.de/Preferences";  
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>





This is my xsd file:

http://www.desktopportal.de/Preferences";  
xmlns="http://www.desktopportal.de/Preferences";  
xmlns:xsd="http://www.w3.org/2001/XMLSchema";>





		maxOccurs="unbounded"/>






		minOccurs="1"/>







		maxOccurs="unbounded"/>






		maxOccurs="unbounded"/>







		maxOccurs="1"/>


	use="required">




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



Re: [PHP] sprintf() oddness

2007-12-02 Thread Christoph

The 4th significant digit in both cases is '5' but in the first case, it's
rounded down but in the second case it is rounded up.  Is sprintf() basing
it's decision on the value of the 3rd significant digit?  If so, why?
Shouldn't rounding decisions be based on subsequent digits and not 
preceding

ones?
Actually, it's more accurate to use the preceding digit to determine 
rounding. What you describe is "if even then round down else round up". 
That's more accurate than always rounding up or always rounding down.

Please follow:
When the digit is zero, no rounding takes place.
When the digit is 1 - 4, round down.
When the digit is 6 - 9, round up.


Ok, I understand what's gong on but still not why.

Fine up to there -- but, if you always round up or down for 5, then you 
are introducing bias.


Fair point except...

So, if you use the even/odd value of the preceding digit to determine 
which way to round for 5, then it's more accurate.
My rounding method doesn't always win against php's round(), but it wins 
more times than not. Plus, it takes a lot of rounding to introduce the 
bias I found and thus for most applications using the round() function 
(always round down) will suffice.


...consider the following example:


echo '

sprintf() test:

';

echo 'sprintf( "%.03f", 0.20375000 ) = ' . sprintf( '%.03f', 0.20375000 ) . '
';
echo 'sprintf( "%.03f", 0.17318750 ) = ' . sprintf( '%.03f', 0.17318750 ) . '
';
echo 'sprintf( "%.03f", 0.15485000 ) = ' . sprintf( '%.03f', 0.15485000 ) . '
';
echo 'sprintf( "%.03f", 0.1525 ) = ' . sprintf( '%.03f', 0.1525 ) . '
';
echo 'sprintf( "%.03f", 0.12962500 ) = ' . sprintf( '%.03f', 0.12962500 ) . '
';
echo 'sprintf( "%.03f", 0.1159 ) = ' . sprintf( '%.03f', 0.1159 ) . '
';
echo 'sprintf( "%.03f", 0.1575 ) = ' . sprintf( '%.03f', 0.1575 ) . '
';
echo 'sprintf( "%.03f", 0.13387500 ) = ' . sprintf( '%.03f', 0.13387500 ) . '
';
echo 'sprintf( "%.03f", 0.1197 ) = ' . sprintf( '%.03f', 0.1197 ) . '
';
echo 'sprintf( "%.03f", 0.1525 ) = ' . sprintf( '%.03f', 0.1525 ) . '
';
echo 'sprintf( "%.03f", 0.12962500 ) = ' . sprintf( '%.03f', 0.12962500 ) . '
';
echo 'sprintf( "%.03f", 0.1159 ) = ' . sprintf( '%.03f', 0.1159 ) . '
';
echo 'sprintf( "%.03f", 0.07875000 ) = ' . sprintf( '%.03f', 0.07875000 ) . '
';
echo 'sprintf( "%.03f", 0.06693750 ) = ' . sprintf( '%.03f', 0.06693750 ) . '
';
echo 'sprintf( "%.03f", 0.05985000 ) = ' . sprintf( '%.03f', 0.05985000 ) . '
';
echo 'sprintf( "%.03f", 0.13125000 ) = ' . sprintf( '%.03f', 0.13125000 ) . '
';
echo 'sprintf( "%.03f", 0.13375000 ) = ' . sprintf( '%.03f', 0.13375000 ) . '

';
echo '

round() test:

'; echo 'round( 0.20375000, 3 ) = ' . round( 0.20375000, 3 ) . '
'; echo 'round( 0.17318750, 3 ) = ' . round( 0.17318750, 3 ) . '
'; echo 'round( 0.15485000, 3 ) = ' . round( 0.15485000, 3 ) . '
'; echo 'round( 0.1525, 3 ) = ' . round( 0.1525, 3 ) . '
'; echo 'round( 0.12962500, 3 ) = ' . round( 0.12962500, 3 ) . '
'; echo 'round( 0.1159, 3 ) = ' . round( 0.1159, 3 ) . '
'; echo 'round( 0.1575, 3 ) = ' . round( 0.1575, 3 ) . '
'; echo 'round( 0.13387500, 3 ) = ' . round( 0.13387500, 3 ) . '
'; echo 'round( 0.1197, 3 ) = ' . round( 0.1197, 3 ) . '
'; echo 'round( 0.1525, 3 ) = ' . round( 0.1525, 3 ) . '
'; echo 'round( 0.12962500, 3 ) = ' . round( 0.12962500, 3 ) . '
'; echo 'round( 0.1159, 3 ) = ' . round( 0.1159, 3 ) . '
'; echo 'round( 0.07875000, 3 ) = ' . round( 0.07875000, 3 ) . '
'; echo 'round( 0.06693750, 3 ) = ' . round( 0.06693750, 3 ) . '
'; echo 'round( 0.05985000, 3 ) = ' . round( 0.05985000, 3 ) . '
'; echo 'round( 0.13125000, 3 ) = ' . round( 0.13125000, 3 ) . '
'; echo 'round( 0.13375000, 3 ) = ' . round( 0.13375000, 3 ) . '

'; Why is the behavior of round() different to that of sprintf()? Both are rounding numbers. I'll grant you that sprintf() has more utility and does more things than round() but when you are dealing with numbers (and more specifically, when you've used a numeric type specifier in the format argument), sprintf() is doing the same type of thing to the value -- rounding. So why are they doing it differently? Is that a bug? I'm reticent to say that but it doesn't make sense to me that they would behave differently. If the general rule is to round up for 5s when preceeding is odd and round down when even, that's not occuring here when using round(). thnx, Christoph -- PHP General Mailing List (http://www.php.net/) T


Re: [PHP] include "config.php" does not work anymore after PHP 5.2

2007-12-02 Thread Richard Heyes

I never never thought my config.php might have problem. I have used
this config.php for almost 6 years and never had problem (the first
time I have forgotten to add it 6 years ago because I had migrated
from ASP. I have copied this wrong config.php to some other projects.


Have you ever migrated from PHP 4.x to PHP 5.x? This is a major upgrade 
so you should expect things to stop working. Using the long version of 
the open tags (ie 

--
Richard Heyes
http://www.websupportsolutions.co.uk

Knowledge Base and HelpDesk software
that can cut the cost of online support

** NOW OFFERING FREE ACCOUNTS TO CHARITIES AND NON-PROFITS **

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



[PHP] Need help for DOM xsd validation

2007-12-02 Thread Matthias Reindl

Hi,

I'm trying to load XML data into my script. That's no problem. The  
problem is, that the

schema validation fails all time after loading a new document:

Warning: DOMDocument::schemaValidate()  
[function.DOMDocument-schemaValidate]: Element
'{http://www.desktopportal.de/Preferences}user': This element is not  
expected. Expected

is ( user ).

Funny is, if I'm creating and adding elements with php (DOMDocument  
etc.) and then
validate the xml structure, no error occures. But if I reload this  
saved file next time

when the script is reloading, I get a warning.

Any ideas? Thanks,
Matthias

This is my xml file:

http://www.desktopportal.de/Preferences";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>




This is my xsd file:

http://www.desktopportal.de/Preferences";
xmlns="http://www.desktopportal.de/Preferences";
xmlns:xsd="http://www.w3.org/2001/XMLSchema";>




minOccurs="0" maxOccurs="unbounded"/>






maxOccurs="1" minOccurs="1"/>


use="required">





minOccurs="0" maxOccurs="unbounded"/>






minOccurs="1" maxOccurs="unbounded"/>


use="required">





minOccurs="1" maxOccurs="1"/>


use="required">




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



[PHP] checkbox unchecked

2007-12-02 Thread Ronald Wiplinger
I have now tried to add many of the security hints on a web page and
come to a problem.
I am checking if the allowed fields match the sent fields.
>From the database I get the information if a checkbox is checked or not:





If the user takes out the checkmark the value will become "" and the
field will not submitted which results in a missing field.

$allowed = array();
$allowed[]='form';
$allowed[]='R_a';
$allowed[]='R_b';

$sent = $array_keys($_POST);
if($allowed == $sent) {
... do some checking ...
} else {
echo "Expected input fields do not match!";
}
break;


How can I force a "n" for not checked in the input field? or how can I
solve that?

bye

Ronald

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



Re: [PHP] checkbox unchecked

2007-12-02 Thread Stephen

Ronald Wiplinger wrote:

How can I force a "n" for not checked in the input field? or how can I
solve that?
  

Either use radio buttons  or a drop down  for the input field.

Stephen

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



Re: [PHP] checkbox unchecked

2007-12-02 Thread Ronald Wiplinger
Stephen wrote:
> Ronald Wiplinger wrote:
>> How can I force a "n" for not checked in the input field? or how can I
>> solve that?
>>   
> Either use radio buttons  or a drop down  for the input field.

Thanks!

>
> Stephen
>

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



Re: [PHP] checkbox unchecked

2007-12-02 Thread Larry Garfield
First of all, using "y" and "n" for boolean values (such as a checkbox) is 
very sloppy.  "n" is boolean True.  A boolean value should evaluate correctly 
in a boolean context.  For that, you should use 1 and 0 for your values.  

What I usually do is this:


 />

Then when it gets submitted, foo will get the value of the form element that 
was submitted last that has a value.  That is, if the checkbox is checked 
then foo will be 1, otherwise it will be 0.  That gives you a nice, clean 
boolean value you can rely on being present (mostly ).  

On Sunday 02 December 2007, Ronald Wiplinger wrote:
> I have now tried to add many of the security hints on a web page and
> come to a problem.
> I am checking if the allowed fields match the sent fields.
> From the database I get the information if a checkbox is checked or not:
>
>  $checked="checked";
> } else {
> $checked="";
> }
> ?>
> 
>
>
> If the user takes out the checkmark the value will become "" and the
> field will not submitted which results in a missing field.
>
> $allowed = array();
> $allowed[]='form';
> $allowed[]='R_a';
> $allowed[]='R_b';
> 
> $sent = $array_keys($_POST);
> if($allowed == $sent) {
> ... do some checking ...
> } else {
> echo "Expected input fields do not match!";
> }
> break;
>
>
> How can I force a "n" for not checked in the input field? or how can I
> solve that?
>
> bye
>
> Ronald


-- 
Larry Garfield  AIM: LOLG42
[EMAIL PROTECTED]   ICQ: 6817012

"If nature has made any one thing less susceptible than all others of 
exclusive property, it is the action of the thinking power called an idea, 
which an individual may exclusively possess as long as he keeps it to 
himself; but the moment it is divulged, it forces itself into the possession 
of every one, and the receiver cannot dispossess himself of it."  -- Thomas 
Jefferson

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



Re: [PHP] checkbox unchecked

2007-12-02 Thread Afan Pasalic

I did once, if I remember once, this "strategy":

>
If checked, you will have value "y". Though, if unchecked, or it was 
checked and visitor unchecked, the value should be "n".


;)

-afan


Ronald Wiplinger wrote:

I have now tried to add many of the security hints on a web page and
come to a problem.
I am checking if the allowed fields match the sent fields.
From the database I get the information if a checkbox is checked or not:





If the user takes out the checkmark the value will become "" and the
field will not submitted which results in a missing field.

$allowed = array();
$allowed[]='form';
$allowed[]='R_a';
$allowed[]='R_b';

$sent = $array_keys($_POST);
if($allowed == $sent) {
... do some checking ...
} else {
echo "Expected input fields do not match!";
}
break;


How can I force a "n" for not checked in the input field? or how can I
solve that?

bye

Ronald



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



Re: [PHP] include "config.php" does not work anymore after PHP 5.2

2007-12-02 Thread Mike Yrabedra
on 12/2/07 2:22 AM, wmac at [EMAIL PROTECTED] wrote:

> 
> Hello,
> 
> I have been working with PHP 5.0 and my "register_globals" has always been
> Off since PHP 4.1
> 
> Today I upgraded to PHP 5.2 and now neither of my include "config.php" work.
> 
> Neither of the variables defined in include files are even included. Anyone
> knows what has been changed and what can I do?
> 
> This is what I normally use
> 
> PHP Code:
> 
> include("config.php");
> 
> mysql_connect($host,$user,$password);
> @mysql_select_db("$db") or die("Unable to open database");
> 
> I echoed those connection variables and all are empty.
> 
> Thank you,
> Mac


I had the same problem last week.

Turned out there was another 'config.php' in the include_path (in my case
the pear folder).

Can you rename the config.php file and things work?

If so, then look in your include_path and see if there is a config.php file
there as well.


-- 
Mike B^)>

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



Re: [PHP] checkbox unchecked

2007-12-02 Thread Steve Edberg

Just to add my two cents -

I don't think it matters much what tokens you use to represent true 
or false, since you're going to be explicitly checking them on the 
server end anyway. I can't see much difference in principle between, 
for example:


if ($_GET['foo'] == 'y')...
and
if ($_GET['foo'] == '1')...
or even
if ($_GET['foo'] == 'Oui')...

One should really not do be doing just

if ($_GET['foo'])

anyway. Checking that a specific value is passed, rather than just 
some value that PHP evaluates to true or false, is one way to catch 
possible form hacking. For general reference, there are a number of 
php security howtos out there on how to sanitize user input, but I'll 
leave finding them as an 'excercize for the reader' at the moment. I 
suppose using 0/1 does have the advantage of 'doing the right thing' 
if a "if ($_GET['foo'])" creeps into your code, though. As would 
using 'Y'/''.


That being said, I've used 0/1 along with y/n in the past; it depends 
on whether I'm thinking like a programmer or a human ;)


steve


At 12:36 PM -0600 12/2/07, Larry Garfield wrote:

First of all, using "y" and "n" for boolean values (such as a checkbox) is
very sloppy.  "n" is boolean True.  A boolean value should evaluate correctly
in a boolean context.  For that, you should use 1 and 0 for your values. 


What I usually do is this:


 />

Then when it gets submitted, foo will get the value of the form element that
was submitted last that has a value.  That is, if the checkbox is checked
then foo will be 1, otherwise it will be 0.  That gives you a nice, clean
boolean value you can rely on being present (mostly ). 


On Sunday 02 December 2007, Ronald Wiplinger wrote:

 I have now tried to add many of the security hints on a web page and
 come to a problem.
 I am checking if the allowed fields match the sent fields.
 From the database I get the information if a checkbox is checked or not:

 
 


 If the user takes out the checkmark the value will become "" and the
 field will not submitted which results in a missing field.

 $allowed = array();
 $allowed[]='form';
 $allowed[]='R_a';
 $allowed[]='R_b';
 
 $sent = $array_keys($_POST);
 if($allowed == $sent) {
 ... do some checking ...
 } else {
 echo "Expected input fields do not match!";
 }
 break;


 How can I force a "n" for not checked in the input field? or how can I
 solve that?

 bye


 > Ronald




--
+--- my people are the people of the dessert, ---+
| Steve Edberghttp://pgfsun.ucdavis.edu/ |
| UC Davis Genome Center[EMAIL PROTECTED] |
| Bioinformatics programming/database/sysadmin (530)754-9127 |
+ said t e lawrence, picking up his fork +

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



Re: [PHP] checkbox unchecked

2007-12-02 Thread Jürgen Wind

nice!
but to avoid confusion it should read (assuming that $checked is a boolean
variable):

/>

IMHO


Larry Garfield wrote:
> 
> First of all, using "y" and "n" for boolean values (such as a checkbox) is 
> very sloppy.  "n" is boolean True.  A boolean value should evaluate
> correctly 
> in a boolean context.  For that, you should use 1 and 0 for your values.  
> 
> What I usually do is this:
> 
> 
>  />
> 
> Then when it gets submitted, foo will get the value of the form element
> that 
> was submitted last that has a value.  That is, if the checkbox is checked 
> then foo will be 1, otherwise it will be 0.  That gives you a nice, clean 
> boolean value you can rely on being present (mostly ).  
> 
> On Sunday 02 December 2007, Ronald Wiplinger wrote:
>> I have now tried to add many of the security hints on a web page and
>> come to a problem.
>> I am checking if the allowed fields match the sent fields.
>> From the database I get the information if a checkbox is checked or not:
>>
>> > $checked="checked";
>> } else {
>> $checked="";
>> }
>> ?>
>> 
>>
>>
>> If the user takes out the checkmark the value will become "" and the
>> field will not submitted which results in a missing field.
>>
>> $allowed = array();
>> $allowed[]='form';
>> $allowed[]='R_a';
>> $allowed[]='R_b';
>> 
>> $sent = $array_keys($_POST);
>> if($allowed == $sent) {
>> ... do some checking ...
>> } else {
>> echo "Expected input fields do not match!";
>> }
>> break;
>>
>>
>> How can I force a "n" for not checked in the input field? or how can I
>> solve that?
>>
>> bye
>>
>> Ronald
> 
> 
> -- 
> Larry GarfieldAIM: LOLG42
> [EMAIL PROTECTED] ICQ: 6817012
> 
> "If nature has made any one thing less susceptible than all others of 
> exclusive property, it is the action of the thinking power called an idea, 
> which an individual may exclusively possess as long as he keeps it to 
> himself; but the moment it is divulged, it forces itself into the
> possession 
> of every one, and the receiver cannot dispossess himself of it."  --
> Thomas 
> Jefferson
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/checkbox-unchecked-tf4932527.html#a14119395
Sent from the PHP - General mailing list archive at Nabble.com.

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



Re: [PHP] checkbox unchecked

2007-12-02 Thread tedd

At 12:36 PM -0600 12/2/07, Larry Garfield wrote:

First of all, using "y" and "n" for boolean values (such as a checkbox) is
very sloppy.  "n" is boolean True.  A boolean value should evaluate correctly
in a boolean context.  For that, you should use 1 and 0 for your values. 


What I usually do is this:


 />

Then when it gets submitted, foo will get the value of the form element that
was submitted last that has a value.  That is, if the checkbox is checked
then foo will be 1, otherwise it will be 0.  That gives you a nice, clean

boolean value you can rely on being present (mostly ).

Larry:

Not that you said otherwise, but if the programmer does not set the 
value for a checkbox, html will provide values  -- that may lead to 
confusion for newer programmers.


See here:

http://webbytedd.com//checkbox/

If you will note, without specifically setting the value, html will 
return "on".


Also, I'm sure it's an oversight, but your code above should be:



Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] sprintf() oddness

2007-12-02 Thread tedd

At 6:08 AM -0500 12/2/07, Christoph wrote:
 If the general rule is to round up for 5s when preceeding is odd 
and round down when even, that's not occuring here when using 
round().


No, you're not reading what I wrote. I said MY general rule is to 
round up when the preceding digit is even, whereas php's round 
function always rounds down.


As for sprint_f(), I haven't investigated that.

Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] checkbox unchecked

2007-12-02 Thread Casey
On Dec 2, 2007 1:08 PM, tedd <[EMAIL PROTECTED]> wrote:
> At 12:36 PM -0600 12/2/07, Larry Garfield wrote:
> >First of all, using "y" and "n" for boolean values (such as a checkbox) is
> >very sloppy.  "n" is boolean True.  A boolean value should evaluate correctly
> >in a boolean context.  For that, you should use 1 and 0 for your values.
> >
> >What I usually do is this:
> >
> >
> > />
> >
> >Then when it gets submitted, foo will get the value of the form element that
> >was submitted last that has a value.  That is, if the checkbox is checked
> >then foo will be 1, otherwise it will be 0.  That gives you a nice, clean
> boolean value you can rely on being present (mostly ).
>
> Larry:
>
> Not that you said otherwise, but if the programmer does not set the
> value for a checkbox, html will provide values  -- that may lead to
> confusion for newer programmers.
>
> See here:
>
> http://webbytedd.com//checkbox/
>
> If you will note, without specifically setting the value, html will
> return "on".
>
> Also, I'm sure it's an oversight, but your code above should be:
>
> 
>
> Cheers,
>
> tedd
>
> --
> ---
> http://sperling.com  http://ancientstones.com  http://earthstones.com
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

You don't need to do anything.


When it's submitted:
http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Join question

2007-12-02 Thread Crayon Shin Chan
On Saturday 01 December 2007, chris smith wrote:
> Considering the rest of the off-topic questions that regularly get
> asked on this list it's a bit much to single out this one particular
> post.

I didn't single it out, it just happened to be at the top of the pile at 
the the time. It was also helped by the fact that the OP, who is 
apparently, renowned for programming in rocks since the time before 
binary was invented, ought to know list etiquette better than most.

> javascript, css, html - none is directly related to php but all still
> get asked here (and 99% of the time answered) - I don't know why
> you're making such a big deal about this particular post and haven't
> kicked up a fuss about the rest in the past.

Exactly how big a deal did I make out of this one? I simply said "ask on a 
database list". It is the responses to that which seems to be kicking up 
all the fuss.

-- 
Crayon

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



Re: [PHP] Structured Code vs. Performance

2007-12-02 Thread tedd

At 8:56 AM +0100 11/29/07, <[EMAIL PROTECTED]> wrote:

Looks for me a bit like a philosophical question, but maybe you have
something to say about it nevertheless. A good thing for me would be
something like: up to 125 lines of code you get an adequate performance with
simply parsing it every time, with more than 125 lines you would get a
better performance with using separate files - just kidding, surely the
number of lines in this case is 42 ;-).

Looking forward to your answers
Thomas


Thomas:

I seldom find that performance is adversely affected by good 
structure. So, I strive for good structure.


To me, good structure starts at the function level. Like the lattice 
of a crystal, coding grows and reflects the most basic element. Keep 
that element consistent and you'll find that it will be reflected in 
everything you do.


How's that for philosophical?

Cheers,

tedd


--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



[PHP] PHP/Perl

2007-12-02 Thread lists
Hi,

Job onsite at Telecom giant in Finland (guess what telecom giant). Please
see  http://jobs.perl.org/job/7322 for more info. Send CV if you're
interested to [EMAIL PROTECTED]

/Peter

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



Re: [PHP] checkbox unchecked

2007-12-02 Thread tedd

At 1:23 PM -0800 12/2/07, Casey wrote:

On Dec 2, 2007 1:08 PM, tedd <[EMAIL PROTECTED]> wrote:

You don't need to do anything.


When it's submitted:


That's true unless you're pulling data in from somewhere else (i.e., a dB).

Cheers,

tedd
--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



[PHP] 5.2.5 failed 7 tests

2007-12-02 Thread Bill
Do failed tests mean I absolutely should NOT install. Or is it normal to 
have a few fails? Try two different versions, all have some failure. 


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



Re: [PHP] Join question

2007-12-02 Thread Crayon Shin Chan
On Sunday 02 December 2007, Daniel Brown wrote:

> There are a great deal of highly-intelligent people on this list, so why
> not take advantage of that resource? 

I do, that's why I'm on the list.

> So until you've been around enough to truly earn your right to
> tell someone far more accomplished than yourself to seek help
> elsewhere, do us all a favor and keep your God damned mouth shut.

AFAIK no list has the clause "once you have made X number of posts feel 
free to do what you want".

-- 
Crayon

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



Re: [PHP] Join question

2007-12-02 Thread tedd

At 6:24 AM +0800 12/3/07, Crayon Shin Chan wrote:

 It was also helped by the fact that the OP, who is
apparently, renowned for programming in rocks since the time before
binary was invented, ought to know list etiquette better than most.


That's "world renowned", if you please. :-)

But just to set the record straight, binary had been invented long 
before I came along. The programmers before then had to program in 
just rocks (1's). It wasn't until much later that the absent of rock 
was invented (0's).


Now, you may not think that one can do anything programming with just 
rocks, but that's the way the pyramids were built. Those old 
programmers were an accomplished lot.


As for me, with my vast experience, I think that "list etiquette" on 
an unmoderated list is what we make it. If you want to correct people 
as to "list etiquette", it's probably best for you to join a list 
with people who care what you think. Unfortunately, I think you'll 
probably have difficulty with that as well.


It's unfortunate that you can't take your talents and help someone 
instead of being so critical. To me, it would be a pretty sad life if 
I had nothing positive to say.


Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



RE: [PHP] including parenthesis, space and dashes in a phone number

2007-12-02 Thread Daevid Vincent
 

> -Original Message-
> From: Warren Vail [mailto:[EMAIL PROTECTED] 
> Sent: Friday, November 30, 2007 2:17 PM
> To: 'Jochem Maas'
> Cc: 'afan pasalic'; 'Daevid Vincent'; 'php-general'
> Subject: RE: [PHP] including parenthesis, space and dashes in 
> a phone number
> 
> I did not know that about Windows Letter formatting, well, 
> not all Americans
> think everything revolves around the way Americans do things. 
>  Knowing a
> little about Microsoft marketing strategy, they probably feel 
> they should
> charge extra for providing more flexible formatting.
> 
> I do believe a good site designer, will plan for a global 
> market, instead of
> a local US one, even if others fail to share his vision.

My product/service is currently only a US/domestic one. 

When the day comes that we need to make it international, we'll have a lot more 
to worry about than simple phone number display. There will be "gettext()" 
involved and .po/.mo files and all that other hassle (I know, I've done it 
before with other companies). Also date formats will change from m/d/y to y-m-d 
too. 

So I would counter and say, a good site designer, designs for their target 
audience... ;-)

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



RE: [PHP] including parenthesis, space and dashes in a phone number

2007-12-02 Thread Daevid Vincent
I should have been more clear. I do *store* the numbers sans punctuation, but 
that's trivial to accomplish as we've seen. I do like to display it however 
with the nice parens and hyphens. Hence "opposite". :)

> -Original Message-
> From: afan pasalic [mailto:[EMAIL PROTECTED] 
> Sent: Friday, November 30, 2007 12:03 PM
> To: Daevid Vincent
> Cc: 'php-general'
> Subject: Re: [PHP] including parenthesis, space and dashes in 
> a phone number
> 
> It's ok to store it this way, but it could be a little PITA 
> when search.
> E.g., you store (123) 456-7890 and somebody search for 
> 123-456-7890? Right?
> 
> -afan
> 
> 
> 
> Daevid Vincent wrote:
> > The kind of OPPOSITE of this, is what I use, in that it 
> ADDs the () and -
> > 
> > if ((strlen($phone)) <= 14) $phone = 
> > 
> preg_replace("/[^0-9]*([0-9]{3})[^0-9]*([0-9]{3})[^0-9]*([0-9]
> {4}).*/",
> >   "(\\1) \\2-\\3", $phone); 

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



Re: [PHP] sprintf() oddness

2007-12-02 Thread Martin Alterisio
2007/12/1, Christoph Boget <[EMAIL PROTECTED]>:
>
> Why does
>
> sprintf( '%.03f', 0.1525 )
>
> return 0.152 while
>
> sprintf( '%.03f', 0.1575 )
>
> return 0.158?
>


Welcome to the world of f floating point numbers. Discrete mathematics,
leave all hope, ye that enter.

It's the way floating point number behave (a computational error that's more
problematic that one may suspect). You'll have to live with it, or use an
extension for arbitrary sized numbers (or fixed point numbers).

Why we have to accept this kind of behavior?

Long story short: they are excellent for computations required in 3d
graphics, they are lousy for business applications...
...and we all know that computers are for playing 3d games, don't we?

XD

Sorry about the noise.


Re: [PHP] Structured Code vs. Performance

2007-12-02 Thread Martin Alterisio
2007/12/2, tedd <[EMAIL PROTECTED]>:
>
>
> To me, good structure starts at the function level. Like the lattice
> of a crystal, coding grows and reflects the most basic element. Keep
> that element consistent and you'll find that it will be reflected in
> everything you do.
>
> How's that for philosophical?
>

I even have a name for your philosophical doctrine: fractalism


Re: [PHP] Structured Code vs. Performance

2007-12-02 Thread tedd

At 8:56 PM -0300 12/2/07, Martin Alterisio wrote:

2007/12/2, tedd <[EMAIL PROTECTED]>:


To me, good structure starts at the function level. Like the lattice
of a crystal, coding grows and reflects the most basic element. Keep
that element consistent and you'll find that it will be reflected in
everything you do.

How's that for philosophical?


I even have a name for your philosophical doctrine: fractalism


Oh yes, it's very much like fractals, but the term "fractalism" is 
usually reserved for art forms based on fractals.


However, one could conclude that all crystalline forms are a 
"real-world" examples of fractals. In similar vein, all repetitive 
processes (including programming) could be though of as a fractal 
dependant functions. Interesting food for thought, which also could 
be fractal dependant. :-)


Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] Issue with STRFTIME and Daylight Savings

2007-12-02 Thread Robert Cummings
On Mon, 2007-12-03 at 15:14 +1000, Malcolm Green wrote:
> Hi Support:
> 
> I've moved into a new role and inherited a system which uses the 'STRFTIME'
> function to create a filename in the form 'strftime("%Y%m%d")'; the
> filename is supposed to be "today's date". (Note I've left out the file
> extension for clarity.)
> 
> I've noticed that system creates the wrong filename when the process runs
> between midnight and 12:59am, during Daylight Savings time. That is, it
> creates a filename equal to "yesterday's date". When run at 1:00am or
> later, everything OK.
> 
> I've checked the Date/Time and 'Locale' settings in Windows, and everything
> is ok. My initial thought was that STRFTIME was looking a the system clock
> rather than Windows (?).
> 
> Can you help?
> 
> (PS ... please be gentle, I'm a novice at PHP!)

Check your timezone settings in php.ini

Cheers,
Rob.
-- 
...
SwarmBuy.com - http://www.swarmbuy.com

Leveraging the buying power of the masses!
...

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



[PHP] Issue with STRFTIME and Daylight Savings

2007-12-02 Thread Malcolm Green

Hi Support:

I've moved into a new role and inherited a system which uses the 'STRFTIME'
function to create a filename in the form 'strftime("%Y%m%d")'; the
filename is supposed to be "today's date". (Note I've left out the file
extension for clarity.)

I've noticed that system creates the wrong filename when the process runs
between midnight and 12:59am, during Daylight Savings time. That is, it
creates a filename equal to "yesterday's date". When run at 1:00am or
later, everything OK.

I've checked the Date/Time and 'Locale' settings in Windows, and everything
is ok. My initial thought was that STRFTIME was looking a the system clock
rather than Windows (?).

Can you help?

(PS ... please be gentle, I'm a novice at PHP!)


Thanks & Regards,
Malcolm.

Malcolm Green
Voice Consultant, Managed Network Services
CSC Australia Pty Limited
M: 0401-002-569
T: (02) 9034-3114
E: [EMAIL PROTECTED]

"Vision without action is a dream; action without vision is a nightmare." -
Chinese Proverb




This is a PRIVATE message. If you are not the intended recipient, please
delete without copying and kindly advise us by e-mail of the mistake in
delivery. NOTE: Regardless of content, this e-mail shall not operate to
bind CSC to any order or other contract unless pursuant to explicit written
agreement or government initiative expressly permitting the use of e-mail
for such purpose.


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