[PHP] SimpleXML
Hi, I am trying to write a PHP interface to ISBNdb.com. When I make a certain request, the following is returned Language, Proof and Logic Jon Barwise, John Etchemendy, Center for the Study of Language and Inf Amazon.com -- Nonfiction -- Philosophy -- Logic & Language Amazon.com -- Science -- General And when loaded using simplexml_load_string, it gives the following object object(SimpleXMLElement)#10 (2) { ["@attributes"]=> array(1) { ["server_time"]=> string(20) "2009-02-24T18:57:31Z" } ["BookList"]=> object(SimpleXMLElement)#14 (2) { ["@attributes"]=> array(4) { ["total_results"]=> string(1) "1" ["page_size"]=> string(2) "10" ["page_number"]=> string(1) "1" ["shown_results"]=> string(1) "1" } ["BookData"]=> object(SimpleXMLElement)#11 (6) { ["@attributes"]=> array(3) { ["book_id"]=> string(24) "language_proof_and_logic" ["isbn"]=> string(10) "157586374X" ["isbn13"]=> string(13) "9781575863740" } ["Title"]=> string(25) "Language, Proof and Logic" ["TitleLong"]=> object(SimpleXMLElement)#15 (0) { } ["AuthorsText"]=> string(30) "Jon Barwise, John Etchemendy, " ["PublisherText"]=> string(40) "Center for the Study of Language and Inf" ["Subjects"]=> object(SimpleXMLElement)#16 (1) { ["Subject"]=> array(2) { [0]=> string(58) "Amazon.com -- Nonfiction -- Philosophy -- Logic & Language" [1]=> string(32) "Amazon.com -- Science -- General" } } } } Notice that I lose the attribute subject_id from the Subject tag. Why is this?? Is there any way from preventing it from happening?? Thanks in advance, Alex Chamberlain -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP attaching css and JS files to current page
Have you considered using some type of templating system, which can use class_exists?? Alex No virus found in this outgoing message. Scanned by AVG Free 8.0 Checked by AVG - http://www.avg.com Version: 8.0.176 / Virus Database: 270.9.11/1820 - Release Date: 29/11/2008 18:52 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: Open Project
> Nathan Rixham wrote: > > Evening All, > > > > I'm feeling the need to either start or contribute to something > > opensource and in PHP. > > > > Anybody have any worthy causes or projects they'd like to collab on > to > > get off the ground; open to all options preference going to anything > > framework, orm, webservice or basically anything without an html > front > > end :) > > > > Afternoon, > > I've had a look through the two frameworks that Alex and Craige have > sent through, done a lot of thinking and came to a decision, well more > of an idea. I'd be interested in thoughts / comments. > > What: > A light generic framework for php developers, built API style with a > public interface (web service) and a private interface (PHP 5 classes). > > =Base=: > > 3rd Party WS Integrations: > Amazon AWS and S3 services, Yahoo's API's, OpenCalais, Google API's > (more..?) > > Additional Product Integrations: > Apache SOLR, ARC2 (for rdf and sparql support?), Doctrine (ORM)? > > Templating: > Smart, other or custom. > > DB: > PDO/Doctrine + contrib to doctrine project as well (or fork?) OR custom > ORM built on top of PDO. > > PHP Client Lib's: > HTTP 1.1, SOAP 1.2 (with the ws-* suite), xml-rpc and maybe XMPP? > > XML: > Generic XML Parser using DOM API > Object to XML and XML to Object support, aim to add __toXML() for all > classes. > Specific XML Parsers, XHTML, RSS, ATOM, SOAP, RDF, XML-RPC (maybe XMPP) > Specific XML Writers (same as above) > > Helpers: > Some things like a Arrays, HashMaps, Tree class, filesystem > negotiation, > verification for common data types (emails and the like) Primitive > types > maybe byte, int, real, string classes too?) - Dates and thoughts on an > Arbitary Precision Class as well for the hell of it? > > Internals: > Framework structure and design pattern(s), Generic Object Class with > id's etc, Generic Cache Class (unless in ORM layer), interfaces, > Exception handler, logging, autoloader(s) etc. > An additional I'd like in here is auto initiation via an "initiator" > interface(s) and analysis on all framework classes via reflection to > auto initiate classes upon framework load. > > [probably do all of the above in reverse order eh.. the framework core, > all with private api's (eg classes)] > > Second Layer: (all with private and public api's) > After the above a series of generic domain model/business object > classes > such as user, address, article etc etc built on top of the ORM stuff. > tbd! Probably worth getting a load agreed, defined and drawn up in UML. > > and really no point going any further here.. > > Thoughts? (open to all obviously) This all seems a bit complicated, qhich is what I am trying to avoid. Alex No virus found in this outgoing message. Scanned by AVG Free 8.0 Checked by AVG - http://www.avg.com Version: 8.0.175 / Virus Database: 270.9.9/1806 - Release Date: 22/11/2008 18:59 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Open Project
> >>> Evening All, > >>> > >>> I'm feeling the need to either start or contribute to something > >>> opensource and in PHP. > >>> > >>> Anybody have any worthy causes or projects they'd like to collab on > >> to > >>> get off the ground; open to all options preference going to > anything > >>> framework, orm, webservice or basically anything without an html > >> front > >>> end :) > >>> > >>> Regards, > >>> > >>> Nathan > >> Hi Nathan, I am about to launch my own framework called Fred the > >> Framework. > >> Designed to be easy going, it is suppose to be ready to use out of > the > >> box, > >> with very little config and a usable user management system - unlike > >> Zend's > >> Auth and ACL. Except, I need someone to develop the Authentication > part > >> of > >> it. > >> > >> I've put it on Sourceforge the other day, but I've never developed > >> anything > >> like this before. I'm going to put up a sample app soonish - take a > >> look at > >> the svn if you want. > >> > >> Alex > > > > had a look through; it is early day's isn't it! > 3 questions: > - what do you all want to have in the framework (rough feature set) > - why build it? / what do you want to offer that other's don't Fred will offer friendly URLs out of the box. Support for Smarty is a given, along with ADOdb and PHPMailer. The major feature I want implemented is a decent user management system that is simple for developers to use and secure enough for consumers to believe in. Nothing else provides this. > - what version of php are you developing in and min support (ie 5.2+ Starting with the current version of PHP5 and branch off to 6 as the developers at a later date see fit. No virus found in this outgoing message. Scanned by AVG Free 8.0 Checked by AVG - http://www.avg.com Version: 8.0.175 / Virus Database: 270.9.9/1806 - Release Date: 22/11/2008 18:59 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Open Project
> > Evening All, > > > > I'm feeling the need to either start or contribute to something > > opensource and in PHP. > > > > Anybody have any worthy causes or projects they'd like to collab on > to > > get off the ground; open to all options preference going to anything > > framework, orm, webservice or basically anything without an html > front > > end :) > > > > Regards, > > > > Nathan > > Hi Nathan, I am about to launch my own framework called Fred the > Framework. > Designed to be easy going, it is suppose to be ready to use out of the > box, > with very little config and a usable user management system - unlike > Zend's > Auth and ACL. Except, I need someone to develop the Authentication part > of > it. > > I've put it on Sourceforge the other day, but I've never developed > anything > like this before. I'm going to put up a sample app soonish - take a > look at > the svn if you want. > > Alex PS forgot to say you can find it at https://sourceforge.net/projects/fredframework/ No virus found in this outgoing message. Scanned by AVG Free 8.0 Checked by AVG - http://www.avg.com Version: 8.0.175 / Virus Database: 270.9.9/1804 - Release Date: 21/11/2008 18:24 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Open Project
> Evening All, > > I'm feeling the need to either start or contribute to something > opensource and in PHP. > > Anybody have any worthy causes or projects they'd like to collab on to > get off the ground; open to all options preference going to anything > framework, orm, webservice or basically anything without an html front > end :) > > Regards, > > Nathan Hi Nathan, I am about to launch my own framework called Fred the Framework. Designed to be easy going, it is suppose to be ready to use out of the box, with very little config and a usable user management system - unlike Zend's Auth and ACL. Except, I need someone to develop the Authentication part of it. I've put it on Sourceforge the other day, but I've never developed anything like this before. I'm going to put up a sample app soonish - take a look at the svn if you want. Alex No virus found in this outgoing message. Scanned by AVG Free 8.0 Checked by AVG - http://www.avg.com Version: 8.0.175 / Virus Database: 270.9.9/1804 - Release Date: 21/11/2008 18:24 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] preg_match
> -Original Message- > From: Stut [mailto:[EMAIL PROTECTED] > Sent: 27 October 2008 15:21 > To: Alex Chamberlain > Cc: PHP General list > Subject: Re: [PHP] preg_match > > On 27 Oct 2008, at 15:08, Alex Chamberlain wrote: > > I don’t understand regular expressions at all – I will make an > > effort to > > learn about them one day, but I need a solution today. I want to use > > the > > __autoload function, but not for all my class only those that finish > > in > > ‘Controller’. So for instance, > > > > ‘ErrorController’ should load ‘errorcontroller.inc.php’ > > ‘IndexController’ should load ‘indexcontroller.inc.php’ > > ‘FooBar’ should NOT load anything whatsoever. > > > > Can you help me write an __autoload function please?? > > Have you even tried it? This is not hard, and doesn't need to use any > regular expressions at all. > > We're not here to write code for you, we're here to help when you have > problems. Try it, see how far you get and send us the code if/when you > get stuck. > > Unless you want to hire me to do it. My rates are pretty reasonable > for simple stuff like this. > > -Stut Problem solved: function __autoload($c) { $m = array(); preg_match('/(?:^[A-Z][a-z]+)Controller/', $c, $m); if (count($m)) { require_once(realpath(FS_CONTROLLER . '/' . strtolower($m[0]) . '.inc.php')); } } However (perhaps a more appropriate question), do you think there is an easier/better way to do this?? Alex No virus found in this outgoing message. Scanned by AVG Free 8.0 Checked by AVG - http://www.avg.com Version: 8.0.175 / Virus Database: 270.8.3/1748 - Release Date: 27/10/2008 07:57 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] preg_match
Hi, I don’t understand regular expressions at all – I will make an effort to learn about them one day, but I need a solution today. I want to use the __autoload function, but not for all my class only those that finish in ‘Controller’. So for instance, ‘ErrorController’ should load ‘errorcontroller.inc.php’ ‘IndexController’ should load ‘indexcontroller.inc.php’ ‘FooBar’ should NOT load anything whatsoever. Can you help me write an __autoload function please?? Alex No virus found in this outgoing message. Scanned by AVG Free 8.0 Checked by AVG - http://www.avg.com Version: 8.0.175 / Virus Database: 270.8.3/1748 - Release Date: 27/10/2008 07:57 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: BarcodeDB.com - a Barcode Database
Thanks for your suggestion!! Sounds like a good route to go down with the API access. Really struggling with the pending 'list' at the moment. Suppose I have got 2 tables `product` and `description`. `product` contains `EAN`, `name`, `last_modified` and `description` contains `EAN` and `description`. The nearest thing to me right now is a tub of pencils. EAN: 5011772007888 Name: 50 Staedtler HB Pencils Description: A tub of 50 HB Pencils by Staedtler. Suppose someone at BarcodeDB.com, having signed in, wanted to change the description to: A tub of 50 HB Pencils by Staedtler. With strong break resistant leads, they make an ideal pencil for kids or adults alike. Rather than update this description straight into the database. It would be nice for it to wait to be approved, and once approved a 'history' is kept so it is known who submitted the data and who approved it. Any ideas on how to achieve this effectively?? Thanks, Alex No virus found in this outgoing message. Scanned by AVG Free 8.0 Checked by AVG - http://www.avg.com Version: 8.0.173 / Virus Database: 270.8.0/1722 - Release Date: 14/10/2008 02:02 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] BarcodeDB.com - a Barcode Database
Hi, I am looking to set up a new 'public' database for barcodes. There are a couple of barcode databases out there, namely http://www.upcdatabase.com/ and http//en.barcodepedia.com/. UPC Database is old fashioned and over run by Google ads, but does provide an (unsecure) XML-RPC interface. Barcodepedia is more modern, but there is no XML-RPC. UPC Database has ~2 users and 977,498 barcode entries, but there is simply a barcode and a name (sometimes a size/ weight) - no description. Both sites claim to use the Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License. I wish to set up a similar website. Indexed on the modern EAN-13 (used across the world, and includes ISBNs), the database will store a barcode and name for *every* product. Additionally, the description of the product can be stored. In the future, I would like to implement a 'tag-type' system, whereby a tag, consisting of name (eg Author) and value (eg JK Rowling), can be assigned to one or more objects. These tags could include links to publicly available images etc. The country of registration of each product can be derived from the barcode itself. I want to set up XML-RPC access for both downloading and uploading products, but I want them to be secure. When people upload or edit a product, I want it to go onto a pending list for me (and others in the future with the appropriate rights) to approve, unless it’s the manufacturer themselves. I know a very basic database is easy to setup - I did it in a day or two, but I am struggling with the user management side, including the authentication of API access, as well as how to implement a 'pending' list. Has anybody got any ideas?? Is there any (free) software out there capable of this?? If anybody else wishes to contribute to this very young project, I am open to ideas ([EMAIL PROTECTED]). Hosting is sorted and I own BarcodeDB.com and .co.uk Platform: PHP 5, ADOdb, Smarty - MySQL to start with, though I have thought about an XML database as well. As the platform develops, I want to let companies upload their products for free, but charge others to download them - think how much time companies spend on data entry for this kind of thing!! For the consumer, a money diary etc will follow. Thanks, Alex No virus found in this outgoing message. Scanned by AVG Free 8.0 Checked by AVG - http://www.avg.com Version: 8.0.173 / Virus Database: 270.8.0/1722 - Release Date: 14/10/2008 02:02 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Closing a website (mod_redirect) SOLVED
Why do you always solve a problem you have been working on for a day as soon as you email a mail list!?! THE SOLUTION, should anybody want it. RewriteEngine on RewriteCond %{REQUEST_URI} !^.*/closed/closed.png.*$ RewriteCond %{REQUEST_URI} !^.*/closed/closed.htm.*$ RewriteRule ^.*$ http://localhost/kayaknames/closed/closed.htm [L] http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";> Kayak Names http://localhost/kayaknames/closed/closed.png"; alt="Kayak Names" /> > -Original Message- > From: Alex Chamberlain [mailto:[EMAIL PROTECTED] > Sent: 26 August 2008 17:33 > To: PHP General list > Subject: [PHP] Closing a website (mod_redirect) > > Hi, > > From time to time, I will need to update my website. During this time, > I > would like to forward all traffic to a ‘closed for site maintenance’ > page. > This page will have an image. I’ve had a go using mod_redirect: > > RewriteEngine on > RewriteRule ^.*/splash.png$ > http://localhost/kayaknames/closed/closed.png > [R] > RewriteCond %{REQUESTURI} !^.*/closed/closed.png.*$ > RewriteRule ^.*$ http://localhost/kayaknames/closed/closed.htm [R,L] > > Closed.htm: > > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";> > > > Kayak Names > > > > > > > > > It works, but the image is not shown as it redirects to closed.png > (correctly), but then redirects again to closed.htm - hence no image. > > Wondering if anybody had any ideas where I am going wrong?? > > Thanks, > > Alex > > > No virus found in this outgoing message. Scanned by AVG Free 8.0 > Checked by AVG - http://www.avg.com > Version: 8.0.138 / Virus Database: 270.6.9/1635 - Release Date: > 26/08/2008 > 07:29 > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > No virus found in this incoming message. > Checked by AVG - http://www.avg.com > Version: 8.0.138 / Virus Database: 270.6.9/1635 - Release Date: > 26/08/2008 07:29 No virus found in this outgoing message. Scanned by AVG Free 8.0 Checked by AVG - http://www.avg.com Version: 8.0.138 / Virus Database: 270.6.9/1635 - Release Date: 26/08/2008 07:29 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Closing a website (mod_redirect)
Hi, >From time to time, I will need to update my website. During this time, I would like to forward all traffic to a ‘closed for site maintenance’ page. This page will have an image. I’ve had a go using mod_redirect: RewriteEngine on RewriteRule ^.*/splash.png$ http://localhost/kayaknames/closed/closed.png [R] RewriteCond %{REQUESTURI} !^.*/closed/closed.png.*$ RewriteRule ^.*$ http://localhost/kayaknames/closed/closed.htm [R,L] Closed.htm: http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";> Kayak Names It works, but the image is not shown as it redirects to closed.png (correctly), but then redirects again to closed.htm - hence no image. Wondering if anybody had any ideas where I am going wrong?? Thanks, Alex No virus found in this outgoing message. Scanned by AVG Free 8.0 Checked by AVG - http://www.avg.com Version: 8.0.138 / Virus Database: 270.6.9/1635 - Release Date: 26/08/2008 07:29 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Image Generation
Hi, I need to generate an online proof for vinyl lettering. Customers specify the text, font, colour, maximum frame size (mm) (ie the width and height it must fit into), and whether or not they want to keep aspect ratio (ie not distort the lettering). I want to represent all this on a single image. So it would display a border with their width and height on, and inside this would be the text in the appropriate colour and font – if they decide to keep aspect ratio the text would not be distorted. If they do not, it would be. The image would always be 300px wide by 150px high (these would need to be constants that I could change from time to time). I’ve got a very basic proof working using a GD wrapper, but I don’t think GD is powerful enough to do it all, nor do I recon my programming skills are up for it. Has anybody got any advice on how to tackle this, even if it is just bits of the problem?? Thanks, Alex Chamberlain No virus found in this outgoing message. Scanned by AVG Free 8.0 Checked by AVG - http://www.avg.com Version: 8.0.138 / Virus Database: 270.6.6/1621 - Release Date: 19/08/2008 18:53 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] More math fun
1.7763568394E-15 is 0. The computer just had a rounding error somewhere. We had this discussion a few weeks ago, the solution being to decide to what accuracy you want the answer. Upto 14 decimal places will give you 0 here!! Alex > -Original Message- > From: Robert Cummings [mailto:[EMAIL PROTECTED] > Sent: 13 August 2008 05:39 > To: Micah Gersten > Cc: Jim Lucas; Jay Blanchard; php-general@lists.php.net > Subject: Re: [PHP] More math fun > > On Tue, 2008-08-12 at 23:23 -0500, Micah Gersten wrote: > > Robert, when you do yours, it's performing the same function on two > > different variable types and has to do a conversion before the > function > > works. He was doing a numeric function on a string which might be > > giving the funky results. > > That's what Jim tried and got 0 and double... I confirmed Jim's results > (I didn't originally test Jay's problem) and then tried the alternative > that I might have thought this morning. Either way, it seems to come up > as 0. Maybe Jay is running a buggy version of PHP. > > 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 > > No virus found in this incoming message. > Checked by AVG - http://www.avg.com > Version: 8.0.138 / Virus Database: 270.6.1/1608 - Release Date: > 12/08/2008 16:59 No virus found in this outgoing message. Scanned by AVG Free 8.0 Checked by AVG - http://www.avg.com Version: 8.0.138 / Virus Database: 270.6.1/1608 - Release Date: 12/08/2008 16:59 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] OpenID
> This one time, at band camp, "Alex Chamberlain" > <[EMAIL PROTECTED]> wrote: > > > > Has anybody had any success implementing an OpenID server in PHP?? > > Sure, I had mine all set up on oceania.net and then the domain got > stolen. So, all my OpenID info went with it.. not as good an idea as > it first seems. > > > Kevin Other than the mystery of the stolen domain, what software did you run?? Did you write it yourself?? Alex No virus found in this outgoing message. Scanned by AVG Free 8.0 Checked by AVG - http://www.avg.com Version: 8.0.138 / Virus Database: 270.5.0/1557 - Release Date: 17/07/2008 05:36 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] OpenID
Hi, Has anybody had any success implementing an OpenID server in PHP?? Alex -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] is there a problem with php script pulling HTML out of database as it writes the page??
> -Original Message- > From: Rod Clay [mailto:[EMAIL PROTECTED] > Sent: 15 July 2008 22:36 > To: php-general@lists.php.net > Subject: [PHP] is there a problem with php script pulling HTML out of > database as it writes the page?? > > Hello. Again, I'm fairly new to php so please forgive me if my > question > is a very simple or obvious one. > > I've just tried testing for the first time some php code that is > pulling > text out of a database to print it on the webpage. Some of this text > includes HTML, specifically in this case an > statement. Much to my surprise, this is not working. Is there a > problem with pulling HTML out of a database like this as the page is > being written? > > There's no problem of course if my php code is writing the HTML to the > page - in this case, the statement works fine and > the > image is displayed. Why is it a problem when my php script pulls the > HTML code out of a database and writes it to the page from there?? > > It would appear that when my php script writes HTML to the page a > process of some kind is executed to, in this case, get the image and > put > it on the page. Apparently this same process is NOT executed if the > HTML is retrieved from a database and simply written to the page from > there. Is this correct? And, if it is, can anyone suggest a > workaround, another way to get done what I'm trying to do here? > > Thanks for any help you can give me. > > Rod Clay Have you got a code snippet?? Alex No virus found in this outgoing message. Scanned by AVG Free 8.0 Checked by AVG - http://www.avg.com Version: 8.0.138 / Virus Database: 270.4.11/1553 - Release Date: 15/07/2008 05:48 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Math Weirdness - Can it be done with integers alone??
> On Mon, 2008-07-14 at 16:25 -0400, Daniel Brown wrote: > > On Mon, Jul 14, 2008 at 4:15 PM, Robert Cummings > <[EMAIL PROTECTED]> wrote: > > > > > > Nope, banks can't round like that when calculating your daily > > > interest :) > > > > If it works in their favor, you'd be surprised what they do. > > That's why extending TILA to banks in the US is such a big deal to > me, > > yet gets no attention. > > I'm not completely sure about the U.S. but banks in Canada are > regulated... fortunately :) > > Cheers, > Rob. Ok, I may have been wrong about the banks thing - don't quote me on it!! However, there must be some degree of accuracy?? Which can then be reflected in your integers. Alex No virus found in this outgoing message. Scanned by AVG Free 8.0 Checked by AVG - http://www.avg.com Version: 8.0.138 / Virus Database: 270.4.10/1550 - Release Date: 13/07/2008 17:58 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Math Weirdness - Can it be done with integers alone??
[quote] I don't quite understand your problem, but I use integers for any monetary workings as you can guarantee it is accurate (obviously, you work in pence or cents rather than GBP or USD). Alex Hello Alex, I was reading through this thread, and I was curious about what methods you use to handle fractions of a dollar and/or fractions of a penny if you are always using integers. Do you only use a decimal for printing? do you adjust all interest rates, etc...then as well? How about when interest calculations result in fractions of pennies, how do you handle it then? Basically, I can't see how it could be done with just integers alone? thanks dank [/quote] To be honest, I haven't used it for any complicated use - shopping carts are additive contraptions. However, I don't see the problem. 1) I use Smarty a lot - I use a plugin to format the integer to a price (ie divide by 100 and display in 2 decimal places). So yes, I only put the decimal place there to print. 2) Why do interest rates need to be changed?? Take £123.45 @ 5%. 123.45 * 1.05 = (12345 [pennies] / 100) [pounds] * 1.05 = (12345 * 1.05) / 100 Same calculation in my mind!! (Tell me if I have missed the point!!) 3) If you have a fraction of a penny - round it!! Surely, that's what the banks do!! It's a penny!! I think it can be done with integers alone - let me know if you disagree!! Alex No virus found in this outgoing message. Scanned by AVG Free 8.0 Checked by AVG - http://www.avg.com Version: 8.0.138 / Virus Database: 270.4.10/1550 - Release Date: 13/07/2008 17:58 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Math Weirdness
> On Mon, Jul 14, 2008 at 3:51 PM, Daniel Brown <[EMAIL PROTECTED]> > wrote: > > > >You're performing math to get the result for $totChargeDiff by > > subtracting $totalCharges from $endingBal. That will give you -0.10 > > in this case, because 0.10 - 0.20 = -0.10. You want the difference, > > not the result. > > Oh, and the code, by the way: > > // your code to this point > > /* what is the difference between the ending balance and the charges? > */ > $totChargeDiff = ($totalCharges > $endingBal) ? > ($endingBal + $totalCharges) : ($endingBal - $totalCharges); > echo number_format($totChargeDiff, 2, '.', '')."\t"; > > // and continue with your code here > ?> Surely, for difference, $totChargeDiff = abs($endingBal - $totalCharges); Alex No virus found in this outgoing message. Scanned by AVG Free 8.0 Checked by AVG - http://www.avg.com Version: 8.0.138 / Virus Database: 270.4.10/1550 - Release Date: 13/07/2008 17:58 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Math Weirdness
> I am totally buffaloed by a set of very simple calculations that I am > doing; > > /* calculate total balance with payments and adjustments */ > $totalBalance = $acct['BALANCE'] + $adjBalance; > echo number_format($totalBalance, 2, '.', '')."\t"; > > /* calculate total charges */ > $totalCharges = $intlLDCharges + $longDistance + $smsCharges + > $daCharges + $totalData + $roaming; > echo number_format($totalCharges, 2, '.', '')."\t"; > > /* > * calculate difference between total balance and total charges > * if the amount matches the ending balance then all is OK > * if not calculate the difference > */ > $totBalDiff = $totalBalance - $totalCharges; > if($totBalDiff === $endingBal){ > echo "OK\t"; > } else { > /* what is the difference between the ending balance and the > charges? */ > $totChargeDiff = $endingBal - $totalCharges; > echo number_format($totChargeDiff, 2, '.', '')."\t"; > } > > Each number represented by a variable in all of these calculations has > been rounded to 2 decimal points at the point they are generated. For > the most part this works just hunky-dory but I have a handful of calcs > (out of 300k plus records) that look like this > > $endingBal0.10 > $totalBalance 0.30 > $totalCharges 0.20 > $totalChargeDiff -0.10 > > The balance minus the charges does equal the ending balance as it > should but it is saying that it doesn't and that there a 20 cent swing > (-0.10 is 20 cents different than 0.10). > > I must be missing something. When I echo out raw data I do not see > negative signs. Does anyone have any insight as to what might be > happening here? I don't quite understand your problem, but I use integers for any monetary workings as you can guarantee it is accurate (obviously, you work in pence or cents rather than GBP or USD). Alex -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Shared Authentication Scheme - the reason for the Redirect and POST mailing
> Alex Chamberlain wrote: > > The server and client will initially be programmed in PHP, so I > wanted to > > gather some opinion on whether people wanted another SAS, and what > would > > make them use it over any other?? The company will be there, not > > only > to > > serve the end user, but to serve the developer as well. If anybody > wants to > > be one of the first users/developers, feel free to contact me on > > this > email > > address and I will keep you posted. > > Personally I don't really like the idea of yet another SAS/SSO... The > whole point of an SSO is summed up in the first letter of the > Acronym... > *Single*. If there are multiple different services and different sites > implement different SSO systems then there is no longer a *Single* > service. > > Personally, I think that a distributed system with a single > *specification* that allows different implementations to exist is the > only way forward here and for that, OpenID seems like the best spec > out there right now. > > Perhaps you can explain what your system would offer that would make > it better than an OpenID service? Perhaps your service will be OpenID > compatible to ensure wider exposure? Perhaps it does more than OpenID? > If so what? > > Col I was anticipating this question, but did not want to prompt it. In fact, I started a few weeks ago looking at the OpenID specification, and a PHP server implementation: I found it to be confusing and quite buggy. I hope to implement a OpenID 'frontend' in the future, but not straight away. I also consulted several friends, as well as some of my 18-year-old brothers friends - although a few were very comfortable with the internet and did understand, a lot were confused by the concept of a URL itself - they sort of understood when I explained it was a web address, but could not understand how to use this as a username: this is a fundamental problem of their discovery procedure, in my opinion. Also, a single server system will be more consistent and more secure, and I hope the sharing of personal information *legally* will be a key attraction for most websites. I am at a very early stage, and welcome any comments. Alex No virus found in this outgoing message. Scanned by AVG Free 8.0 Checked by AVG - http://www.avg.com Version: 8.0.138 / Virus Database: 270.4.10/1549 - Release Date: 12/07/2008 16:31 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Relocating and POSTing
Ahh, but they are on different webservers At the moment, I am just using a query string. How long is the limit of the query string?? Alex > -Original Message- > From: tedd [mailto:[EMAIL PROTECTED] > Sent: 11 July 2008 17:12 > To: Alex Chamberlain; PHP General list > Subject: Re: [PHP] Relocating and POSTing > > At 7:20 PM +0100 7/10/08, Alex Chamberlain wrote: > >I need to send a header('Location:') and send some data along with > it - > >how would I do this?? > > > >Thanks, > > > >Alex > > Alext: > > Or you could just: > > ob_clean(); > include('theNextScript.php'); > exit(); > > The variable in your parent script will be "passed" to the next script. > > Cheers, > > tedd > > -- > --- > http://sperling.com http://ancientstones.com http://earthstones.com > No virus found in this incoming message. > Checked by AVG - http://www.avg.com > Version: 8.0.138 / Virus Database: 270.4.7/1546 - Release Date: > 11/07/2008 06:47 No virus found in this outgoing message. Scanned by AVG Free 8.0 Checked by AVG - http://www.avg.com Version: 8.0.138 / Virus Database: 270.4.7/1546 - Release Date: 11/07/2008 06:47 No virus found in this outgoing message. Scanned by AVG Free 8.0 Checked by AVG - http://www.avg.com Version: 8.0.138 / Virus Database: 270.4.7/1546 - Release Date: 11/07/2008 06:47 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
FW: [PHP] Relocating and POSTing
I've solved the problem by using a query string - whilst it is the same domain now - it won't always be and I a silly moment trying to POST data with the redirect! Thanks for the help, Alex > -Original Message- > From: Eric Butera [mailto:[EMAIL PROTECTED] > Sent: 10 July 2008 20:12 > To: Daniel Brown > Cc: [EMAIL PROTECTED]; Alex Chamberlain; PHP General list > Subject: Re: [PHP] Relocating and POSTing > > On Thu, Jul 10, 2008 at 2:58 PM, Daniel Brown <[EMAIL PROTECTED]> > wrote: > > On Thu, Jul 10, 2008 at 2:32 PM, Richard Heyes <[EMAIL PROTECTED]> > wrote: > >> > >> 1. Use the query string. Eg > >> > >> header('Location: http://www.xxx.com?name=value&name2=value2'); > > > >That's GET, not POST, as the subject requests. ;-P > > > >> 2. Use sessions > > > > if you're not trying to POST the data and are staying within > > the same domain on the same server. ;-P > > I'm pretty sure he means persist POST data on the forwarded request. > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > No virus found in this incoming message. > Checked by AVG - http://www.avg.com > Version: 8.0.138 / Virus Database: 270.4.7/1544 - Release Date: > 10/07/2008 07:37 No virus found in this outgoing message. Scanned by AVG Free 8.0 Checked by AVG - http://www.avg.com Version: 8.0.138 / Virus Database: 270.4.7/1544 - Release Date: 10/07/2008 07:37 No virus found in this outgoing message. Scanned by AVG Free 8.0 Checked by AVG - http://www.avg.com Version: 8.0.138 / Virus Database: 270.4.7/1544 - Release Date: 10/07/2008 07:37 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Relocating and POSTing
I need to send a header('Location:') and send some data along with it - how would I do this?? Thanks, Alex No virus found in this outgoing message. Scanned by AVG Free 8.0 Checked by AVG - http://www.avg.com Version: 8.0.138 / Virus Database: 270.4.7/1544 - Release Date: 10/07/2008 07:37 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Pear DB
> Hi Folks, > > I have just successfully lobbied for the company I work for to use > PHP/MySQL for our next website. My Question is regarding DB abstraction > . I know there is a Pear DB module, is this the best to use ? I have a > vague memory of reading somewhere that there is a newer lib or something > which is considered better ? > > TIA, > JC The newest version of Pear DB is Pear MDB2. I have to say I'm not a great fan of the pear system, but MDB2 is probably one of the best. Alex No virus found in this outgoing message. Scanned by AVG Free 8.0 Checked by AVG - http://www.avg.com Version: 8.0.138 / Virus Database: 270.4.7/1542 - Release Date: 09/07/2008 06:50 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php