php-general Digest 12 Jan 2010 05:08:45 -0000 Issue 6534

2010-01-11 Thread php-general-digest-help

php-general Digest 12 Jan 2010 05:08:45 - Issue 6534

Topics (messages 300992 through 301012):

Re: To add the final ? or not...
300992 by: Bipper Goes!

Re: Formatting Decimals
300993 by: Rick Dwyer
300996 by: Paul M Foster
301002 by: tedd
301005 by: Rick Dwyer
301007 by: Mattias Thorslund
301008 by: Adam Richardson
301009 by: Paul M Foster

test
300994 by: LAMP
300995 by: LAMP
300997 by: Daniel Brown
300998 by: LAMP

Count the Number of Certain Elements in An Array
300999 by: Alice Wei
301000 by: Jonathan Tapicer
301001 by: Alice Wei

corect way to use mail() function
301003 by: LAMP
301004 by: Daevid Vincent
301010 by: Paul M Foster
301011 by: Daevid Vincent
301012 by: Angus Mann

Re: Clean PHP 5.2.12 Build Core Dumping / Can't Build Port - FreeBSD 6.1
301006 by: Don O'Neil

Administrivia:

To subscribe to the digest, e-mail:
php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
php-gene...@lists.php.net


--
---BeginMessage---
Ever write a string replace function on a closing ? //somecomment here like
end junk

I have written some systems and gone back two to three years later and found
myself having to do such.  Sloppy, sure.  Minimize cost to the client?  Oh
yeah.

I keep em, and comment 'em as I feel I should.

On Mon, Jan 11, 2010 at 2:24 AM, Olav olav...@xs4all.nl wrote:

 Paul M Foster wrote:

  I leave it off. I don't want to have to worry about which editor I'm
  using or whether I accidentally left some whitespace where it shouldn't
  be.

 I also use different editors in different situations, both terminal based
 and GUI. For instance I find Midnight Commander's internal editor quite
 comfortable to use but unfortunately it does leave whitespace all over
 the place.

 This discussion made me think. From now on, I will probably also leave
 the closing ? off in include files. If something isn't really needed
 then there is no rational reason to insist on using it.


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


---End Message---
---BeginMessage---

I have been asked to further modify the value to the nearest half cent.

So if the 3rd decimal spot ends in 1 or 2, it gets rounded down to 0
If it ends in 3, 4, 5, 6 it gets rounded to 5.  And if it 7, 8 or 9 it  
gets rounded up to full cents.


Can this be done fairly easily?  Not knowing PHP well, I am not aware  
of the logic to configure this accordingly.


Thanks,
--Rick




On Jan 11, 2010, at 10:55 AM, Ryan Sun wrote:


$newprice =  sprintf($%.2f, 15.109);

On Sun, Jan 10, 2010 at 8:36 PM, Rick Dwyer rpdw...@earthlink.net  
wrote:

Hello List.

Probably an easy question, but I am not able to format a number to  
round up from 3 numbers after the decimal to just 2.


My code looks like this:

$newprice = $.number_format($old_price, 2, ., ,);

and this returns $0.109 when I am looking for $0.11.


I tried:

$newprice = $.round(number_format($old_price, 2, ., ,),2);
But no luck.

Any help is appreciated.

Thanks,

 --Rick



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





 --Rick


---End Message---
---BeginMessage---
On Mon, Jan 11, 2010 at 02:55:33PM -0500, Rick Dwyer wrote:

 I have been asked to further modify the value to the nearest half cent.

 So if the 3rd decimal spot ends in 1 or 2, it gets rounded down to 0
 If it ends in 3, 4, 5, 6 it gets rounded to 5.  And if it 7, 8 or 9 it
 gets rounded up to full cents.

 Can this be done fairly easily?  Not knowing PHP well, I am not aware
 of the logic to configure this accordingly.

Yes, this can be done, but you'll need to write a function to do it
yourself. I'd also suggest you look into the BCMath functions, at:

http://us2.php.net/manual/en/book.bc.php

Paul

-- 
Paul M. Foster
---End Message---
---BeginMessage---

At 2:55 PM -0500 1/11/10, Rick Dwyer wrote:

I have been asked to further modify the value to the nearest half cent.

So if the 3rd decimal spot ends in 1 or 2, it gets rounded down to 0
If it ends in 3, 4, 5, 6 it gets rounded to 5.  And if it 7, 8 or 9 
it gets rounded up to full cents.


Can this be done fairly easily?  Not knowing PHP well, I am not 
aware of the logic to configure this accordingly.


Thanks,
--Rick



--Rick:

The above described rounding algorithm introduces more bias than 
simply using PHP's round() function, which always rounds down. IMO, 
modifying rounding is not worth the effort.


The best rounding algorithm is to look at the last digit and do this:

0 -- no rounding needed.
1-4 round down.
6-9 round up.

In the case of 5, then look to the number that precedes it -- 

Re: [PHP] POLL: To add the final ? or not...

2010-01-11 Thread Olav
Paul M Foster wrote:

 I leave it off. I don't want to have to worry about which editor I'm
 using or whether I accidentally left some whitespace where it shouldn't
 be.

I also use different editors in different situations, both terminal based 
and GUI. For instance I find Midnight Commander's internal editor quite 
comfortable to use but unfortunately it does leave whitespace all over 
the place.

This discussion made me think. From now on, I will probably also leave 
the closing ? off in include files. If something isn't really needed 
then there is no rational reason to insist on using it.


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



[PHP] htmlMicroscope 1.2.0 out - much better than 1.1.0

2010-01-11 Thread Rene Veerman
Check it out at http://mediabeez.ws/htmlMicroscope

Last modified   Mon, 11 Jan 2010, 13:00 UTC+0100
Latest changes: 

* Javascript hm() support added
* Added ability to view HTML strings as rendered HTML.
  I admit there are still problems with some HTML taking over the
browser as soon as viewed in rendered form.
  I hope to fix most of those problems in a later release.
* Added ability to put semi-binary data (see All Ascii in
random array example) in values.
* Much improved CSS; it's now properly generated in javascript
instead of badly hand-crafted  stored on the server.
  Themes are now generated from definitions like these:

  ( please use hms.tools.addTheme(contributerName, themeName,
theme) to add a theme, and load them just after hm.js is loaded. var
theme = renesIce)

  options : {
  ..
  authorsDefaults : {
themes : {
...
,renesIce : {
themeName : 'renesIce',
cssGeneration : {
  colorLevels : {
// This sets stops for color gradients.
// 0 = outer level of display,
//   100 = deepest level of display.

0 : {
background : 'navy',
color : '#FF'
},
45 : {
color : 'black'
},
75 : {
background : 'lime',
color : 'navy'
},
100 : {
background : 'white',
color : 'black'
}
//Rules:
// 1: only css COLOR properties allowed here.
//  color names allowed, for a list see
http://www.w3schools.com/css/css_colornames.asp
// 2: properties used anywhere in a list like this must be
present in both 0: and 100:
  }
},
..


License:LGPL

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



[PHP] I am not receiving any e-mail from the list...

2010-01-11 Thread Jay Blanchard
..and I haven't for a while. Is anyone else having this problem? If you
are you will not see this.

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



Re: [PHP] I am not receiving any e-mail from the list...

2010-01-11 Thread metastable
Jay Blanchard wrote:
 ..and I haven't for a while. Is anyone else having this problem? If you
 are you will not see this.

   
If they are, how can they wonder if they have this problem ?



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



RE: [PHP] I am not receiving any e-mail from the list...

2010-01-11 Thread Jay Blanchard
[snip]
Jay Blanchard wrote:
 ..and I haven't for a while. Is anyone else having this problem? If
you
 are you will not see this.

   
If they are, how can they wonder if they have this problem ?
[/snip]

exactly

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



Re: [PHP] Upgraded PHP now website doesn't work properly?

2010-01-11 Thread Ashley Sheridan
On Mon, 2010-01-11 at 03:27 +0200, Kaya Saman wrote:

 
 
  Depending on the latency and bandwidth you could use X11 forwarding 
  (granted the server supports it) so you could use a non-CLI editor. I 
  think joe has some syntax highlighting, but I've never edited PHP 
  files with it.
  If you are coming from a windows machine, you can use Cygwin or Xming 
  to set up an X server on the box before SSHing to your data center 
  w/X11 forwarding enabled.
 
  -Ken Sande
 Many thanks to everyone!
 
 I currently use a mixture of FreeBSD, Linux, and Solaris/OpenSolaris as 
 operating systems so X11 forwarding is not a problem but maybe quite 
 slow considering the distance between me and my data center right now, 
 and also I have only 1Mbps upstream as the data center uses ADSL which 
 is a restriction on my behalf.
 
 Am using SFTP to transfer non-html related stuff and using simple nano 
 or copy-paste from the Gnome terminal.
 
 Yeah many options available I know and I guess that's what makes things 
 fun :-)
 
 Anyway I'm sure I'll work something out, at worst case I could always 
 VPN once I get a Cisco router out here and get an IPsec tunnel going and 
 do things over NFS mount??
 
 Regards,
 
 Kaya


I never bother with X-forwarding for development work, it is too slow I
agree. I use Konqueror to connect as an FTP client, as it works really
well as a file manager with the split screen views it has. From there, I
can manage most of my files as I wish over sftp as if they were local.
The only thing I can't do it edit the graphics files with Gimp, as that
doesn't use KDE's kioslaves :(

Thanks,
Ash
http://www.ashleysheridan.co.uk




RE: [PHP] Upgraded PHP now website doesn't work properly?

2010-01-11 Thread Bob McConnell
From: Kaya Saman

 I also forgot to mention, it's worth getting an editor that comes
with 
 syntax highlighting, as this would have shown you the problem right
away.

 Thanks for both comments Ashley!
 
 I will attempt it now. An editor with syntax checking?? Currently my 
 data center is in the UK and I am in Turkey so am having to SSH in and

 my current text editor is nano. Are there any good CLI based editors 
 that will do highlighting something hopefully not in the vi/vim 
 categories as I really don't get on with them!

When working in a shell, I always use joe (Joe's Own Editor). But my
first word processor was WordStar, so those keystrokes come naturally.
People who learned on newer programs probably won't have the same
experience.

Bob McConnell

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



[PHP] Easy Eclipse PHP Problem

2010-01-11 Thread tedd

Hi gang:

I recently installed MAPA on my new system (Mac X 10.6.2) to use use 
Eclipse and PHP 5.


The EasyEclipse for PHP download is located at:

http://www.easyeclipse.org/site/distributions/php.html

However, the installation fails.

I posted an error report, but there are other reports that date 
months back. Does anyone have the ear of any developers who work on 
this open source project? Until that bug is fixed, my new system sits 
idle.


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] Upgraded PHP now website doesn't work properly?

2010-01-11 Thread Kaya Saman

Bob McConnell wrote:

From: Kaya Saman
  

I also forgot to mention, it's worth getting an editor that comes
  
with 
  

syntax highlighting, as this would have shown you the problem right
  

away.
  

Thanks for both comments Ashley!

I will attempt it now. An editor with syntax checking?? Currently my 
data center is in the UK and I am in Turkey so am having to SSH in and



  
my current text editor is nano. Are there any good CLI based editors 
that will do highlighting something hopefully not in the vi/vim 
categories as I really don't get on with them!



When working in a shell, I always use joe (Joe's Own Editor). But my
first word processor was WordStar, so those keystrokes come naturally.
People who learned on newer programs probably won't have the same
experience.

Bob McConnell

  


Thanks for so much support guys!

I've just compiled Emacs 23 on OpenSolaris and also installed Bluefish 
from the package repo.


Emacs has something called flymake which I enabled but it didn't find 
any errors??


My site I think is up and running again but the central menu is really 
messed up and not sure why that is. Of course it doesn't help being a 
network and UNIX engineer as web design is a completely different ball-game!


--K

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



Re: [PHP] Upgraded PHP now website doesn't work properly?

2010-01-11 Thread Ashley Sheridan
On Mon, 2010-01-11 at 16:21 +0200, Kaya Saman wrote:

 Bob McConnell wrote:
  From: Kaya Saman

  I also forgot to mention, it's worth getting an editor that comes

  with 

  syntax highlighting, as this would have shown you the problem right

  away.

  Thanks for both comments Ashley!
 
  I will attempt it now. An editor with syntax checking?? Currently my 
  data center is in the UK and I am in Turkey so am having to SSH in and
  
 

  my current text editor is nano. Are there any good CLI based editors 
  that will do highlighting something hopefully not in the vi/vim 
  categories as I really don't get on with them!
  
 
  When working in a shell, I always use joe (Joe's Own Editor). But my
  first word processor was WordStar, so those keystrokes come naturally.
  People who learned on newer programs probably won't have the same
  experience.
 
  Bob McConnell
 

 
 Thanks for so much support guys!
 
 I've just compiled Emacs 23 on OpenSolaris and also installed Bluefish 
 from the package repo.
 
 Emacs has something called flymake which I enabled but it didn't find 
 any errors??
 
 My site I think is up and running again but the central menu is really 
 messed up and not sure why that is. Of course it doesn't help being a 
 network and UNIX engineer as web design is a completely different ball-game!
 
 --K
 


Get the Firefox addon called Firebug. It shows you what CSS is being
applied to each element, and lets you edit things temporarily to see
what would happen.

Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] Upgraded PHP now website doesn't work properly?

2010-01-11 Thread Robert Cummings

Bob McConnell wrote:

From: Kaya Saman

I also forgot to mention, it's worth getting an editor that comes
with 

syntax highlighting, as this would have shown you the problem right

away.

Thanks for both comments Ashley!

I will attempt it now. An editor with syntax checking?? Currently my 
data center is in the UK and I am in Turkey so am having to SSH in and


my current text editor is nano. Are there any good CLI based editors 
that will do highlighting something hopefully not in the vi/vim 
categories as I really don't get on with them!


When working in a shell, I always use joe (Joe's Own Editor). But my
first word processor was WordStar, so those keystrokes come naturally.
People who learned on newer programs probably won't have the same
experience.


Woohoo!!! A fellow JOE user :)

Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP

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



Re: [PHP] Upgraded PHP now website doesn't work properly?

2010-01-11 Thread Michael A. Peters

Ashley Sheridan wrote:




I never bother with X-forwarding for development work, it is too slow I
agree.


My development box is a Dell Optiplex G50 I found discarded in an 
illegal trash pile. Hard drive was bad, I had a spare. Heat sink was 
dislodged, I had thermal paste. CDROM is not reliable, but reliable 
enough to boot off of a 4MB CentOS boot.iso and network install. Video 
gives snow, but after install, it's headless so who cares.


It's been problem free for a couple months now (found it a couple months 
ago). Only thing I had to purchase was a mouse for install - as I don't 
have a spare and didn't feel like detaching a mouse from an existing 
computer.


I installed bluefish on it and use bluefish over ssh via x forwarding on 
my local lan and sometimes have the bluefish window open for days. When 
I'm ready to publish to live, I simple ssh in and rsync to live. Never 
had a slowness problem.


It's an old crap computer, ram limit of 512MB (currently has 384 in it), 
but having the devel box local makes things like X forwarded a GUI text 
editor cake w/o performance issues.


I use Ubuntu for my desktop, no server crap installed on it, I prefer 
CentOS for serving - so this a cheap crap local box for devel server is 
the perfect solution. Since I'm the only user, the low performance of 
the CPU/Intel i815 chipset really isn't an issue (I think the mobo was 
swapped at some point, Dell website indicates i810 but it has i815).


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



RE: [PHP] Form validation and save the form

2010-01-11 Thread Angelo Zanetti


-Original Message-
From: aditya shukla [mailto:adityashukla1...@gmail.com] 
Sent: 11 January 2010 07:37 AM
To: php-general
Subject: [PHP] Form validation and save the form

Hello Guys,

I am trying to validate a form for user input , such that when something is
missing load the form again by focusing on the  wrong field.Say i don not
enter my address so when the form loads everything else is saved and the
form points to address field.

Thanks

Aditya

You need Javascript for that not PHP. PHP is server side, javascript is
client side (browser).

Regards
Angelo 
http://www.elemental.co.za
http://www.wapit.co.za




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



Re: [PHP] Form validation and save the form

2010-01-11 Thread Robert Cummings

Angelo Zanetti wrote:


-Original Message-
From: aditya shukla [mailto:adityashukla1...@gmail.com] 
Sent: 11 January 2010 07:37 AM

To: php-general
Subject: [PHP] Form validation and save the form

Hello Guys,

I am trying to validate a form for user input , such that when something is
missing load the form again by focusing on the  wrong field.Say i don not
enter my address so when the form loads everything else is saved and the
form points to address field.

Thanks

Aditya

You need Javascript for that not PHP. PHP is server side, javascript is
client side (browser).


He doesn't say anything about not reloading the form... in fact he 
explicitly says when something is missing load the form again. This 
suggests a server request and not JavaScript. Either way... validation 
can occur either in JavaScript or PHP... but it should ALWAYS occur in 
PHP regardless of any JavaScript validation.


Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP

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



Re: [PHP] Upgraded PHP now website doesn't work properly?

2010-01-11 Thread Kaya Saman




My development box is a Dell Optiplex G50 I found discarded in an 
illegal trash pile. Hard drive was bad, I had a spare. Heat sink was 
dislodged, I had thermal paste. CDROM is not reliable, but reliable 
enough to boot off of a 4MB CentOS boot.iso and network install. Video 
gives snow, but after install, it's headless so who cares.


It's been problem free for a couple months now (found it a couple 
months ago). Only thing I had to purchase was a mouse for install - as 
I don't have a spare and didn't feel like detaching a mouse from an 
existing computer.


I installed bluefish on it and use bluefish over ssh via x forwarding 
on my local lan and sometimes have the bluefish window open for days. 
When I'm ready to publish to live, I simple ssh in and rsync to live. 
Never had a slowness problem.


It's an old crap computer, ram limit of 512MB (currently has 384 in 
it), but having the devel box local makes things like X forwarded a 
GUI text editor cake w/o performance issues.


I use Ubuntu for my desktop, no server crap installed on it, I prefer 
CentOS for serving - so this a cheap crap local box for devel server 
is the perfect solution. Since I'm the only user, the low performance 
of the CPU/Intel i815 chipset really isn't an issue (I think the mobo 
was swapped at some point, Dell website indicates i810 but it has i815).


Thanks for that info I do admit that old computers do make the coolest 
machines especially home servers and when running something like FreeBSD 
they end up being awsome!


However we were talking about SSH over continents not local LAN! With 
local LAN you get round 100Mbps unless really old in which case you 
would get 10Mbps half duplex. This is no way an issue when in such close 
proximity. I however am round 3500 km's away at the moment from my web 
server and the internet connection I am getting is really poor as it 
locks up quite a bit and I end up with failed routes between my PoP 
(point of presence) server or the countries main gateway.


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



Re: [PHP] Form validation and save the form

2010-01-11 Thread aditya shukla
Thanks for the reply guys.Do you guys know a good resource where i can read
from about form validation through PHP.There a lot on google but please
suggest something if you guys know.


Thanks

Aditya


Re: [PHP] I am not receiving any e-mail from the list...

2010-01-11 Thread Richard
Hi,

 ...

I had this (I think) recently; mail simply stopped coming from the
list and I can't remember unsubscribing (though that's not saying
much...). I simply re-subscribed and all was dandy again.

--
Richard Heyes
HTML5 canvas graphing: RGraph - http://www.rgraph.net (updated 9th January)
Lots of PHP and Javascript code - http://www.phpguru.org

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



Re: [PHP] I am not receiving any e-mail from the list...

2010-01-11 Thread Daniel Brown
On Mon, Jan 11, 2010 at 10:10, Richard rich...@php.net wrote:

 I had this (I think) recently; mail simply stopped coming from the
 list and I can't remember unsubscribing (though that's not saying
 much...). I simply re-subscribed and all was dandy again.

Quite possibly caused by malformed headers or SPAM being rejected
by the filters and bounced back to the list.  Two bounces and a tracer
is sent.  If that fails as well (and they usually do), you're
unsubscribed without further notice.  It happens to me all the time on
the Windows list (now that I think about it, I think it happened
again).

-- 
/Daniel P. Brown
daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
Looking for hosting or dedicated servers?  Ask me how we can fit your budget!

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



RE: [PHP] Form validation and save the form

2010-01-11 Thread Angelo Zanetti


-Original Message-
From: aditya shukla [mailto:adityashukla1...@gmail.com] 
Sent: 11 January 2010 05:03 PM
To: Robert Cummings
Cc: Angelo Zanetti; php-general
Subject: Re: [PHP] Form validation and save the form

Thanks for the reply guys.Do you guys know a good resource where i can read
from about form validation through PHP.There a lot on google but please
suggest something if you guys know.


Thanks

Aditya

I think just do some form validation tutorials (google for them).
These will help you to understand the validation process in more detail.

Regards
Angelo
http://www.elemental.co.za
http://www.wapit.co.za



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



Re: [PHP] I am not receiving any e-mail from the list...

2010-01-11 Thread Ashley Sheridan
On Mon, 2010-01-11 at 10:17 -0500, Daniel Brown wrote:

 On Mon, Jan 11, 2010 at 10:10, Richard rich...@php.net wrote:
 
  I had this (I think) recently; mail simply stopped coming from the
  list and I can't remember unsubscribing (though that's not saying
  much...). I simply re-subscribed and all was dandy again.
 
 Quite possibly caused by malformed headers or SPAM being rejected
 by the filters and bounced back to the list.  Two bounces and a tracer
 is sent.  If that fails as well (and they usually do), you're
 unsubscribed without further notice.  It happens to me all the time on
 the Windows list (now that I think about it, I think it happened
 again).
 
 -- 
 /Daniel P. Brown
 daniel.br...@parasane.net || danbr...@php.net
 http://www.parasane.net/ || http://www.pilotpig.net/
 Looking for hosting or dedicated servers?  Ask me how we can fit your budget!
 


All my mails were rejected from the list a couple of weeks ago, because
my hosting had found its way onto a blacklist, which they vehemently
denied until I pointed it out to them.

Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] I am not receiving any e-mail from the list...

2010-01-11 Thread Richard
Hi,

 ...

It's not a problem at all,  it just takes me a few months to realise... :-)

-- 
Richard Heyes
HTML5 canvas graphing: RGraph - http://www.rgraph.net (updated 9th January)
Lots of PHP and Javascript code - http://www.phpguru.org

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



Re: [PHP] Upgraded PHP now website doesn't work properly?

2010-01-11 Thread Michael A. Peters

Kaya Saman wrote:






Thanks for that info I do admit that old computers do make the coolest 
machines especially home servers and when running something like FreeBSD 
they end up being awsome!


However we were talking about SSH over continents not local LAN! With 
local LAN you get round 100Mbps unless really old in which case you 
would get 10Mbps half duplex. This is no way an issue when in such close 
proximity. I however am round 3500 km's away at the moment from my web 
server and the internet connection I am getting is really poor as it 
locks up quite a bit and I end up with failed routes between my PoP 
(point of presence) server or the countries main gateway.




But what you can do is keep your dev box local, and then use rsync over 
ssh to publish to the production (or dev) server that is across ocean(s).


I use .devel as my TLD for my dev hosts (IE www.something.devel) but 
otherwise have the dev box configured identical to the production 
server, so that if it works on dev box I know it works on production.


Other thing I do, cron job on production dumps the database once a 
night, cron job on dev fetches it (via rsync over ssh w/ keys) and 
applies it to dev database so that the dev database is always very close 
to production database.


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



Re: [PHP] Formatting Decimals

2010-01-11 Thread Ryan Sun
$newprice =  sprintf($%.2f, 15.109);

On Sun, Jan 10, 2010 at 8:36 PM, Rick Dwyer rpdw...@earthlink.net wrote:

 Hello List.

 Probably an easy question, but I am not able to format a number to round up
 from 3 numbers after the decimal to just 2.

 My code looks like this:

 $newprice = $.number_format($old_price, 2, ., ,);

 and this returns $0.109 when I am looking for $0.11.


 I tried:

 $newprice = $.round(number_format($old_price, 2, ., ,),2);
 But no luck.

 Any help is appreciated.

 Thanks,

  --Rick



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




Re: [PHP] Form validation and save the form

2010-01-11 Thread Bastien Koert
On Mon, Jan 11, 2010 at 10:18 AM, Angelo Zanetti ang...@zlogic.co.za wrote:


 -Original Message-
 From: aditya shukla [mailto:adityashukla1...@gmail.com]
 Sent: 11 January 2010 05:03 PM
 To: Robert Cummings
 Cc: Angelo Zanetti; php-general
 Subject: Re: [PHP] Form validation and save the form

 Thanks for the reply guys.Do you guys know a good resource where i can read
 from about form validation through PHP.There a lot on google but please
 suggest something if you guys know.


 Thanks

 Aditya

 I think just do some form validation tutorials (google for them).
 These will help you to understand the validation process in more detail.

 Regards
 Angelo
 http://www.elemental.co.za
 http://www.wapit.co.za



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




I still like

?php

// includes go here

if(isset($_POST['submit'])){
  process_form();
}else{
  show_form();
}//end if

function process_form()
{
//receive the data, validate and store the data in the db goes here
//feel free to add more functions that you could re-use in other parts
//of the app


}

function show_form($data='', $errors='')
{
//code to show the form goes here
//$data and $errors could be passed in from the above function if
//there are issues with the data validation (no image, data missing etc)


}

for simple pages. Its a mini MVC where the code could post the data
back to the form with error message to indicate to the user what
should be done.
-- 

Bastien

Cat, the other other white meat

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



Re: [PHP] I am not receiving any e-mail from the list...

2010-01-11 Thread Bastien Koert
On Mon, Jan 11, 2010 at 10:17 AM, Daniel Brown danbr...@php.net wrote:
 On Mon, Jan 11, 2010 at 10:10, Richard rich...@php.net wrote:

 I had this (I think) recently; mail simply stopped coming from the
 list and I can't remember unsubscribing (though that's not saying
 much...). I simply re-subscribed and all was dandy again.

    Quite possibly caused by malformed headers or SPAM being rejected
 by the filters and bounced back to the list.  Two bounces and a tracer
 is sent.  If that fails as well (and they usually do), you're
 unsubscribed without further notice.  It happens to me all the time on
 the Windows list (now that I think about it, I think it happened
 again).

 --
 /Daniel P. Brown
 daniel.br...@parasane.net || danbr...@php.net
 http://www.parasane.net/ || http://www.pilotpig.net/
 Looking for hosting or dedicated servers?  Ask me how we can fit your budget!

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



Windows, still not ready for the desktop!

-- 

Bastien

Cat, the other other white meat

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



Re: [PHP] Upgraded PHP now website doesn't work properly?

2010-01-11 Thread Kaya Saman







But what you can do is keep your dev box local, and then use rsync 
over ssh to publish to the production (or dev) server that is across 
ocean(s).


I use .devel as my TLD for my dev hosts (IE www.something.devel) but 
otherwise have the dev box configured identical to the production 
server, so that if it works on dev box I know it works on production.


Other thing I do, cron job on production dumps the database once a 
night, cron job on dev fetches it (via rsync over ssh w/ keys) and 
applies it to dev database so that the dev database is always very 
close to production database.



Thanks for the tip! It isn't really a necessity as I'm not a web 
developer - I just built my site from scratch that's all as I don't have 
any developer friends who can help me out since I'm not an established 
company yet..


Usually I just sftp a tar'ed folder or files into my home dir if I need 
anything or do work on the fly.


I really need to learn rsync though as I managed to accomplish transfers 
of it once but never again :-( It is especially useful for backing up 
machines!


Regards,

Kaya

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



Re: [PHP] SVG and PHP

2010-01-11 Thread haliphax
On Wed, Jan 6, 2010 at 5:04 PM, Bob Strasser bstras...@noccorp.com wrote:


 Hi,

  Just went online and saw an SVG generated from Python, and wanted to
 do the similar thing by loading the SVG into an PHP script. Here is the
 script that I have:

 ?php

 #Load the Map
 $ourFileName= USA_Counties_with_FIPS_and_names.svg;
 $fh = fopen($ourFileName, r) or die(Can't open file);
 fclose($fh);

 ?

 The problem is that my screen appears as blank even though I could open
 up USA_Counties_with_FIPS_and_names.svg and see the entire US Map. Does
 anyone know what I might have done wrong here?

 Thanks in advance.

 Alice


Bob/Alice/Whatever,

You don't do anything with the SVG file except open it and close it. Opening
and closing a door doesn't walk you through the doorway. Maybe you should
echo the contents of said file after sending a Content-Type header through
to the browser?


// Todd


Re: [PHP] POLL: To add the final ? or not...

2010-01-11 Thread Bipper Goes!
Ever write a string replace function on a closing ? //somecomment here like
end junk

I have written some systems and gone back two to three years later and found
myself having to do such.  Sloppy, sure.  Minimize cost to the client?  Oh
yeah.

I keep em, and comment 'em as I feel I should.

On Mon, Jan 11, 2010 at 2:24 AM, Olav olav...@xs4all.nl wrote:

 Paul M Foster wrote:

  I leave it off. I don't want to have to worry about which editor I'm
  using or whether I accidentally left some whitespace where it shouldn't
  be.

 I also use different editors in different situations, both terminal based
 and GUI. For instance I find Midnight Commander's internal editor quite
 comfortable to use but unfortunately it does leave whitespace all over
 the place.

 This discussion made me think. From now on, I will probably also leave
 the closing ? off in include files. If something isn't really needed
 then there is no rational reason to insist on using it.


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




Re: [PHP] Formatting Decimals

2010-01-11 Thread Rick Dwyer

I have been asked to further modify the value to the nearest half cent.

So if the 3rd decimal spot ends in 1 or 2, it gets rounded down to 0
If it ends in 3, 4, 5, 6 it gets rounded to 5.  And if it 7, 8 or 9 it  
gets rounded up to full cents.


Can this be done fairly easily?  Not knowing PHP well, I am not aware  
of the logic to configure this accordingly.


Thanks,
--Rick




On Jan 11, 2010, at 10:55 AM, Ryan Sun wrote:


$newprice =  sprintf($%.2f, 15.109);

On Sun, Jan 10, 2010 at 8:36 PM, Rick Dwyer rpdw...@earthlink.net  
wrote:

Hello List.

Probably an easy question, but I am not able to format a number to  
round up from 3 numbers after the decimal to just 2.


My code looks like this:

$newprice = $.number_format($old_price, 2, ., ,);

and this returns $0.109 when I am looking for $0.11.


I tried:

$newprice = $.round(number_format($old_price, 2, ., ,),2);
But no luck.

Any help is appreciated.

Thanks,

 --Rick



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





 --Rick



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



[PHP] test

2010-01-11 Thread LAMP

sorry for this - previous email didn't get through?!!?!?

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



Re: [PHP] test

2010-01-11 Thread LAMP

I tried again and got this error message:

Hi. This is the qmail-send program at outbound-mail-319.bluehost.com.
I'm afraid I wasn't able to deliver your message to the following addresses.
This is a permanent error; I've given up. Sorry it didn't work out.

php-general@lists.php.net:
76.75.200.58 failed after I sent the message.
Remote host said: 550 we're manly enough already


?!?!?!!??!






--- Enclosed are the original headers of the message.



LAMP wrote:

sorry for this - previous email didn't get through?!!?!?




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



Re: [PHP] Formatting Decimals

2010-01-11 Thread Paul M Foster
On Mon, Jan 11, 2010 at 02:55:33PM -0500, Rick Dwyer wrote:

 I have been asked to further modify the value to the nearest half cent.

 So if the 3rd decimal spot ends in 1 or 2, it gets rounded down to 0
 If it ends in 3, 4, 5, 6 it gets rounded to 5.  And if it 7, 8 or 9 it
 gets rounded up to full cents.

 Can this be done fairly easily?  Not knowing PHP well, I am not aware
 of the logic to configure this accordingly.

Yes, this can be done, but you'll need to write a function to do it
yourself. I'd also suggest you look into the BCMath functions, at:

http://us2.php.net/manual/en/book.bc.php

Paul

-- 
Paul M. Foster

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



Re: [PHP] test

2010-01-11 Thread Daniel Brown
On Mon, Jan 11, 2010 at 15:52, LAMP l...@afan.net wrote:
 I tried again and got this error message:

 Hi. This is the qmail-send program at outbound-mail-319.bluehost.com.
 I'm afraid I wasn't able to deliver your message to the following addresses.
 This is a permanent error; I've given up. Sorry it didn't work out.

 php-general@lists.php.net:
 76.75.200.58 failed after I sent the message.
 Remote host said: 550 we're manly enough already

Sounds like a subscriber's mail server bounced your list message
because it thought it was SPAM.  Nothing to worry about your email
came through.

For the future, when unsure about list messages, check
http://news.php.net/php.general/ .

-- 
/Daniel P. Brown
daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
Looking for hosting or dedicated servers?  Ask me how we can fit your budget!

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



Re: [PHP] test

2010-01-11 Thread LAMP

Daniel Brown wrote:

On Mon, Jan 11, 2010 at 15:52, LAMP l...@afan.net wrote:
  

I tried again and got this error message:

Hi. This is the qmail-send program at outbound-mail-319.bluehost.com.
I'm afraid I wasn't able to deliver your message to the following addresses.
This is a permanent error; I've given up. Sorry it didn't work out.

php-general@lists.php.net:
76.75.200.58 failed after I sent the message.
Remote host said: 550 we're manly enough already



Sounds like a subscriber's mail server bounced your list message
because it thought it was SPAM.  Nothing to worry about your email
came through.

For the future, when unsure about list messages, check
http://news.php.net/php.general/ .


But I still can't send my question!?! :-)


LL


[PHP] Count the Number of Certain Elements in An Array

2010-01-11 Thread Alice Wei

Hi, 

  This seems like a pretty simple problem, but I can't seem to be able to 
figure it out. I have a lot of elements in an array, and some of them are 
duplicates, but I don't want to delete them because I have other purposes for 
it. Is it possible for me to find out the number of certain elements in an 
array? 

  For example, 

   // Create a simple array.
   $array = array(1, 2, 3, 4, 5, 3,3,4,2);
   $total = count($array);
   echo $total;
  
  If I run the code, the value of $total would be 9. However, what I really 
want to do is to get the values of the different instances of each, like:

   1 = 1
   2 = 2
   3 = 3
   4=  2
   5=  1

Is there a simple code that I use to find this out? 

Thanks for your help. 

Alice
  
_
Hotmail: Trusted email with powerful SPAM protection.
http://clk.atdmt.com/GBL/go/196390707/direct/01/

Re: [PHP] Count the Number of Certain Elements in An Array

2010-01-11 Thread Jonathan Tapicer
On Mon, Jan 11, 2010 at 6:21 PM, Alice Wei aj...@alumni.iu.edu wrote:

 Hi,

  This seems like a pretty simple problem, but I can't seem to be able to 
 figure it out. I have a lot of elements in an array, and some of them are 
 duplicates, but I don't want to delete them because I have other purposes for 
 it. Is it possible for me to find out the number of certain elements in an 
 array?

  For example,

   // Create a simple array.
   $array = array(1, 2, 3, 4, 5, 3,3,4,2);
   $total = count($array);
   echo $total;

  If I run the code, the value of $total would be 9. However, what I really 
 want to do is to get the values of the different instances of each, like:

   1 = 1
   2 = 2
   3 = 3
   4=  2
   5=  1

 Is there a simple code that I use to find this out?

 Thanks for your help.

 Alice

 _
 Hotmail: Trusted email with powerful SPAM protection.
 http://clk.atdmt.com/GBL/go/196390707/direct/01/


Hi,

Try the function array_count_values.

Regards,

Jonathan

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



RE: [PHP] Count the Number of Certain Elements in An Array

2010-01-11 Thread Alice Wei

 Date: Mon, 11 Jan 2010 18:31:43 -0300
 Subject: Re: [PHP] Count the Number of Certain Elements in An Array
 From: tapi...@gmail.com
 To: aj...@alumni.iu.edu
 CC: php-general@lists.php.net
 
 On Mon, Jan 11, 2010 at 6:21 PM, Alice Wei aj...@alumni.iu.edu wrote:
 
  Hi,
 
   This seems like a pretty simple problem, but I can't seem to be able to 
  figure it out. I have a lot of elements in an array, and some of them are 
  duplicates, but I don't want to delete them because I have other purposes 
  for it. Is it possible for me to find out the number of certain elements in 
  an array?
 
   For example,
 
// Create a simple array.
$array = array(1, 2, 3, 4, 5, 3,3,4,2);
$total = count($array);
echo $total;
 
   If I run the code, the value of $total would be 9. However, what I really 
  want to do is to get the values of the different instances of each, like:
 
1 = 1
2 = 2
3 = 3
4=  2
5=  1
 
  Is there a simple code that I use to find this out?
 
  Thanks for your help.
 
  Alice
 
  _
  Hotmail: Trusted email with powerful SPAM protection.
  http://clk.atdmt.com/GBL/go/196390707/direct/01/
 
 
 Hi,
 
 Try the function array_count_values.
 
   Thanks, this is cool. There is already a function for it!

 Regards,
 
 Jonathan
  
_
Hotmail: Free, trusted and rich email service.
http://clk.atdmt.com/GBL/go/196390708/direct/01/

Re: [PHP] Formatting Decimals

2010-01-11 Thread tedd

At 2:55 PM -0500 1/11/10, Rick Dwyer wrote:

I have been asked to further modify the value to the nearest half cent.

So if the 3rd decimal spot ends in 1 or 2, it gets rounded down to 0
If it ends in 3, 4, 5, 6 it gets rounded to 5.  And if it 7, 8 or 9 
it gets rounded up to full cents.


Can this be done fairly easily?  Not knowing PHP well, I am not 
aware of the logic to configure this accordingly.


Thanks,
--Rick



--Rick:

The above described rounding algorithm introduces more bias than 
simply using PHP's round() function, which always rounds down. IMO, 
modifying rounding is not worth the effort.


The best rounding algorithm is to look at the last digit and do this:

0 -- no rounding needed.
1-4 round down.
6-9 round up.

In the case of 5, then look to the number that precedes it -- if it 
is even, then round up and if it is odd, then round down -- or vise 
versa, it doesn't make any difference as long as you are consistent.


Here are some examples:

122.4  -- round down (122)
122.6 -- round up (123)
122.5 -- round up (123)

123.4  -- round down (123)
123.6 -- round up (124)
123.5 -- round down (123)

There are people who claim that there's no difference, or are at odds 
with this method, but they simply have not investigated the problem 
sufficiently to see the bias that rounding up/down causes. However, 
that difference is very insignificant and can only be seen after tens 
of thousands iterations.  PHP's rounding function is quite sufficient.


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] corect way to use mail() function

2010-01-11 Thread LAMP

Hi,
The company I work for, hosts online events registration applications. 
After a registered registered himself for an event he will get a 
confirmation email saying he registered successfully.
Currently, in the header part of the mail(), in From it says e.g. 
ord...@computility.com - because the email comes from us not from our 
client (e.g. ABC Assoc.). Reply-to goes to us too.


Now one of our clients (e.g. ABC Assoc.) asks us to put in the from 
field their email, to looks like the email comes from them. something 
like: From: ABC Assoc. eve...@abcaccos.org;


I refused to do that concerned we are going to be blacklisted for 
sending spam. Because header shows one place and From field says other 
email address - spam way of sending emails.


Am I right or it really doesn't matter who sent the email?

LL




RE: [PHP] corect way to use mail() function

2010-01-11 Thread Daevid Vincent
 -Original Message-
 From: LAMP [mailto:l...@afan.net] 
 Sent: Monday, January 11, 2010 2:17 PM
 To: PHP-General List
 Subject: [PHP] corect way to use mail() function
 
 Hi,
 The company I work for, hosts online events registration 
 applications. 
 After a registered registered himself for an event he will get a 
 confirmation email saying he registered successfully.
 Currently, in the header part of the mail(), in From it says e.g. 
 ord...@computility.com - because the email comes from us not from our 
 client (e.g. ABC Assoc.). Reply-to goes to us too.
 
 Now one of our clients (e.g. ABC Assoc.) asks us to put in the from 
 field their email, to looks like the email comes from them. something 
 like: From: ABC Assoc. eve...@abcaccos.org;
 
 I refused to do that concerned we are going to be blacklisted for 
 sending spam. Because header shows one place and From field 
 says other 
 email address - spam way of sending emails.
 
 Am I right or it really doesn't matter who sent the email?
 
 LL

I do that sort of thing all the time and don't get RBL'd.

I think the key things are if your domain can be reverse verified, the
frequency you send (if you're just sending hundreds of emails out that's a
red flag), BCC: but no TO:, and if the content/body seems to be non-spammy.
Make sure any hyperlinks in the body are correct and non-spammy looking
too. A common phishing routine is to display one hyperlink to the user, but
the actual 'click' takes you somewhere else. I think doing one of those,
to register, click _here_ deals is WORSE (from an automated spam filter
POV) than showing the actual hyperlink and making it a hyperlink too. Ala,
to register, click http://www.abcaccos.org/register/fa4jar4875;. Avoid
sending HTML emails for registrations too. It has a better chance of
getting through and should have a disclaimer in it to 'whitelist this
sender' sort of dealio. Once they're setup, then you can work with HTML
emails, but you don't want to loose/frustrate customers right off the bat
by not letting them register properly despite how pretty you think the HTML
version looks.

I think you should 
[a] do what your client asks -- it's their money
[b] put in a From: that is representative of the site the user expected the
email to actually come from
[c] put a disclaimer on your web form for the person to add
ord...@computility.com and eve...@abcaccos.org to their whitelist
(no-spam filter)
[d] make the SUBJ: line of the email VERY explicit about WHO and WHAT this
is concerning:
ie SUBJ: Registration Confirmation from ABC Assoc. for username JDOE
requested

If I was a customer and got an email from @computility.com and I didn't
know who the heck they were, since I was expecting from @abcaccos.org, then
I would most likely delete it. I have an itchy trigger finger and tend to
delete first, ask questions later. ;-)


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



Re: [PHP] Formatting Decimals

2010-01-11 Thread Rick Dwyer


On Jan 11, 2010, at 4:56 PM, tedd wrote:


At 2:55 PM -0500 1/11/10, Rick Dwyer wrote:
I have been asked to further modify the value to the nearest half  
cent.


So if the 3rd decimal spot ends in 1 or 2, it gets rounded down to 0
If it ends in 3, 4, 5, 6 it gets rounded to 5.  And if it 7, 8 or 9  
it gets rounded up to full cents.


Can this be done fairly easily?  Not knowing PHP well, I am not  
aware of the logic to configure this accordingly.


Thanks,
--Rick



--Rick:

The above described rounding algorithm introduces more bias than  
simply using PHP's round() function, which always rounds down. IMO,  
modifying rounding is not worth the effort.


I understand what you are saying and I agree.  But the decision to  
round to half cents as outlined above is a client requirement, not  
mine (I did try to talk them out of it but no luck).


I come from an LDML environment, not a PHP one so I don't know the  
actual code to make this happen.  But the logic would be something like:


If 3 decimal than look at decimal in position 3.

If value = 1 or 2 set it to 0
If value = 3,4,5,6 round it to 5
If value = 7,8,9 round it to a full cent


Anybody have specific code examples to make this happen?

Thanks,

--Rick








The best rounding algorithm is to look at the last digit and do  
this:


0 -- no rounding needed.
1-4 round down.
6-9 round up.

In the case of 5, then look to the number that precedes it -- if it  
is even, then round up and if it is odd, then round down -- or vise  
versa, it doesn't make any difference as long as you are consistent.


Here are some examples:

122.4  -- round down (122)
122.6 -- round up (123)
122.5 -- round up (123)

123.4  -- round down (123)
123.6 -- round up (124)
123.5 -- round down (123)

There are people who claim that there's no difference, or are at  
odds with this method, but they simply have not investigated the  
problem sufficiently to see the bias that rounding up/down causes.  
However, that difference is very insignificant and can only be seen  
after tens of thousands iterations.  PHP's rounding function is  
quite sufficient.


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




 --Rick



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



RE: [PHP] RE: Clean PHP 5.2.12 Build Core Dumping / Can't Build Port - FreeBSD 6.1

2010-01-11 Thread Don O'Neil
Ok.. just for grins I installed a new instance of 6.1, NO Patches, just
straight off the ISO...

I loaded the ports that came WITH the distro, and was able to make php 5.1.2
ok...

When I did a portsnap fetch, portsnap extract, then went into the
/usr/ports/lang/php5 and just typed make I get the same error...

SO as it seems, the port is broken, at least for working with FreeBSD 6.1.

Can anyone give me some hints on how to build this sucker by hand? Seems as
though there are a bunch of patches that are referenced in the distinfo
file.

I REALLY need to get this taken care of asap, any help is appreciated.

Thanks!

   I tried adding WITHOUT_X11=yes to /etc/make.conf as well as
 X11BASE=
  and
   X11BASE=, but I still get the same error.
 
  Remove them. This makes sure they are not defined, not even
  empty (as in #define BLA - symbol 'BLA' is defined).
 
   Where to go from here? Do I have and old version of something that
 is
   causing this? I get this error _right away_ before anything is even
  built.
 
  It seems to be a check by the Makefile at port's top level.
 
 Ok... I have no definition for X11BASE anywhere, not in my env, not in
 my
 /etc/make.conf, nowhwere...
 
 However, it's still complaining about X11BASE being deprecated. I tried
 just
 adding WITHOUT_X11=yes in /etc/make, and without it. I even searched
 all the
 Makefiles in /usr/ports, and in the /usr/ports/lang/php5 dir to find
 any
 reference to X11, or X, or X11BASE, but nada... I don't even know where
 this
 error message is being generated from.
 
 I can't even do a basic make without it immediately spitting out the
 error:
 
 # make
 X11BASE is now deprecated.  Unset X11BASE in make.conf and try again.
 *** Error code 1
 
 Stop.
 


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



Re: [PHP] Formatting Decimals

2010-01-11 Thread Mattias Thorslund

tedd wrote:

At 2:55 PM -0500 1/11/10, Rick Dwyer wrote:

I have been asked to further modify the value to the nearest half cent.

So if the 3rd decimal spot ends in 1 or 2, it gets rounded down to 0
If it ends in 3, 4, 5, 6 it gets rounded to 5.  And if it 7, 8 or 9 
it gets rounded up to full cents.


Can this be done fairly easily?  Not knowing PHP well, I am not aware 
of the logic to configure this accordingly.


Thanks,
--Rick



--Rick:

The above described rounding algorithm introduces more bias than 
simply using PHP's round() function, which always rounds down. IMO, 
modifying rounding is not worth the effort.


The best rounding algorithm is to look at the last digit and do this:

0 -- no rounding needed.
1-4 round down.
6-9 round up.

In the case of 5, then look to the number that precedes it -- if it is 
even, then round up and if it is odd, then round down -- or vise 
versa, it doesn't make any difference as long as you are consistent.


Here are some examples:

122.4  -- round down (122)
122.6 -- round up (123)
122.5 -- round up (123)

123.4  -- round down (123)
123.6 -- round up (124)
123.5 -- round down (123)

There are people who claim that there's no difference, or are at odds 
with this method, but they simply have not investigated the problem 
sufficiently to see the bias that rounding up/down causes. However, 
that difference is very insignificant and can only be seen after tens 
of thousands iterations.  PHP's rounding function is quite sufficient.


Cheers,

tedd



However that's not what Rick is asking for. He needs a function that 
rounds to the half penny with a bias to rounding up (greedy bosses):



Actual Rounded Diff
.011   .010-.001
.012   .010-.002
.013   .015+.002
.014   .015+.001
.015   .015 .000
.016   .015-.001
.017   .020+.003
.018   .020+.002
.019   .020+.001
.020   .020 .000
Bias   +.005

This could easily be implemented by getting the 3rd decimal and using it 
in a switch() statement.


An unbiased system could look like:

Actual Rounded Diff
.011   .010-.001
.012   .010-.002
.013   .015+.002
.014   .015+.001
.015   .015 .000
.016   .015-.001
.017   .020-.002
.018   .020+.002
.019   .020+.001
.020   .020 .000
Bias.000

The only difference is the case where the third decimal is 7.

Cheers,

Mattias

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



Re: [PHP] Formatting Decimals

2010-01-11 Thread Adam Richardson
On Mon, Jan 11, 2010 at 7:45 PM, Mattias Thorslund matt...@thorslund.uswrote:

 tedd wrote:

 At 2:55 PM -0500 1/11/10, Rick Dwyer wrote:

 I have been asked to further modify the value to the nearest half cent.

 So if the 3rd decimal spot ends in 1 or 2, it gets rounded down to 0
 If it ends in 3, 4, 5, 6 it gets rounded to 5.  And if it 7, 8 or 9 it
 gets rounded up to full cents.

 Can this be done fairly easily?  Not knowing PHP well, I am not aware of
 the logic to configure this accordingly.

 Thanks,
 --Rick



 --Rick:

 The above described rounding algorithm introduces more bias than simply
 using PHP's round() function, which always rounds down. IMO, modifying
 rounding is not worth the effort.

 The best rounding algorithm is to look at the last digit and do this:

 0 -- no rounding needed.
 1-4 round down.
 6-9 round up.

 In the case of 5, then look to the number that precedes it -- if it is
 even, then round up and if it is odd, then round down -- or vise versa, it
 doesn't make any difference as long as you are consistent.

 Here are some examples:

 122.4  -- round down (122)
 122.6 -- round up (123)
 122.5 -- round up (123)

 123.4  -- round down (123)
 123.6 -- round up (124)
 123.5 -- round down (123)

 There are people who claim that there's no difference, or are at odds with
 this method, but they simply have not investigated the problem sufficiently
 to see the bias that rounding up/down causes. However, that difference is
 very insignificant and can only be seen after tens of thousands iterations.
  PHP's rounding function is quite sufficient.

 Cheers,

 tedd


 However that's not what Rick is asking for. He needs a function that rounds
 to the half penny with a bias to rounding up (greedy bosses):


 Actual Rounded Diff
 .011   .010-.001
 .012   .010-.002
 .013   .015+.002
 .014   .015+.001
 .015   .015 .000
 .016   .015-.001
 .017   .020+.003
 .018   .020+.002
 .019   .020+.001
 .020   .020 .000
 Bias   +.005

 This could easily be implemented by getting the 3rd decimal and using it in
 a switch() statement.

 An unbiased system could look like:

 Actual Rounded Diff
 .011   .010-.001
 .012   .010-.002
 .013   .015+.002
 .014   .015+.001
 .015   .015 .000
 .016   .015-.001
 .017   .020-.002
 .018   .020+.002
 .019   .020+.001
 .020   .020 .000
 Bias.000

 The only difference is the case where the third decimal is 7.

 Cheers,

 Mattias


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


Here you go, Rick.  Just send the check in the mail ;)

function round_to_half_cent($amount)
{
if (!is_numeric($amount)) throw new Exception('The amount received by the
round_to_half_cent function was not numeric');
 $parts = explode('.', str_replace(',', '', (string)$amount));
 if (count($parts) = 3) throw new Exception('The amount received by the
round_to_half_cent function had too many decimals.');
 if (count($parts) == 1)
{
return $amount;
}
 $digit = substr($parts[1], 2, 1);
 if ($digit == 0 || $digit == 1 || $digit == 2)
{
$digit = 0;
}
elseif ($digit == 3 || $digit == 4 || $digit == 5 || $digit == 6)
{
$digit = .005;
}
elseif ($digit == 7 || $digit == 8 || $digit == 9)
{
$digit = .01;
}
else
{
throw new Exception('OK, perhaps we are talking about different types of
numbers :(  Check the input to the round_to_half_cent function.');
}
 return (double)($parts[0].'.'.substr($parts[1], 0, 2)) + $digit;
}

echo 5.002 = .round_to_half_cent(5.002);
echo br /70,000.126 = .round_to_half_cent(7.126);
echo br /55.897 = .round_to_half_cent(55.897);
// should cause exception
echo br /One hundred = .round_to_half_cent(One hundred);

-- 
Nephtali:  PHP web framework that functions beautifully
http://nephtaliproject.com


Re: [PHP] Formatting Decimals

2010-01-11 Thread Paul M Foster
On Mon, Jan 11, 2010 at 04:56:03PM -0500, tedd wrote:


 --Rick:

 The above described rounding algorithm introduces more bias than
 simply using PHP's round() function, which always rounds down. IMO,
 modifying rounding is not worth the effort.

 The best rounding algorithm is to look at the last digit and do this:

 0 -- no rounding needed.
 1-4 round down.
 6-9 round up.

 In the case of 5, then look to the number that precedes it -- if it
 is even, then round up and if it is odd, then round down -- or vise
 versa, it doesn't make any difference as long as you are consistent.

 Here are some examples:

 122.4  -- round down (122)
 122.6 -- round up (123)
 122.5 -- round up (123)

 123.4  -- round down (123)
 123.6 -- round up (124)
 123.5 -- round down (123)

 There are people who claim that there's no difference, or are at odds
 with this method, but they simply have not investigated the problem
 sufficiently to see the bias that rounding up/down causes. However,
 that difference is very insignificant and can only be seen after tens
 of thousands iterations.  PHP's rounding function is quite sufficient.

This is called (among other things) banker's rounding. But PHP's
round() function won't do banker's rounding, as far as I know.

Paul

-- 
Paul M. Foster

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



Re: [PHP] corect way to use mail() function

2010-01-11 Thread Paul M Foster
On Mon, Jan 11, 2010 at 04:17:30PM -0600, LAMP wrote:

 Hi,
 The company I work for, hosts online events registration applications.
 After a registered registered himself for an event he will get a
 confirmation email saying he registered successfully.
 Currently, in the header part of the mail(), in From it says e.g.
 ord...@computility.com - because the email comes from us not from our
 client (e.g. ABC Assoc.). Reply-to goes to us too.

 Now one of our clients (e.g. ABC Assoc.) asks us to put in the from
 field their email, to looks like the email comes from them. something
 like: From: ABC Assoc. eve...@abcaccos.org;

 I refused to do that concerned we are going to be blacklisted for
 sending spam. Because header shows one place and From field says other
 email address - spam way of sending emails.

 Am I right or it really doesn't matter who sent the email?

Since the mail() function doesn't have a parameter for the From:, how
do you force it to be a certain thing in the first place?

Paul

-- 
Paul M. Foster

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



RE: [PHP] corect way to use mail() function

2010-01-11 Thread Daevid Vincent
 

 -Original Message-
 From: Paul M Foster [mailto:pa...@quillandmouse.com] 
 Sent: Monday, January 11, 2010 8:51 PM
 To: php-general@lists.php.net
 Subject: Re: [PHP] corect way to use mail() function
 
 On Mon, Jan 11, 2010 at 04:17:30PM -0600, LAMP wrote:
 
  Hi,
  The company I work for, hosts online events registration 
 applications.
  After a registered registered himself for an event he will get a
  confirmation email saying he registered successfully.
  Currently, in the header part of the mail(), in From it says e.g.
  ord...@computility.com - because the email comes from us 
 not from our
  client (e.g. ABC Assoc.). Reply-to goes to us too.
 
  Now one of our clients (e.g. ABC Assoc.) asks us to put in 
 the from
  field their email, to looks like the email comes from them. 
 something
  like: From: ABC Assoc. eve...@abcaccos.org;
 
  I refused to do that concerned we are going to be blacklisted for
  sending spam. Because header shows one place and From 
 field says other
  email address - spam way of sending emails.
 
  Am I right or it really doesn't matter who sent the email?
 
 Since the mail() function doesn't have a parameter for the 
 From:, how
 do you force it to be a certain thing in the first place?
 
 Paul

That's what the headers are for son! :)

/**
 * This is the actual 'engine' that does the sending of an SMS or
Email.
 *
 * @access  static final
 * @return  void
 * @param   string $to the email address to send to
 * @param   string $subject the subject line of the message
 * @param   string $body the body of the message
 * @param   boolean $html use 'html' (true) or 'plain' (false)
 * @author  Daevid Vincent [daevid.vinc...@panasonic.aero]
 * @date12/22/09
 * @see send_email()
 */
static final function email($to, $subject, $body, $html=true)
{
$headers  = MIME-Version: 1.0\r\n;
$headers .= Content-type: text/.( ($html) ? 'html' :
'plain').; charset=iso-8859-1\r\n;
$headers .= From: .COMPANY_FULL_NAME.' '.PRODUCT_NAME.
.PRODUCT_SUPPORT_EMAIL.\n;
//$headers .= Cc: Daevid Vincent
daevid@.COMPANY_DOMAIN.\r\n;
//$headers .= Bcc: presid...@example.com\r\n;
//$headers .= Reply-To: .$myname.
.$myreplyemail.\r\n;
$headers .= X-Priority: 1\r\n;
$headers .= X-MSMail-Priority: High\r\n;
$headers .= X-Mailer: .COMPANY_FULL_NAME. Linux Server;

$body .= p\n\niThis is an automated email from host
(.$_SERVER['SERVER_NAME'].) .$_SERVER['SERVER_ADDR'].. Do not reply to
it./i;
if (!$html) $body = strip_tags($body);

mail($to, $subject, $body, $headers);
}


/**
 * Send this user an HTML email.
 *
 * @access  public
 * @return  boolean
 * @author  Daevid Vincent [daevid.vinc...@panasonic.aero]
 * @date12/22/09
 * @see User::email()
 */
public function send_email($subject, $body)
{
$to = $this-get_fullname().' '.$this-email.'';
User::email($to, $subject, $body,
(strtolower($this-emailformat) == 'html') );
add_user_log('Action', 'Email \''.$subject.'\' sent');
}


ÐÆ5ÏÐ 
http://daevid.com

There are only 11 types of people in this world. Those that think binary
jokes are funny, those that don't, and those that don't know binary.


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



Re: [PHP] corect way to use mail() function

2010-01-11 Thread Angus Mann

There are only 11 types of people in this world. Those that think binary
jokes are funny, those that don't, and those that don't know binary.

ErUmmm.shouldn't that read ...only 10 types of people... ?



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