php-general Digest 28 Dec 2002 13:02:28 -0000 Issue 1789

Topics (messages 129482 through 129496):

Re: php app frameworks?
        129482 by: Jason Sheets
        129486 by: michael kimsal
        129487 by: Javier

Re: exec, system , backtick
        129483 by: Michael Sims
        129489 by: gamin
        129490 by: gamin

object vs functions
        129484 by: Mat Harris
        129492 by: Paul Reed

Re: PHP 4.3.0 released
        129485 by: The Doctor
        129495 by: Rick Widmer

some multiple array problems...
        129488 by: Victor

XSLT Transformation
        129491 by: Boris Kolev

rounding...sort of
        129493 by: Peter Lavender
        129494 by: Jason Wong

Date fields
        129496 by: Peter Goggin

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [EMAIL PROTECTED]


----------------------------------------------------------------------
--- Begin Message ---
If you go to www.hotscripts.com they have several PHP application
frameworks listed.

I've investigated PHPLIB, and horde (http://www.horde.org) but wound up
creating my own framework because I have not yet found a well documented
framework that does what I need it to do.

Jason

On Fri, 2002-12-27 at 13:51, Jeff D. Hamann wrote:
> What application frameworks are avail for php?
> 
> Jeff.
> 
> --
> Jeff D. Hamann
> Hamann, Donald & Associates, Inc.
> PO Box 1421
> Corvallis, Oregon USA 97339-1421
> Bus. 541-753-7333
> Cell. 541-740-5988
> [EMAIL PROTECTED]
> www.hamanndonald.com
> 
> 
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

--- End Message ---
--- Begin Message ---
Jason Sheets wrote:
If you go to www.hotscripts.com they have several PHP application
frameworks listed.

I've investigated PHPLIB, and horde (http://www.horde.org) but wound up
creating my own framework because I have not yet found a well documented
framework that does what I need it to do.

What were you looking for that you couldn't find in other products/projects?

Thanks.


--- End Message ---
--- Begin Message ---
[EMAIL PROTECTED] (Jason Sheets) wrote in 
[EMAIL PROTECTED]:">news:[EMAIL PROTECTED]:

Have you got any documentation of it to share?

> If you go to www.hotscripts.com they have several PHP application
> frameworks listed.
> 
> I've investigated PHPLIB, and horde (http://www.horde.org) but wound
> up creating my own framework because I have not yet found a well
> documented framework that does what I need it to do.
> 
> Jason
> 
> On Fri, 2002-12-27 at 13:51, Jeff D. Hamann wrote:
>> What application frameworks are avail for php?
>> 
>> Jeff.


-- 
*** s2r - public key: (http://leeloo.mine.nu/s2r-gmx.sig)
--- End Message ---
--- Begin Message ---
On Sat, 28 Dec 2002 02:55:44 +0530, you wrote:

>I tried a simple command line script, in all cases no_file does not exist. I
>do not want the command line script to show the error on the screen but to
>deliver it in the variable $r. But alas, in all 3 cases i get 'rm: canoot
>remove `no_file': No such file or directory'
[script snipped]

I think this is because your error is being sent to stderr but PHP is
only capturing what is sent to stdout.  I was able to acheive your
desired results by redirecting stderr to stdout via the shell.  Try
the following, it worked for me:

#! /usr/bin/php -q
<?
$r = `rm no_file 2>&1`;
echo "the value in r is $r";
?>

If you need more info on the "2>&1" part, consult the Advanced Bash
Scripting Guide here:

http://www.digitaltoad.net/docs/guide/advshell/io-redirection.html
--- End Message ---
--- Begin Message ---
"Maciek Ruckgaber Bielecki" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> how about :
> #!/usr/local/bin/php -q
>
> <?PHP
>     $file = 'no_file';
>
>     if(!is_file($file))
>       $mess =  "no such file";
>     else
>       $mess = shell_exec("ls $file");
>
>     echo $mess."\n";
> ?>
> regards,
> Maciek Ruckaber Bielecki
>

Hi Maciek,

   I used rm as an example to illustrate what i want to do, basically i need
to catch an error if it occurs and STOP the script from going ahead and
include the error in a file for later examination. I would be using 'rm,
unzip, tar, rpm' etc commands from inside a PHP script. Micheal Sims' post
has something interesting.

gamin


--- End Message ---
--- Begin Message ---
"Michael Sims" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
On Sat, 28 Dec 2002 02:55:44 +0530, you wrote:
<--sniped -->

#! /usr/bin/php -q
<?
$r = `rm no_file 2>&1`;
echo "the value in r is $r";
?>

If you need more info on the "2>&1" part, consult the Advanced Bash
Scripting Guide here:

http://www.digitaltoad.net/docs/guide/advshell/io-redirection.html

Thx Michael,

   I tested what you prescribed and it works like a charm. Thanks for the
link to ABSG, a very useful Guide indeed.

Im running a linux system so i have no problem, but how would one redirect
stderr to stdout on a Win machine, if it is possible at all <g>

Have a good day

gamin.


--- End Message ---
--- Begin Message ---
if i have a php script containing some functions, then all i have to do is
include() the file and then call the functions.

if i had an object (taking the example from php.net):

<?php
class foo
{
        function do_foo()
        {
                echo "Doing foo."; 
        }
}

$bar = new foo;
$bar->do_foo();
?>
                     
what is the point of having the object, when i could just call the
functions?

what are the uses of objects over functions/groups of functions?

sorry if this is an innane or frequently asked question.

-- 
Mat Harris                      OpenGPG Public Key ID: C37D57D9
[EMAIL PROTECTED]        www.genestate.com       

Attachment: msg90832/pgp00000.pgp
Description: PGP signature

--- End Message ---
--- Begin Message ---
Objects are not simply a 'grouping' of functions, it's a fundamentally
different approach to programming where variable and functions are
grouped into objects. (OOP, or Object Oriented Programming)

Objects contain all the necessary variables to hold the information on
an item, and all the functions that work on that particular item.

A class is simply a 'blue-print' for an object. (each object is made
from that blueprint.)

Say for instance you were doing a used auto site, and this site had many
cars of different makes and models, and you wanted to assign a different
markup to each car.

Class c_Car
{
  var $make;
  var $model;
  var $color;
  var $cost;
  var $markup;

  function price()
  {
    // '$this->cost' means the $cost variable in the current object.
    $price=$this->cost+($this->cost*$this->markup);
    return $price;
  }
}

// so I have 2 cars....

$car1=new c_Car; 
$car1->cost=10000;    // what the car cost you.
$car1->markup=0.05;   // 5% markup from cost for this car.

$car2=new c_Car;
$car2->cost=7500;     // what the car cost you.
$car2->markup=0.10;   // 10% markup from cost for this car.

echo $car1->price();  // output the price of car1, (10500).
echo $car2->price();  // output the price of car2, (8250).

As you can see, the function works internally to the object.

To learn more, you should really read up on OOP. Overall it's an easier
way to do most sites, but sometimes a simple collection of functions in
an include file may be more practical (usually for sites with very
little PHP).

In the last few months, I have shifted my own programming techniques to
use classes and I have found it tends to work better for almost every
situation. Personally, I wish I had found out about them sooner!

Hope this helps, (And I hope it makes sense, as I'm writing at 4:05am!)

Paul Reed.






-----Original Message-----
From: Mat Harris [mailto:[EMAIL PROTECTED]] 
Sent: Friday, December 27, 2002 21:18
To: [EMAIL PROTECTED]
Subject: [PHP] object vs functions

if i have a php script containing some functions, then all i have to do
is
include() the file and then call the functions.

if i had an object (taking the example from php.net):

<?php
class foo
{
        function do_foo()
        {
                echo "Doing foo."; 
        }
}

$bar = new foo;
$bar->do_foo();
?>
                     
what is the point of having the object, when i could just call the
functions?

what are the uses of objects over functions/groups of functions?

sorry if this is an innane or frequently asked question.

-- 
Mat Harris                      OpenGPG Public Key ID: C37D57D9
[EMAIL PROTECTED]        www.genestate.com       


--- End Message ---
--- Begin Message ---
On Fri, Dec 27, 2002 at 11:12:22AM -0500, Andrei Zmievski wrote:
> The PHP developers are pleased to announce the immediate availability of
> PHP 4.3.0, the latest and greatest version of this extremely popular and
> widely used scripting language.
> 
> This release contains a multitude of changes, bug fixes and improvements
> over the previous one, PHP 4.2.3. It further elevates PHP's standing as
> a serious contender in the general purpose scripting language arena. The
> highlights of this release are listed below:
> 
>  Command line interface
> 
>  This version finalizes the separate command line interface (CLI) that
>  can be used for developing shell and desktop applications (with
>  PHP-GTK). The CLI is always built, but installed automatically only if
>  CGI version is disabled via --disable-cgi switch during configuration.
>  Alternatively, one can use make install-cli target. On Windows CLI can
>  be found in cli folder.
> 
>  CLI has a number of differences compared to other server APIs. More
>  information can be found here:
> 
>      * PHP Manual: Using PHP from the command line
>        http://www.php.net/manual/en/features.commandline.php
> 
> 
>  Streams
> 
>  A very important "under the hood" feature is the streams API. It
>  introduces a unified approach to the handling of files, pipes, sockets,
>  and other I/O resources in the PHP core and extensions.
> 
>  What this means for users is that any I/O function that works with
>  streams (and that is almost all of them) can access built-in protocols,
>  such as HTTP/HTTPS and FTP/FTPS, as well as custom protocols registered
>  from PHP scripts. For more information please see:
> 
>      * List of Supported Protocols/Wrappers
>        http://www.php.net/manual/en/wrappers.php
> 
>      * Streams API
>        http://www.php.net/manual/en/streams.php
> 
> 
>  New build system
> 
>  This iteration of the build system, among other things, replaces the
>  slow recursive make with one global Makefile and eases the integration
>  of proper dependencies. Automake is only needed for its aclocal tool.
>  The build process is now more portable and less resource-consuming.
> 
> 
>  PHP 4.3.0 has many improvements and enhancements:
> 
>      * GD library is now bundled with the distribution and it is
>        recommended to always use the bundled version
>      * vpopmail and cybermut extensions are moved to PECL
>      * several deprecated extensions (aspell, ccvs, cybercash, icap) and
>        SAPIs (fastcgi, fhttpd) are removed
>      * speed improvements in a variety of string functions
>      * Apache2  filter is improved, but is still considered experimental
>        (use with PHP in prefork and not worker (thread) model since many
>        extensions based on external libraries are not thread safe)
>      * various security fixes (imap, mysql, mcrypt, file upload, gd, etc)
>      * new SAPI for embedding PHP in other applications (experimental)
>      * much better test suite
>      * significant improvements in dba, gd, pcntl, sybase, and xslt
>        extensions
>      * debug_backtrace() should help with debugging
>      * error messages now contain URLs linking to pages describing the
>        error or function in question
>      * Zend Engine has some fixes and minor performance enhancements
>      * and TONS of other fixes, updates, new functions, etc
> 
> For the full list of changes in PHP 4.3.0, see the NEWS file
> (http://www.php.net/ChangeLog-4.php).
> 
> Thank you to all who coded, tested, and documented this release!
> 
> -Andrei                                       http://www.gravitonic.com/
> 
> "It's an emergent property of connected human minds that
> they create things for one another's pleasure and to conquer
> their uneasy sense of being too alone." -- Eben Moglen
>

Is it just my or are there problems with static Aapche 1.3.27 compiles?

 
Script started on Fri Dec 27 20:34:45 2002
nl2k.ca//usr/source/php-4.3.0$ cat configphp
configure --prefix=/usr/contrib --localstatedir=/var --infodir=/usr/share/info 
--mandir=/usr/share/man --with-low-memory --with-elf --with-x   --with-mysql 
--with-zlib --enable-track-vars --enable-debug  --enable-versioning 
--with-config-file-path=/usr/local/lib --with-iconv=/usr --with-openssl=/usr/contrib  
--enable-ftp --with-gd=/usr --enable-imap --with-bz2 
--with-apache=/usr/source/apache_1.3.27_nonSSL/  --with-pgsql=/usr/contrib/pgsql 
--enable-gd-native-ttf --with-jpeg-dir=/usr --with-png-dir=/usr 
--with-freetype-dir=/usr  --with-xpm-dir=/usr/X11/lib 
nl2k.ca//usr/source/php-4.3.0$ make
nl2k.ca//usr/source/php-4.3.0$ make install
Installing PHP CLI binary:        /usr/contrib/bin/
Installing PHP SAPI module
Installing shared extensions:     
/usr/contrib/lib/php/extensions/debug-non-zts-20020429/
Installing PEAR environment:      /usr/contrib/lib/php/
[PEAR] Archive_Tar    - already installed: 0.9
[PEAR] Console_Getopt - already installed: 1.0
[PEAR] PEAR           - already installed: 1.0b3
[PEAR] DB             - already installed: 1.3
[PEAR] HTTP           - already installed: 1.2
[PEAR] Mail           - already installed: 1.0.1
[PEAR] Net_SMTP       - already installed: 1.0
[PEAR] Net_Socket     - already installed: 1.0.1
[PEAR] XML_Parser     - already installed: 1.0
[PEAR] XML_RPC        - already installed: 1.0.4
Installing build environment:     /usr/contrib/lib/php/build/
Installing header files:          /usr/contrib/include/php/
Installing helper programs:       /usr/contrib/bin/
  program: phpize
  program: php-config
  program: phpextdist
You have new mail in /var/mail/root
nl2k.ca//usr/source/php-4.3.0$ cd ../mod*perl*27
nl2k.ca//usr/source/mod_perl-1.27$ confi     cat configAapche
cat: configAapche: No such file or directory
nl2k.ca//usr/source/mod_perl-1.27$ cat configAapchechepache
/usr/bin/perl Makefile.PL  APACHE_PREFIX=/var/www 
APACHE_SRC=/usr/source/apache_1.3.27_nonSSL/src EVERYTHING=1 DO_HTTPD=1 USE_APACI=1 
PERL_MARK_WHERE=1 PERL_STACKED_HANDLERS=1 ALL_HOOKS=1 PERL_METHOD_HANDLERS=1 
PERL_DIRECTIVE_HANDLERS=1 PERL_TABLE_API=1 PERL_LOG_API=1 PERL_URI_API=1 
PERL_UTIL_API=1 PERL_FILE_API=1 PERL_SECTIONS=1 PERL_SSI=1 
APACI_ARGS=--prefix=/usr/contrib,--exec-prefix=/usr/contrib,--sbindir=/usr/contrib/bin,--mandir=/usr/share/man,--sysconfdir=/var/www/conf,--datadir=/var/www,--localstatedir=/var,--runtimedir=/var/run,--logfiledir=/var/log/httpd,--proxycachedir=/var/proxy,--enable-suexec,--suexec-userdir=html,--enable-module=most,--activate-module=src/modules/php4/libphp4.a,--activate-module=src/modules/extra/mod_gzip.o,--activate-module=src/modules/extra/mod_throttle.o,--activate-module=src/modules/frontpage/mod_frontpage.o,--enable-rule=EXPAT,--activate-module=src/modules/ruby/libruby.a

nl2k.ca//usr/source/mod_perl-1.27$ configApache
Will configure via APACI
cp apaci/Makefile.libdir 
/usr/source/apache_1.3.27_nonSSL/src/modules/perl/Makefile.libdir
cp apaci/Makefile.tmpl /usr/source/apache_1.3.27_nonSSL/src/modules/perl/Makefile.tmpl
cp apaci/README /usr/source/apache_1.3.27_nonSSL/src/modules/perl/README
cp apaci/configure /usr/source/apache_1.3.27_nonSSL/src/modules/perl/configure
cp apaci/libperl.module 
/usr/source/apache_1.3.27_nonSSL/src/modules/perl/libperl.module
cp apaci/mod_perl.config.sh 
/usr/source/apache_1.3.27_nonSSL/src/modules/perl/mod_perl.config.sh
cp apaci/load_modules.pl 
/usr/source/apache_1.3.27_nonSSL/src/modules/perl/load_modules.pl
cp apaci/find_source /usr/source/apache_1.3.27_nonSSL/src/modules/perl/find_source
cp apaci/apxs_cflags /usr/source/apache_1.3.27_nonSSL/src/modules/perl/apxs_cflags
cp apaci/perl_config /usr/source/apache_1.3.27_nonSSL/src/modules/perl/perl_config
cp apaci/mod_perl.exp /usr/source/apache_1.3.27_nonSSL/src/modules/perl/mod_perl.exp
PerlDispatchHandler.........enabled
PerlChildInitHandler........enabled
PerlChildExitHandler........enabled
PerlPostReadRequestHandler..enabled
PerlTransHandler............enabled
PerlHeaderParserHandler.....enabled
PerlAccessHandler...........enabled
PerlAuthenHandler...........enabled
PerlAuthzHandler............enabled
PerlTypeHandler.............enabled
PerlFixupHandler............enabled
PerlHandler.................enabled
PerlLogHandler..............enabled
PerlInitHandler.............enabled
PerlCleanupHandler..........enabled
PerlRestartHandler..........enabled
PerlStackedHandlers.........enabled
PerlMethodHandlers..........enabled
PerlDirectiveHandlers.......enabled
PerlTableApi................enabled
PerlLogApi..................enabled
PerlUriApi..................enabled
PerlUtilApi.................enabled
PerlFileApi.................enabled
PerlConnectionApi...........enabled
PerlServerApi...............enabled
PerlSections................enabled
PerlSSI.....................enabled
PERL_MARK_WHERE.............enabled (experimental)
Will run tests as User: 'nobody' Group: 'wheel'
(cd /usr/source/apache_1.3.27_nonSSL && CC="cc" CFLAGS=" -DPERL_MARK_WHERE=1 
-fno-strict-aliasing -I/usr/local/include" ./configure 
--activate-module=src/modules/perl/libperl.a --disable-rule=EXPAT 
--prefix=/usr/contrib --exec-prefix=/usr/contrib --sbindir=/usr/contrib/bin 
--mandir=/usr/share/man --sysconfdir=/var/www/conf --datadir=/var/www 
--localstatedir=/var --runtimedir=/var/run --logfiledir=/var/log/httpd 
--proxycachedir=/var/proxy --enable-suexec --suexec-userdir=html --enable-module=most 
--activate-module=src/modules/php4/libphp4.a 
--activate-module=src/modules/extra/mod_gzip.o 
--activate-module=src/modules/extra/mod_throttle.o 
--activate-module=src/modules/frontpage/mod_frontpage.o --enable-rule=EXPAT 
--activate-module=src/modules/ruby/libruby.a)
Configuring for Apache, Version 1.3.27
 + using installation path layout: Apache (config.layout)
 + activated perl module (modules/perl/libperl.a)
 + activated php4 module (modules/php4/libphp4.a)
 + activated gzip module (modules/extra/mod_gzip.o)
 + activated throttle module (modules/extra/mod_throttle.o)
 + activated frontpage module (modules/frontpage/mod_frontpage.o)
 + activated ruby module (modules/ruby/libruby.a)
Creating Makefile
Creating Configuration.apaci in src
Creating Makefile in src
 + configured for BSDI platform
 + setting C pre-processor to cc -E
 + checking for system header files
 + adding selected modules
    o rewrite_module uses ConfigStart/End
      enabling DBM support for mod_rewrite
    o dbm_auth_module uses ConfigStart/End
    o python_module uses ConfigStart/End
    o perl_module uses ConfigStart/End
      + mod_perl build type: OBJ
      + id: mod_perl/1.27
      + id: Perl/v5.8.0 (bsdos) [/usr/bin/perl]
      + setting up mod_perl build environment
      + adjusting Apache build environment
      + enabling Perl support for SSI (mod_include)
    o php4_module uses ConfigStart/End
    o ruby_module uses ConfigStart/End
 + using system Expat
 + checking sizeof various data types
 + doing sanity check on compiler and options
** A test compilation with your Makefile configuration
** failed.  The below error output from the compilation
** test will give you an idea what is failing. Note that
** Apache requires an ANSI C Compiler, such as gcc. 

======== Error Output for sanity check ========
cd ..; cc  -DMOD_PERL -DUSE_PERL_SSI -fno-strict-aliasing -I/usr/local/include 
-DNO_DL_NEEDED -DPERL_MARK_WHERE=1 -fno-strict-aliasing -I/usr/local/include `./apaci` 
-I/usr2/source/mod_python-2.7.8/src/include 
-I/usr2/source/apache_1.3.27_nonSSL/src/include 
-I/usr2/source/apache_1.3.27_nonSSL/src/os/unix -I/usr2/source/Python-2.2.2 
-I/usr2/source/Python-2.2.2/Include -I. -I/usr/libdata/perl5/i386-bsdos/CORE  -Xlinker 
-export-dynamic  -o helpers/dummy helpers/dummy.c   -L/usr/contrib/lib -leruby 
-L/usr/contrib/lib -lruby -ldl -lm  -Wl,-rpath,/usr/contrib/lib 
-Wl,-rpath,/usr/X11R6/lib -Wl,-rpath,/usr/contrib/pgsql/lib  -rdynamic 
-L/usr/contrib/lib -L/usr/X11R6/lib -L/usr/contrib/pgsql/lib -Lmodules/php4 
-L../modules/php4 -L../../modules/php4 -lmodphp4 -export-symbols 
/usr2/source/php-4.3.0/sapi/apache/php.sym   -rdynamic -L/usr/contrib/lib 
-L/usr/X11R6/lib -L/usr/contrib/pgsql/lib   -lpq -liconv -lgd -lfreetype -lX11 -lXpm 
-lpng -lz -ljpeg -lbz2 -lz -lssl -lcrypto -lm -ldl    -lm  
/usr2/source/Python-2.2.2/libpython2.2.a     -L/usr/X11/lib -L/usr/local/lib 
/usr/libdata/perl5/i386-bsdos/auto/DynaLoader/DynaLoader.a 
-L/usr/libdata/perl5/i386-bsdos/CORE -lperl -lutil -lbind -ldl -ldld -lm -lc  -lexpat
ld:/usr2/source/php-4.3.0/sapi/apache/php.sym: file format not recognized; treating as 
linker script
ld:/usr2/source/php-4.3.0/sapi/apache/php.sym:2: syntax error
*** Error code 1

Stop.
============= End of Error Report =============

 Aborting!
Checking CGI.pm VERSION..........ok
Checking for LWP::UserAgent......ok
Checking for HTML::HeadParser....ok
Writing Makefile for Apache
Writing Makefile for Apache::Connection
Writing Makefile for Apache::Constants
Writing Makefile for Apache::File
Writing Makefile for Apache::Leak
Writing Makefile for Apache::Log
Writing Makefile for Apache::ModuleConfig
Writing Makefile for Apache::PerlRunXS
Writing Makefile for Apache::Server
Writing Makefile for Apache::Symbol
Writing Makefile for Apache::Table
Writing Makefile for Apache::URI
Writing Makefile for Apache::Util
Writing Makefile for mod_perl
*** BSDI users: be sure to read the INSTALL `Notes' section ***
You have new mail in /var/mail/root
nl2k.ca//usr/source/mod_perl-1.27$ exit
exit

Script done on Fri Dec 27 20:36:58 2002
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

-- 
Member - Liberal International  On 11 Sept 2001 the WORLD was violated.
This is [EMAIL PROTECTED]       Ici [EMAIL PROTECTED]
Society MUST be saved! Extremists must dissolve.  
Merry Christmas 2002 and Happy 2003
--- End Message ---
--- Begin Message ---
At 08:40 PM 12/27/02 -0700, The Doctor wrote:


Is it just my or are there problems with static Aapche 1.3.27 compiles?
I don't know if it is _just_ you, but my static install compiled and is running just fine.

SuSE 8.0

php 4.3.0

Apache 1.3.27

Mod_SSL 2.8.12-1.3.27

OpenSSL 0.9.6h

ming 0.2a

pdflib 4.0.3

./configure --with-apache=../apache --with-mysql --with-pgsql=/usr --enable-cli --enable-calendar --enable-debug=no --with-config-file=/web/conf --with-PEAR --with-jpeg-dir=/usr/local --with-phg-dir=/usr/local --with-zlib-dir=/usr/local --with-gd=/usr --enable-gd-native-ttf --with-freetype=/usr/include/freetype2 --with-pdflib=/usr/local --with-ming --enable-magic-quotes --with-mm=../mm --with-pspell




Script started on Fri Dec 27 20:34:45 2002
nl2k.ca//usr/source/php-4.3.0$ cat configphp

configure --prefix=/usr/contrib --localstatedir=/var --infodir=/usr/share/info --mandir=/usr/share/man --with-low-memory --with-elf --with-x --with-mysql --with-zlib --enable-track-vars --enable-debug --enable-versioning --with-config-file-path=/usr/local/lib --with-iconv=/usr --with-openssl=/usr/contrib --enable-ftp --with-gd=/usr --enable-imap --with-bz2 --with-apache=/usr/source/apache_1.3.27_nonSSL/ --with-pgsql=/usr/contrib/pgsql --enable-gd-native-ttf --with-jpeg-dir=/usr --with-png-dir=/usr --with-freetype-dir=/usr --with-xpm-dir=/usr/X11/lib

--- End Message ---
--- Begin Message ---
I am trying to make a calculator that figures out the total price
(calculates tax sums up price for print size times quantity etc.) and
the mechanism all works fine - but only when the user checks
SEQUENTIALLY from their list of available picture. 

The user should be able to select from their list of pictures at random,
and the script should be able to calculate the total price, but after
one image is skipped, if any pictures after the skipped one is selected
the script thinks that the user chose size 4x6 and quantity of 1 for
those (those are default values) 

note that I am also using arrays and that may be what is causing
problem, - bad array data input. Please help if u can and it doesn't
take u too much time.

The page that gives me trouble is order_form.php

This is what calculated the total value:

(don't get overwhelmed by the code, at the bottom there is clearer
explanation)

________________________________________________

# calculate pricing
if (isset($_POST['check_price']) && isset($_SESSION['f_username']) &&
isset($quantity) && isset($size)) {
        # if no picture checked but update submitted, then lets thell
the user how stupid they are
        if (empty($check))
        {       
                echo ('One or more pictures must be checked in order to
verify price.');
                exit;
        }
                
        # let us do some math, like taxes, discounts, etc.
        for ($i=0; $i<sizeof($_POST['check']); $i++)
        {
                # if the data in the quantity is not pure numbers then
we abort
                if (!is_numeric($quantity[$i]))
                {       
                        echo ('Quantity must be defined only in
numbers.');
                        exit;
                }
                
                # getting the array data into variables
                $ins_size = $size[$i];
                $ins_quantity = $quantity[$i];
                
                ######################
                # 4x6 pricing matrix #
                ######################
                
                # less than or equal to 50
                if ($ins_size == '4x6' && $ins_quantity <= '50')
                {
                        $price = '0.49';
                }
                
                # 51 to 100
                if ($ins_size == '4x6' && $ins_quantity >= '51' &&
$ins_quantity <= '100')
                {
                        $price = '0.45';
                }
                
                # 101 to 150
                if ($ins_size == '4x6' && $ins_quantity >= '101' &&
$ins_quantity <= '150')
                {
                        $price = '0.40';
                }
                
                # 151 to infinity
                if ($ins_size == '4x6' && $ins_quantity >= '151')
                {
                        $price = '$0.30';
                }
                
                ##########################
                # 2.5x3.5 pricing matrix #
                ##########################
                
                # less than or equal to 50
                if ($ins_size == '2.5x3.5' && $ins_quantity <= '50')
                {
                        $price = '0.49';
                }
                
                # 51 to 100
                if ($ins_size == '2.5x3.5' && $ins_quantity >= '51' &&
$ins_quantity <= '100')
                {
                        $price = '0.45';
                }
                
                # 101 to 150
                if ($ins_size == '2.5x3.5' && $ins_quantity >= '101' &&
$ins_quantity <= '150')
                {
                        $price = '0.40';
                }
                
                # 151 to infinity
                if ($ins_size == '2.5x3.5' && $ins_quantity >= '151')
                {
                        $price = '0.30';
                }
                
                ########################
                # 3.5x5 pricing matrix #
                ########################
                
                # less than or equal to 50
                if ($ins_size == '3.5x5' && $ins_quantity <= '50')
                {
                        $price = '0.49';
                }
                
                # 51 to 100
                if ($ins_size == '3.5x5' && $ins_quantity >= '51' &&
$ins_quantity <= '100')
                {
                        $price = '0.45';
                }
                
                # 101 to 150
                if ($ins_size == '3.5x5' && $ins_quantity >= '101' &&
$ins_quantity <= '150')
                {
                        $price = '0.40';
                }
                
                # 151 to infinity
                if ($ins_size == '3.5x5' && $ins_quantity >= '151')
                {
                        $price = '0.30';
                }
                
                ######################
                # 5x7 pricing matrix #
                ######################
                
                # less than or equal to 50
                if ($ins_size == '5x7' && $ins_quantity <= '50')
                {
                        $price = '1.99';
                }
                
                # 51 to 100
                if ($ins_size == '5x7' && $ins_quantity >= '51' &&
$ins_quantity <= '100')
                {
                        $price = '1.99';
                }
                
                # 101 to 150
                if ($ins_size == '5x7' && $ins_quantity >= '101' &&
$ins_quantity <= '150')
                {
                        $price = '1.99';
                }
                
                # 151 to infinity
                if ($ins_size == '5x7' && $ins_quantity >= '151')
                {
                        $price = '1.99';
                }
                
                #######################
                # 8x10 pricing matrix #
                #######################
                
                # less than or equal to 50
                if ($ins_size == '8x10' && $ins_quantity <= '50')
                {
                        $price = '4.99';
                }
                
                # 51 to 100
                if ($ins_size == '8x10' && $ins_quantity >= '51' &&
$ins_quantity <= '100')
                {
                        $price = '4.99';
                }
                
                # 101 to 150
                if ($ins_size == '8x10' && $ins_quantity >= '101' &&
$ins_quantity <= '150')
                {
                        $price = '4.99';
                }
                
                # 151 to infinity
                if ($ins_size == '8x10' && $ins_quantity >= '151')
                {
                        $price = '4.99';
                }
                
                #######################
                # 8x12 pricing matrix #
                #######################
                
                # less than or equal to 50
                if ($ins_size == '8x12' && $ins_quantity <= '50')
                {
                        $price = '4.99';
                }
                
                # 51 to 100
                if ($ins_size == '8x12' && $ins_quantity >= '51' &&
$ins_quantity <= '100')
                {
                        $price = '4.99';
                }
                
                # 101 to 150
                if ($ins_size == '8x12' && $ins_quantity >= '101' &&
$ins_quantity <= '150')
                {
                        $price = '4.99';
                }
                
                # 151 to infinity
                if ($ins_size == '8x12' && $ins_quantity >= '151')
                {
                        $price = '4.99';
                }
                
                ########################
                # 11x14 pricing matrix #
                ########################
                
                # less than or equal to 50
                if ($ins_size == '11x14' && $ins_quantity <= '50')
                {
                        $price = '8.99';
                }
                
                # 51 to 100
                if ($ins_size == '11x14' && $ins_quantity >= '51' &&
$ins_quantity <= '100')
                {
                        $price = '8.99';
                }
                
                # 101 to 150
                if ($ins_size == '11x14' && $ins_quantity >= '101' &&
$ins_quantity <= '150')
                {
                        $price = '8.99';
                }
                
                # 151 to infinity
                if ($ins_size == '11x14' && $ins_quantity >= '151')
                {
                        $price = '8.99';
                }
                
                ########################
                # 12x18 pricing matrix #
                ########################
                
                # less than or equal to 50
                if ($ins_size == '12x18' && $ins_quantity <= '50')
                {
                        $price = '14.99';
                }
                
                # 51 to 100
                if ($ins_size == '12x18' && $ins_quantity >= '51' &&
$ins_quantity <= '100')
                {
                        $price = '14.99';
                }
                
                # 101 to 150
                if ($ins_size == '12x18' && $ins_quantity >= '101' &&
$ins_quantity <= '150')
                {
                        $price = '14.99';
                }
                
                # 151 to infinity
                if ($ins_size == '12x18' && $ins_quantity >= '151')
                {
                        $price = '14.99';
                }
                
                # do the math for each print
                $cost_total = ($price * $ins_quantity);
                # $tax isset at the beginning of page
                $cost_tax = ($cost_total * $tax);
                $cost = ($cost_total + $cost_tax);
                
                # to round sintax
                # round(1.95583, 2);
                
                echo ('Size: <b>'.$ins_size.'</b> Quantity:
<b>'.$ins_quantity.'</b> Price: <b>$'.round($cost, 2).'</b><br />');
                
                # put each cost value into an array to hold
                $cost_cache[$i] = round($cost, 2);
                
        }
        
        # calculate total
        $total = array_sum($cost_cache);
        
        
        echo ('<br />Total: '.$total);
        exit;
        
}

______________________________________________

and this is the form:

______________________________________________


<h4>Please select from below the pictures you want printed:</h4>
                
                <form name="order" method="post" action="">'
        );

        mysql_db(); # engage connection

        # Formulate the query 
        $picture_list = mysql_query
        (
                "SELECT ID, picture_name 
                FROM kodak_user_pictures 
                WHERE username = '$_SESSION[f_username]'"
        )
        or die ('Unable to execute query. 1 '.mysql_error());

        # start table for the pictures
        echo 
        (
                '<table>
                        <tr>
                                <td colspan="2">
                                        <b>Picture name</b>
                                </td>
                                <td>
                                        <b>Size</b>
                                </td>
                                <td>
                                        <b>Quantity</b>
                                </td>
                        </tr>'
        );
        
        # show user's pictures
        while ($row = mysql_fetch_array($picture_list)) 
        { 
                # Insert query info into variable
                $ID = $row["ID"];
                $picture_name = $row["picture_name"];

                # Strip down slashes
                $picture_name = stripslashes($picture_name);

                # show available pictures
                echo 
                (
                        '<tr>
                                <td> 
                                        <input type="checkbox"
name="check[]" value="'.$ID.'">
                                </td>
                                <td>
                                        '.$picture_name.'
                                </td>
                                <td>
                                        <select name="size[]">
                                                <option
value="2.5x3.5">2.5x3.5</option>
                                                <option
value="3.5x5">3.5x5</option>
                                                <option value="4x6"
selected="selected">4x6</option>
                                                <option
value="5x7">5x7</option>
                                                <option
value="8x10">8x10</option>
                                                <option
value="8x12">8x12</option>
                                                <option
value="11x14">11x14</option>
                                                <option
value="12x18">12x18</option>
                                        </select>
                                </td>
                                <td>
                                        <input name="quantity[]"
type="text" value="1" size="3" maxlength="3">
                                </td>
                        </tr>'
                );
                
        } # end show available pictures
        
        # see if the total was calculated, if not then say 0.00
        if (isset($total))
        {
                $total = $total;
        }
        else
        {
                $total = '0.00';
        }
        
        echo 
        (
                '</table>
                
                <br />
                
                Total cost: <b> $'.$total.'</b> <input type="submit"
name="check_price" value="Update">
                
                <h4>When finished setting order press "Submit".</h4>
                
                <input type="submit" name="make_order" value="Submit">
                <input type="reset" name="reset" value="Reset">
                 or
                <a href="picture_manager.php">Cancel</a>
                
                </p> 
                
                </form>'



_____________________________________________________

It might help to see the forms html code:

This can be viewed at:

http://rapidphotoimagecentre.com/picture_manager/order_form.php 

(Login: test pass: test) <- will be in use by me

Make a new user (your name whatever) at:

http://rapidphotoimagecentre.com/picture_manager/

__________________________________________

the arrays are: 

size[];

quantity[];

and 

check[];


so here is and example of the problem:

this is the default:

Picture name                            Size            Quantity
hitachi_4_color.gif             4x6             1
rough_dubs.gif                  4x6             1
system_sound.gif                        4x6             1
peeSnow3.jpg                    4x6             1
bobsqu.gif                              4x6             1
Bluehills.jpg                   4x6             1

Then the use chooses the first two pictures to print:

Size: 4x6 Quantity: 1 Price: $0.56
Size: 5x7 Quantity: 1 Price: $2.29

Total: 2.85

So it works, these are the values I chose, but if I skip one picture it
will get screwed up:

This is what gets calculated:

Size: 4x6 Quantity: 1 Price: $0.56
Size: 5x7 Quantity: 2 Price: $4.58
Size: 4x6 Quantity: 1 Price: $0.56

Total: 5.7

And his is what I actually selected:

Size: 4x6 Quantity: 1 Price: $0.56
Size: 5x7 Quantity: 2 Price: $4.58
Size: 8x10 Quantity: 5 Price: $???

Total: 5.7


Thanks, 

Vic





______________________________________________________________________ 
Post your free ad now! http://personals.yahoo.ca
--- End Message ---
--- Begin Message ---
Hello php-general,

  I have a problem with XSLT Transformation. I have in one page HTML
  that is in my php page and one $result - where i transform one XSLT
  file. When php show HTML - no problems but when i print $result
  after HTML iyt can be read. In XSLT and XML i use UTF-8 ecnoding
  after transformation i tray to use utf8_decode and encode functions
  but all in $result can be read!
  Please Help me !

  Best regards,
  Boris                          mailto:[EMAIL PROTECTED]

--- End Message ---
--- Begin Message ---
Hi everyone,

I have a nubmer: 4.1 but I only want the whole number 4, even if it's
4.9, so this rules out using round (Unless I missed a parameter).

How could I do this.. I'm drawing a blank...

Pete



--- End Message ---
--- Begin Message ---
On Saturday 28 December 2002 17:49, Peter Lavender wrote:
> Hi everyone,
>
> I have a nubmer: 4.1 but I only want the whole number 4, even if it's
> 4.9, so this rules out using round (Unless I missed a parameter).
>
> How could I do this.. I'm drawing a blank...

floor()

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *

/*
Remark of Dr. Baldwin's concerning upstarts: We don't care to eat toadstools
that think they are truffles.
                -- Mark Twain, "Pudd'nhead Wilson's Calendar"
*/

--- End Message ---
--- Begin Message ---
I have a form with several date fields. I want to be able to set these by
selecting from a calendar display.  Does anyone know of any php function or
code which would let me do this?

Regards

Peter Goggin

--- End Message ---

Reply via email to