php-general Digest 2 Dec 2007 09:35:27 -0000 Issue 5159
php-general Digest 2 Dec 2007 09:35:27 - Issue 5159 Topics (messages 265372 through 265375): include config.php does not work anymore after PHP 5.2 265372 by: wmac 265373 by: Casey 265374 by: wmac 265375 by: wmac Administrivia: To subscribe to the digest, e-mail: [EMAIL PROTECTED] To unsubscribe from the digest, e-mail: [EMAIL PROTECTED] To post to the list, e-mail: [EMAIL PROTECTED] -- ---BeginMessage--- 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. ---End Message--- ---BeginMessage--- 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 ---End Message--- ---BeginMessage--- Hello This is the same thing I always use. ? $host=localhost; $user=root; $password=123; $db=stud; $activation=1; $MAXATTACHSIZE = 100; $ATTACHDIRPATH=e:/www/stud/lattach/; ? By the way, I installed php 4.4.7 and everything is fine with this version though register_globals is again Off. Regards, Mac ---End Message--- ---BeginMessage--- 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. ---End Message---
php-general Digest 2 Dec 2007 22:10:35 -0000 Issue 5160
php-general Digest 2 Dec 2007 22:10:35 - Issue 5160 Topics (messages 265376 through 265392): Re: include config.php does not work anymore after PHP 5.2 265376 by: Andrés Robinet 265379 by: Richard Heyes 265386 by: Mike Yrabedra Need help for DOM xsd validation 265377 by: Matthias Reindl 265380 by: Matthias Reindl Re: sprintf() oddness 265378 by: Christoph 265390 by: tedd checkbox unchecked 265381 by: Ronald Wiplinger 265382 by: Stephen 265383 by: Afan Pasalic 265384 by: Ronald Wiplinger 265385 by: Larry Garfield 265387 by: Steve Edberg 265388 by: Jürgen Wind 265389 by: tedd 265391 by: Casey PHP/Perl 265392 by: lists.dwsasia.com Administrivia: To subscribe to the digest, e-mail: [EMAIL PROTECTED] To unsubscribe from the digest, e-mail: [EMAIL PROTECTED] To post to the list, e-mail: [EMAIL PROTECTED] -- ---BeginMessage--- -Original Message- From: wmac [mailto:[EMAIL PROTECTED] Sent: Sunday, December 02, 2007 6:35 AM To: [EMAIL PROTECTED] 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 ? as the starting tag for PHP code and will allow for ?=$myvar? instead of ?php echo $myvar ? 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 ---End Message--- ---BeginMessage--- 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 ?php ) has been best practice for a long time. -- 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 ** ---End Message--- ---BeginMessage--- 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^) ---End Message--- ---BeginMessage--- 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':
Re: [PHP] include config.php does not work anymore after PHP 5.2
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
Hello This is the same thing I always use. ? $host=localhost; $user=root; $password=123; $db=stud; $activation=1; $MAXATTACHSIZE = 100; $ATTACHDIRPATH=e:/www/stud/lattach/; ? 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
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
-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 ? as the starting tag for PHP code and will allow for ?=$myvar? instead of ?php echo $myvar ? 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
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: ?xml version=1.0 encoding=UTF-8? preferences xmlns=http://www.desktopportal.de/Preferences; xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance; user id=1webmail//user user id=2webmail//user /preferences This is my xsd file: ?xml version=1.0 encoding=UTF-8? xsd:schema targetNamespace=http://www.desktopportal.de/Preferences; xmlns=http://www.desktopportal.de/Preferences; xmlns:xsd=http://www.w3.org/2001/XMLSchema; xsd:element name=preferences type=typePreferences/ xsd:complexType name=typePreferences xsd:sequence xsd:element name=user type=typeUser minOccurs=0 maxOccurs=unbounded/ /xsd:sequence /xsd:complexType xsd:complexType name=typeUser xsd:sequence xsd:element name=webmail type=typeWebmail maxOccurs=1 minOccurs=1/ /xsd:sequence xsd:attribute name=id type=xsd:int use=required/xsd:attribute /xsd:complexType xsd:complexType name=typeWebmail xsd:sequence xsd:element name=mailbox type=typeMailbox minOccurs=0 maxOccurs=unbounded/ /xsd:sequence /xsd:complexType xsd:complexType name=typeMailbox xsd:sequence xsd:element name=box type=typeBox minOccurs=1 maxOccurs=unbounded/ /xsd:sequence xsd:attribute name=id type=xsd:int use=required/xsd:attribute /xsd:complexType xsd:complexType name=typeBox xsd:sequence xsd:element name=visibility type=xsd:boolean minOccurs=1 maxOccurs=1/ /xsd:sequence xsd:attribute name=name type=xsd:string use=required/xsd:attribute /xsd:complexType /xsd:schema -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] sprintf() oddness
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: script language=php echo 'h3sprintf() test:brbr'; echo 'sprintf( %.03f, 0.20375000 ) = ' . sprintf( '%.03f', 0.20375000 ) . 'br'; echo 'sprintf( %.03f, 0.17318750 ) = ' . sprintf( '%.03f', 0.17318750 ) . 'br'; echo 'sprintf( %.03f, 0.15485000 ) = ' . sprintf( '%.03f', 0.15485000 ) . 'br'; echo 'sprintf( %.03f, 0.1525 ) = ' . sprintf( '%.03f', 0.1525 ) . 'br'; echo 'sprintf( %.03f, 0.12962500 ) = ' . sprintf( '%.03f', 0.12962500 ) . 'br'; echo 'sprintf( %.03f, 0.1159 ) = ' . sprintf( '%.03f', 0.1159 ) . 'br'; echo 'sprintf( %.03f, 0.1575 ) = ' . sprintf( '%.03f', 0.1575 ) . 'br'; echo 'sprintf( %.03f, 0.13387500 ) = ' . sprintf( '%.03f', 0.13387500 ) . 'br'; echo 'sprintf( %.03f, 0.1197 ) = ' . sprintf( '%.03f', 0.1197 ) . 'br'; echo 'sprintf( %.03f, 0.1525 ) = ' . sprintf( '%.03f', 0.1525 ) . 'br'; echo 'sprintf( %.03f, 0.12962500 ) = ' . sprintf( '%.03f', 0.12962500 ) . 'br'; echo 'sprintf( %.03f, 0.1159 ) = ' . sprintf( '%.03f', 0.1159 ) . 'br'; echo 'sprintf( %.03f, 0.07875000 ) = ' . sprintf( '%.03f', 0.07875000 ) . 'br'; echo 'sprintf( %.03f, 0.06693750 ) = ' . sprintf( '%.03f', 0.06693750 ) . 'br'; echo 'sprintf( %.03f, 0.05985000 ) = ' . sprintf( '%.03f', 0.05985000 ) . 'br'; echo 'sprintf( %.03f, 0.13125000 ) = ' . sprintf( '%.03f', 0.13125000 ) . 'br'; echo 'sprintf( %.03f, 0.13375000 ) = ' . sprintf( '%.03f', 0.13375000 ) . 'brbr'; echo 'h3round() test:brbr'; echo 'round( 0.20375000, 3 ) = ' . round( 0.20375000, 3 ) . 'br'; echo 'round( 0.17318750, 3 ) = ' . round( 0.17318750, 3 ) . 'br'; echo 'round( 0.15485000, 3 ) = ' . round( 0.15485000, 3 ) . 'br'; echo 'round( 0.1525, 3 ) = ' . round( 0.1525, 3 ) . 'br'; echo 'round( 0.12962500, 3 ) = ' . round( 0.12962500, 3 ) . 'br'; echo 'round( 0.1159, 3 ) = ' . round( 0.1159, 3 ) . 'br'; echo 'round( 0.1575, 3 ) = ' . round( 0.1575, 3 ) . 'br'; echo 'round( 0.13387500, 3 ) = ' . round( 0.13387500, 3 ) . 'br'; echo 'round( 0.1197, 3 ) = ' . round( 0.1197, 3 ) . 'br'; echo 'round( 0.1525, 3 ) = ' . round( 0.1525, 3 ) . 'br'; echo 'round( 0.12962500, 3 ) = ' . round( 0.12962500, 3 ) . 'br'; echo 'round( 0.1159, 3 ) = ' . round( 0.1159, 3 ) . 'br'; echo 'round( 0.07875000, 3 ) = ' . round( 0.07875000, 3 ) . 'br'; echo 'round( 0.06693750, 3 ) = ' . round( 0.06693750, 3 ) . 'br'; echo 'round( 0.05985000, 3 ) = ' . round( 0.05985000, 3 ) . 'br'; echo 'round( 0.13125000, 3 ) = ' . round( 0.13125000, 3 ) . 'br'; echo 'round( 0.13375000, 3 ) = ' . round( 0.13375000, 3 ) . 'brbr'; /script 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/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] include config.php does not work anymore after PHP 5.2
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 ?php ) has been best practice for a long time. -- 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
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: ?xml version=1.0 encoding=UTF-8? preferences xmlns=http://www.desktopportal.de/Preferences; xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance; user id=1webmail//user user id=2webmail//user /preferences This is my xsd file: ?xml version=1.0 encoding=UTF-8? xsd:schema targetNamespace=http://www.desktopportal.de/Preferences; xmlns=http://www.desktopportal.de/Preferences; xmlns:xsd=http://www.w3.org/2001/XMLSchema; xsd:element name=preferences type=typePreferences/ xsd:complexType name=typePreferences xsd:sequence xsd:element name=user type=typeUser minOccurs=0 maxOccurs=unbounded/ /xsd:sequence /xsd:complexType xsd:complexType name=typeUser xsd:sequence xsd:element name=webmail type=typeWebmail maxOccurs=1 minOccurs=1/ /xsd:sequence xsd:attribute name=id type=xsd:int use=required/xsd:attribute /xsd:complexType xsd:complexType name=typeWebmail xsd:sequence xsd:element name=mailbox type=typeMailbox minOccurs=0 maxOccurs=unbounded/ /xsd:sequence /xsd:complexType xsd:complexType name=typeMailbox xsd:sequence xsd:element name=box type=typeBox minOccurs=1 maxOccurs=unbounded/ /xsd:sequence xsd:attribute name=id type=xsd:int use=required/xsd:attribute /xsd:complexType xsd:complexType name=typeBox xsd:sequence xsd:element name=visibility type=xsd:boolean minOccurs=1 maxOccurs=1/ /xsd:sequence xsd:attribute name=name type=xsd:string use=required/xsd:attribute /xsd:complexType /xsd:schema -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] checkbox unchecked
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: ?php if($DB_a ==y) { $checked=checked; } else { $checked=; } ? input type=checkbox name=R_a value=y ?php echo $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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] checkbox unchecked
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
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
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: input type=hidden name=foo value=0 / input type=checkbox name=foo value=1 ?php echo $checked; ? / 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 g). 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: ?php if($DB_a ==y) { $checked=checked; } else { $checked=; } ? input type=checkbox name=R_a value=y ?php echo $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
I did once, if I remember once, this strategy: input type=hidden name=R_a value=n input type=checkbox name=R_a value=y ?php echo $checked ? 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: ?php if($DB_a ==y) { $checked=checked; } else { $checked=; } ? input type=checkbox name=R_a value=y ?php echo $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 -- 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
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
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: input type=hidden name=foo value=0 / input type=checkbox name=foo value=1 ?php echo $checked; ? / 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 g). 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: ?php if($DB_a ==y) { $checked=checked; } else { $checked=; } ? input type=checkbox name=R_a value=y ?php echo $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 -- +--- 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
nice! but to avoid confusion it should read (assuming that $checked is a boolean variable): input type=hidden name=foo value=0/ input type=checkbox name=foo value=1?php if($checked) echo ' checked'; ?/ 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: input type=hidden name=foo value=0 / input type=checkbox name=foo value=1 ?php echo $checked; ? / 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 g). 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: ?php if($DB_a ==y) { $checked=checked; } else { $checked=; } ? input type=checkbox name=R_a value=y ?php echo $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
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: input type=hidden name=foo value=0 / input type=checkbox name=foo value=1 ?php echo $checked; ? / 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 g). 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: ?php if ($foo) echo('checked'); ? 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
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
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: input type=hidden name=foo value=0 / input type=checkbox name=foo value=1 ?php echo $checked; ? / 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 g). 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: ?php if ($foo) echo('checked'); ? 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. input type=checkbox name=likes_pie / When it's submitted: ?php if ($_GET['likes_pie']) // checked else // not -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Join question
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
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
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
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. input type=checkbox name=likes_pie / When it's submitted: ?php if ($_GET['likes_pie']) // checked else // not 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
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
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
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
-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
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/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/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
At 8:56 PM -0300 12/2/07, Martin Alterisio wrote: 2007/12/2, tedd mailto:[EMAIL PROTECTED][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
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
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