Re: [PHP] html forms in php

2005-09-20 Thread Alain Reguera
 I HATE Are you sure? prompts.  If I wasn't sure, I wouldn't have
 clicked it in the first place.
 
 If you want to make your users happy, trust them when they say
 Delete, but make it easy to undo.  Instead of deleting the records,
 just set the Delete flag and timestamp.  Then when the odd user
 makes a mistake, just unset that flag.  After a period of time, you
 can really delete the records that were marked a few days ago.

Thanks for that comment Scott, it helps me a lot to see what I didn't.
I've been developing with Are you sure? confirmation and it really
makes things difficult to users and slow actions' time to be
committed. Now, I've changed and all is more nice.

Thanks again, feel this is a very good practice.

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



Re: [PHP] Re: Problem with mysql_connect(...)

2005-09-20 Thread viraj
http://www.experts-exchange.com/Web/Web_Languages/PHP/PHP_Installation/Q_21077014.html

~viraj.


On 9/19/05, Mark Rees [EMAIL PROTECTED] wrote:
 
 I'm trying to connect to my MySQL server with mysql_connect(...). The server
 is up and running, and I'm running Apache with PHP properly installed. :
 
 ---
 But have you got the mysql extension? put this in a script
 
 ?php
  phpinfo();
 ?
 
 and view the output to check
 
 The code
 $hleServer = mysql_connect($host, $user, $password)
  or die(Error: Database. Error code: 1. Contact the web master!);
 
 $host, $user, and $password are set to correct values (checked and double
 checked). The funny thing is that not only does the function call fail, but
 I'm not even getting the text defined by die(...). It seems that the
 function call is more or less a black hole. Of course the rest of the script
 doesn't execute either, I'm just left with a blank page.
 
 I didn't use to have this problem before (using PHP 5 now instead of 4).
 
 Thanks for any input on this problem...
 
 
 Arthur
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 


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



[PHP] Tidying code for PHP5.0.5/PHP4.4.0

2005-09-20 Thread Lester Caine
This type of code is used in a few places, so I'd like a little help 
converting it to 'good code' under the new rules ;)


Get the key from an array ( fails because key(array) )

if( $pId == key( $this-getFunc() ) ) {

In getFunc()

return ( $this-getAssoc(select Id, Content from database...);

Current fix is just to create the array and use that
$keyarray = $this-getFunc();
if( $pGroupId == key( $keyarray ) ) {

This works fine, but is there a 'proper' way to do it now that what 
looked tidy originally fails with an error?


Lester Caine
-
L.S.Caine Electronic Services

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



[PHP] ordimage problem!! (export image from oracle to directory with php)

2005-09-20 Thread Rasim �EN
Hi all oracle+php expert,

we kept all image in oracle db. Now nearly we have 1 000 000 image in
database. we want to export them to directory. but with php we couldn't do
it.

our process : ordimage type - blob type - jpeg file type -
directory(save)

Any body know it? any advice, we appreciate!!

thanks a lot.

rasimsen

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



Re: [PHP] Tidying code for PHP5.0.5/PHP4.4.0

2005-09-20 Thread Jasper Bryant-Greene

Lester Caine wrote:
This type of code is used in a few places, so I'd like a little help 
converting it to 'good code' under the new rules ;)


They're not new rules. PHP is just warning you where it didn't before. 
It was still bad coding practice before.




Get the key from an array ( fails because key(array) )

if( $pId == key( $this-getFunc() ) ) {

In getFunc()

return ( $this-getAssoc(select Id, Content from database...);

Current fix is just to create the array and use that
$keyarray = $this-getFunc();
if( $pGroupId == key( $keyarray ) ) {

This works fine, but is there a 'proper' way to do it now that what 
looked tidy originally fails with an error?


That is the 'proper' way, since you are using key() exactly as it is 
intended to be used, although you could avoid the reference like this:


$keys = array_keys( $this-getFunc() );
if( $pGroupId = $keys[0] ) {

--
Jasper Bryant-Greene
Freelance web developer
http://jasper.bryant-greene.name/

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



RE: [PHP] Re: Suggestions for class design

2005-09-20 Thread Murray @ PlanetThoughtful
 on 09/19/2005 02:33 PM Chris W. Parker said the following:
  Let's take for example a class called 'Customer' that (obviously)
  manipulates customers in the database. Here is a very basic Customer
  class. (Data validation and the like are left out for brevity.)
 
 This is a basic object persistence problem.
 
 
  (Unless I've already got some major design flaws I think we should be
  good to go.)
  
   Where I get tripped up is when I realize I'll need to at some point
   get more than one customer at a time and thus I want to add a method
   called 'get_customers()'.
 
 
 Yes, there is a problem. You are trying to retrieve objects into memory
 before they exist. It makes more sense that you retrieve objects using a
 factory class.
 
 That is the approach of Metastorage. You may want to take a looka at
 Metastorage before you reinvent the wheel.

Hi Manuel,

I very much understand your desire to promote your various projects, but the
original poster is asking a question that is basic to any programmer's
development in object-oriented coding.

Once he understands how to solve class abstraction problems such as the one
he is asking about, he will be better equipped to deal with a wider range of
application development tasks.

This is not to trivialize your Metastorage project (or, to be more accurate,
I know nothing about it, so it's not my place to trivialize it or
otherwise), but to point out that 'out-of-the-box' solutions to fundamental
coding development problems probably ultimately makes for a poorer
programmer. I could well be wrong, but it seems this is a case of give a
man a fish as opposed to teach a man to fish.

Also, and separate from above, I don't understand the relevance of your
comment, You are trying to retrieve objects into memory before they exist.
Unless I'm horribly mistaken [1], the original poster has developed a class
that abstracts a single customer, and is asking the list for suggestions in
how to best approach a need to be able to abstract collections of customers.
This is a normal application development issue, and for the life of me I
can't grasp how your comment relates.

Much warmth,

Murray
---
Lost in thought...
http://www.planetthoughtful.org

[1] And it wouldn't be the first time!

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



Re: [PHP] Tidying code for PHP5.0.5/PHP4.4.0

2005-09-20 Thread Lester Caine

Jasper Bryant-Greene wrote:


Lester Caine wrote:

This type of code is used in a few places, so I'd like a little help 
converting it to 'good code' under the new rules ;)


They're not new rules. PHP is just warning you where it didn't before. 
It was still bad coding practice before.


Since it is not my own code ...
The problem is that little problems like this HAVE been duplicated and 
no one has complained before ;)

Now we have to go through every library and eliminate them ...


Get the key from an array ( fails because key(array) )

if( $pId == key( $this-getFunc() ) ) {

In getFunc()

return ( $this-getAssoc(select Id, Content from database...);

Current fix is just to create the array and use that
$keyarray = $this-getFunc();
if( $pGroupId == key( $keyarray ) ) {

This works fine, but is there a 'proper' way to do it now that what 
looked tidy originally fails with an error?


That is the 'proper' way, since you are using key() exactly as it is 
intended to be used, although you could avoid the reference like this:


$keys = array_keys( $this-getFunc() );
if( $pGroupId = $keys[0] ) {


Actually the proper way would be to get each function to produce a 
single result - but I'm not going to re-code everything :)


I suppose the REAL questions was - Why was using the function in this 
way a 'bad practice', is there any way that it could be made a 'good 
practice' since the intent is so obvious?
I understand the new checks, but I don't see that the original was 
particularly 'bad' - only that under some conditions it might cause a 
problem?


--
Lester Caine
-
L.S.Caine Electronic Services

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



Re: [PHP] Tidying code for PHP5.0.5/PHP4.4.0

2005-09-20 Thread Jasper Bryant-Greene

Lester Caine wrote:
I suppose the REAL questions was - Why was using the function in this 
way a 'bad practice', is there any way that it could be made a 'good 
practice' since the intent is so obvious?
I understand the new checks, but I don't see that the original was 
particularly 'bad' - only that under some conditions it might cause a 
problem?




Basically, in PHP, a reference (such as what key() takes as a parameter 
[1]) can only point to an actual variable, not directly to the result of 
a function. So you have to assign the output of the function to a 
variable first.


From the PHP manual [2]:
| the following examples of passing by reference are invalid:
|
| foo(bar()); // Produces fatal error since PHP 5.1.0
| foo($a = 5); // Expression, not variable
| foo(5); // Produces fatal error

Whether this is the optimal behaviour has been the subject of recent 
debate on this list [3]. Rasmus states that the current behaviour of 
throwing a fatal error will be changed to a notice.


[1] http://php.net/key
[2] http://php.net/language.references.pass
[3] http://marc.theaimsgroup.com/?l=php-generalm=112689425109173w=2
--
Jasper Bryant-Greene
Freelance web developer
http://jasper.bryant-greene.name/

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



Re: [PHP] Suggestions for class design

2005-09-20 Thread Jochem Maas

Hi Chris,

nice thread, good questions - nice to see some real programming
theory being discussed - does us all some good :-)

here is my take, hth:

Chris W. Parker wrote:

Anas Mughal mailto:[EMAIL PROTECTED]
on Monday, September 19, 2005 4:02 PM said:



The simplest way to solve this problem is as follows:

- Have your Customer class hold only attributes for a customer. This
class would only have getter and setter methods. In the Java world,
this is referred to as a JavaBean.  
- Then, have a DAO class that does your data access functions.


Here is a sample DAO class:


[snip]

Ahh.. I guess this is the same thing that Michael Sims suggested?



class CustomerDAO {


function getCustomer(..) {
...
//return a customer
}



So I return a Customer object that has the set and get methods? And does
that mean I do the following?

-set_first_name()
-set_last_name()
-set_address_1()
-set_address_2()
-set_address_3()
-set_city()
-set_state()


me, I have 'data object' that are subclasses of a 'peer' object, the
'peer' class has all the methods for data handling e.g.

Persistent::submit() (update and insert are handled/determined internally)
Persistent::get()
Persistent::find()
Persistent::findRange()
etc..

the 'data object's have definitions that stipulate 'field'  objects
for each field in the database (usually a 1 to 1 relationship but not
always - for instance there is a VectorField for 1 to many stuff, and an
AssocField for many to many stuff).

if I have a Customer class I can do something _like_:

$cust = Persistent::get('Customer', array('CONTACT_ID' = $id));
$cust-firstname = 'Bob';
$cust-lastname = 'Builder';
$cust-submit();

the 'peer' class has __get() and __set() methods that find the requested
'field' object and return or set its value e.g. (very simplified)

class Persistent
{
function __get($name)
{
if (isset($this-fields[$name])) {
return $this-fields[$name]-getValue();
}

throw new Exception(field '$name' does not exist in this 
(.get_class($this).) object!);
}
}

maybe that gives you an idea about how to avoid constantly writing practically
the same getter/setter methods over and over... and also how to avoid
writing practically identical collection getter functions/methods
(how much different will you getCustomers() method be from your getProducts()
method ... in general anyway ... there are always exceptions to the rule! :)


etc.

Or is there a better way to handle it?



function getCustomers(..) {
...
// return a collection of customers
}



How do I return a collection of customers?



Thanks,
Chris.



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



Re: [PHP] Re: about PHP

2005-09-20 Thread viraj
On 9/20/05, Srinivasan Kumar [EMAIL PROTECTED] wrote:
 hello sir,
 I am srinivasan,I am a web designer.I hered about PHP
 is the safest pages while using monetory
 transaction,

mmm! nop, PHP is not providing anything to secure your transactions
otherthan few fuctions to handle your login sessions and support on
few data encryption functions. but you can develop a good web
application/website using PHP.

 so i want to learn about the PHP. so only
 I need to view or run the PHP Pages in my local server

PHP is a server side scripting language, to use php for your website,
you have to install php on your webserver and configure PWS to handle
php pages. for this you need to read some manuals and spent some time
on research and development work.

i recomend you to read a lttle and slowly start PHPing.

http://forums.devarticles.com/archive/t-2574/Article-Discussion-Installing-PHP-Under-Personal-Web-Server


~viraj.

 (i.e.PWS) so only i am asking how to view the PHP
 pages in my local server (i.e.PWS)as a asp page
 
 thanking you for your kindly reply
 K.Srinivasan
 
 --- viraj [EMAIL PROTECTED] wrote:
 
  On 9/20/05, Srinivasan Kumar
  [EMAIL PROTECTED] wrote:
   sir,
this is srinivasan i have to know about the
  php.i.e.
 
  Google is your friend! ..the best is to search/read
  a bit more about
  PHP. follow these links..
 
  http://www.php.net/tut.php
 
 http://www.google.com/search?hl=enlr=oi=defmoreq=define:PHP
 
how can i view the php pages in windows98
  PWS?.could
 
  please be specific. write a little more, explaining
  what you want to
  do with php and your current knowledge in
  programming. so the others
  on the list can help you better to solve your issue.
 
 
  ~viraj.
 
you reply in this regard.
thanking you
k.srinivasan
  
  
   Gabor Hojtsy [EMAIL PROTECTED] wrote:Dear
  Srinivasan Kumar,
  
   Since your problem has nothing to do with
   webmastering of the php.net website, it does
   not belong in here Please contact
   php-general@lists.php.net (a mailing list)
   with support questions or see
  http://php.net/support
   for more support options.
 
 
 
 __
 Do You Yahoo!?
 Tired of spam?  Yahoo! Mail has the best spam protection around
 http://mail.yahoo.com


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



Re: [PHP] Tidying code for PHP5.0.5/PHP4.4.0

2005-09-20 Thread Jochem Maas

Jasper Bryant-Greene wrote:

Lester Caine wrote:

I suppose the REAL questions was - Why was using the function in this 
way a 'bad practice', is there any way that it could be made a 'good 
practice' since the intent is so obvious?
I understand the new checks, but I don't see that the original was 
particularly 'bad' - only that under some conditions it might cause a 
problem?




Basically, in PHP, a reference (such as what key() takes as a parameter 
[1]) can only point to an actual variable, not directly to the result of 
a function. So you have to assign the output of the function to a 
variable first.


 From the PHP manual [2]:
| the following examples of passing by reference are invalid:
|
| foo(bar()); // Produces fatal error since PHP 5.1.0
| foo($a = 5); // Expression, not variable


wtf, Im now officially confused (before I suffered unofficially :-)

if foo() expects one args by reference then why is doing:

foo($a = 5);

..wrong? I always thought that the expression (in this form) 'returns'
the variable? or does it need to be:?

foo( ($a = 5) );

in fact I'm pretty sure that an example (like this) of a fix for
the 'bad coding' practice that is now throwing notices/errors was
given on internals-php quite recently.

I can understand that the following are wrong:

foo(5); // not sure this is wrong.
foo(bar());

but how is:

foo(($a = 5));

different from?:

$a = 5; foo($a);



| foo(5); // Produces fatal error

Whether this is the optimal behaviour has been the subject of recent 
debate on this list [3]. Rasmus states that the current behaviour of 
throwing a fatal error will be changed to a notice.


[1] http://php.net/key
[2] http://php.net/language.references.pass
[3] http://marc.theaimsgroup.com/?l=php-generalm=112689425109173w=2


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



Re: [PHP] can not re-use a object

2005-09-20 Thread [EMAIL PROTECTED]
Ok thanks a lot!

Joe Wollard wrote:

 I have try to use the same $db and to create a new one...

 Are you trying to use the $db object inside of another function later 
 in the code? If so you'll need to use $GLOBALS['db'] instead.
 Sorry, this is the only thing I can think of with your description 
 Have you tried a simple test program that does nothing more than 
 execute your example below 2 or more times?

 ...well, wait, now I did have an issue where the constructor of an 
 object was not being executed while mmcache was running. Do you run 
 mmcache or any other code caching mechanism? (phpinfo() would tell 
 you if you're not sure)

 Good luck!


 On Sep 19, 2005, at 6:26 AM, [EMAIL PROTECTED] wrote:

 Hi! Sorry about the bad english :-[
 I try to re-use an object that manage the mysql connections (it is  code
 from sugarcrm)
 $db = new PearDatabase();
 $var = ' . $user_id .';
 $pregunta = SELECT user_name  FROM users WHERE id = $var;
 $resultado = $db-query($pregunta, true, Error filling in user 
 array: );
 $row = $db-fetchByAssoc($resultado);
 $user_name= $row['user_name'];

 if i try a new query (can be the same one or an other one), i  become
 0
 as result and no error message
 I have try to use the same $db and to create a new one, i have try to
 close the descriptor
 Thanks for help
 pascal

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




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



Re: [PHP] can not re-use a object

2005-09-20 Thread [EMAIL PROTECTED]
Ok!
No i do not run mmcache, $GLOBAL is ok
thanks a lot!
Joe Wollard wrote:

 I have try to use the same $db and to create a new one...

 Are you trying to use the $db object inside of another function later 
 in the code? If so you'll need to use $GLOBALS['db'] instead.
 Sorry, this is the only thing I can think of with your description 
 Have you tried a simple test program that does nothing more than 
 execute your example below 2 or more times?

 ...well, wait, now I did have an issue where the constructor of an 
 object was not being executed while mmcache was running. Do you run 
 mmcache or any other code caching mechanism? (phpinfo() would tell 
 you if you're not sure)

 Good luck!


 On Sep 19, 2005, at 6:26 AM, [EMAIL PROTECTED] wrote:

 Hi! Sorry about the bad english :-[
 I try to re-use an object that manage the mysql connections (it is  code
 from sugarcrm)
 $db = new PearDatabase();
 $var = ' . $user_id .';
 $pregunta = SELECT user_name  FROM users WHERE id = $var;
 $resultado = $db-query($pregunta, true, Error filling in user 
 array: );
 $row = $db-fetchByAssoc($resultado);
 $user_name= $row['user_name'];

 if i try a new query (can be the same one or an other one), i  become
 0
 as result and no error message
 I have try to use the same $db and to create a new one, i have try to
 close the descriptor
 Thanks for help
 pascal

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




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



[PHP] user can post items while outhers cannot?

2005-09-20 Thread Joeffrey Betita
hello
  i installed mysql-standard-4.1.13-pc-linux-gnu-i686.tar.gz, i followed
the instruction on the INSTALL-BINARY file. after that i installed
httpd-2.0.54.tar.gz followed the instruction on the INSTALL file. also
installed php-5.0.4.tar.gz
followed the install intruction in the INSTALL file. CentOS release 4.0
(Final) is the linux distribution. some user when trying to post an item
cannot post an item. they are being redirected to the welcome page. once
they click the post item button. while other user can post an item
succesfully. i been looking at the apache access and error logs and
/var/log/messages no luck. what log files should i be looking for. did i
miss anything while installing on the ./configure [options] mysql, apache,
php etc. on our old server the version of apache-2.0.47, mysql-4.0.15a-log,
php-4.3.3 the OS is RH9 before our only problem is too many connections
error when they browse our website. is this a apache, MySQL, PHP etc.
problem. i just would like to know. any help would be appreciated. thank you
very much.


rgds,
Joeffrey



--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.344 / Virus Database: 267.11.3/106 - Release Date: 9/19/2005

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



Re: [PHP] [Off] How much time should this take?

2005-09-20 Thread Jochem Maas

Brian Dunning wrote:
I got a 12-hour invoice from a consultant who was tasked to do the  
following:


There are people that can do it faster ... then again it seems about right
given the time it takes to customize, tweak and secure allsorts of things...

I might add tho that a 'professional' might consider swapping his copy
of RedHat for a some fresh horse manure and using Debian or somesuch instead
(horse manure can be put to good use in the garden). Debian won't save you
any time but it sure runs faster/safer imho) ;-)

John Nichel's points are all good ones.

never forget that it's very easy to 'lose' a day or more because a machine
configuration is 'playing up' - I remember at my company losing _lots_ of
time trying to get Squid  Apache to play nice (inc SSL) so that the 'web logs'
(from which [webalizer] statistics were generated) were complete/accurate...
and that was just the webserver request logging!

so if the box does what you want, is fast and secure ... then you have a fair 
deal
me thinks (well it depends what he charges per hour - $1000/hour is extortion 
;-).



- Install a Red Hat machine from absolute scratch for PHP/MySQL/Apache

- Copy over some MySQL databases

- Have mod_rewrite working via htaccess, and have wildcard DNS

I realize there are a billion different variables - I don't know  
specifically what distribution he used, or any other variables - but  
what are the chances that his invoice is reasonable? Assume that he  
should know what he's doing without having to learn anything. Thanks...




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



Re: [PHP] Is my feedback form being successfully abused?

2005-09-20 Thread Jochem Maas

Chris W. Parker wrote:

Hello,

About a few weeks ago I started seeing three emails that all come at the
same time (within the same minute) that seem to be trying to exploit a
feedback form I have on our website. Everytime someone submits a
feedback form I am sent the information they entered. The To and From
address are hard coded.


that makes no difference, what the spammer is trying to do is pass
mail headers directly in the body of the email you are generating which when
passed to the SMTP server by whatever function/syscall you use will
be interpreted by the SMTP server as a seperate email to be sent.

this 'fairly recent' class of attack is already quite well documented,
google around for more info.

I don't if any mail classes out there deal with this issue for you,
I wrote a simple function to attempt to check for 'problem' message
bodies:

?php

/* returns true if any of the values in the passed are suspect in terms
 * of someone trying to hack our form based mailer to start sending people
 * spam.
 *
 * simple example:
 *
 * if (emailFieldHackAttempt( $_REQUEST )) {
 * die('off with thy head, spamwannabe!');
 * }
 */
function emailFieldHackAttempt( $fieldVals )
{
$evilStrings = array(
'Content-Type: multipart/mixed;',
'Content-Type: text/plain;',
'boundary=',
'boundary=\\',
'Content-Transfer-Encoding: 7bit',
\nSubject: ,
'MIME-Version: ',
\nbcc: ,
\ncc: ,
\nFrom: ,
\nTo: ,
);

if (is_array($fieldVals)  count($fieldVals)) {
foreach ($evilStrings as $evilStr) {
foreach ($fieldVals as $k = $v) {
if (strstr($v, $evilStr) !== false) {
return true;
}
}
}
}

// nothing going on!
return false;
}

?

any comments or improvements to this function are appreciated.



Here is an example message

[begin]
== Name ==

  [EMAIL PROTECTED]

== Agency ==

  [EMAIL PROTECTED]
Content-Type: multipart/mixed; boundary1815270735==
MIME-Version: 1.0
Subject: a8f1a36a
To: [EMAIL PROTECTED]
bcc: [EMAIL PROTECTED]
From: [EMAIL PROTECTED]

This is a multi-part message in MIME format.

--===1815270735==
Content-Type: text/plain; charset=us-ascii
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit

thgfxnes
--===1815270735==--


== Email ==

  [EMAIL PROTECTED]

== Comment ==

[EMAIL PROTECTED]
[end]

It seems to me that the attemped exploit is unsuccessful because I
cannot find dtdegq or mhko321 in /var/log/maillog. But I wanted to
send this to the list in case someone knows different.


Thanks,
Chris.



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



Re: [PHP] Tidying code for PHP5.0.5/PHP4.4.0

2005-09-20 Thread Jasper Bryant-Greene

Jochem Maas wrote:

Jasper Bryant-Greene wrote:

 From the PHP manual [2]:
| the following examples of passing by reference are invalid:
|
| foo(bar()); // Produces fatal error since PHP 5.1.0
| foo($a = 5); // Expression, not variable


if foo() expects one args by reference then why is doing:

foo($a = 5);

..wrong? I always thought that the expression (in this form) 'returns'
the variable? or does it need to be:?


Yes, but how can you modify $a = 5 from within foo()? It's an 
expression, not something that can be modified. This one is, admittedly, 
kinda shaky.



I can understand that the following are wrong:

foo(5); // not sure this is wrong.


This is definitely wrong. For example:

?php
function foo($a) {
$a = 6;
}

foo(5);
?

Is obviously impossible, as it tries to assign the value 6 to the 
constant value 5.


--
Jasper Bryant-Greene
Freelance web developer
http://jasper.bryant-greene.name/

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



[PHP] Strange issue with xml_parse_into_struct

2005-09-20 Thread Mark Evans

Hi All

I am having an issue when trying to parse an xml document with namespaces.

The XML data I am trying to parse looks like the following

my:object name=__root%3Chtml%3E%0A%3Chead%3E%0A%3Ctitle%3Emy:variable
name='Test'/%3C%2Ftitle%3E%0A%0A%3C%2Fhead%3E%0A%3Cbody%3E%0A%0A%3C%2Fbody%3E%0A%3C%2Fhtml%3E%0A/my:object

A small script to reproduce the problem I am having is as follows (note:
This isnt pretty I know ;-))

?php
$sFile = data.xml;
$xml_parser = xml_parser_create_ns();

if (!($pFile = fopen($sFile, r)))
 {
   die(could not open XML input);
 }

$sData = fread($pFile, filesize($sFile));
fclose($pFile);

if (!xml_parse_into_struct($xml_parser, $sData, $aVals, $aIndex))
 {
 $nErrorCode = xml_get_error_code($xml_parser);
 $sError = xml_error_string($nErrorCode);
 $sErrorMessage = 'XML Parser Error: Error Code: ' . $nErrorCode . ' Error
String: ' . $sError . ' Line Number: ' .
xml_get_current_line_number($xml_parser);
 trigger_error($sErrorMessage, E_USER_WARNING);
 }
?

This script works perfectly on all versions of PHP on Windows.. however 
as soon as I test this on a FreeBSD box running 4.4.0 or a CentOS box 
running 4.3.9 I get the same error


Warning: XML Parser Error: Error Code: 27 Error String: unbound prefix 
Line Number: 1 in /usr/local/www/data-dist/xml/test.php on line 18


If I change

$xml_parser = xml_parser_create_ns();

to

$xml_parser = xml_parser_create();

It does work on both platforms.

The question is (finally ;-)) can anyone see anything wrong with what I 
am trying to do? Is there an issue in xml_parse_into_struct when used 
with  xml_parser_create_ns on non-windows platforms (the latter I dobut 
as I have searched the php bugs section and havent found anything 
relating to this).


TIA

Mark

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



Re: [PHP] Tidying code for PHP5.0.5/PHP4.4.0

2005-09-20 Thread Jochem Maas

Jasper Bryant-Greene wrote:

Jochem Maas wrote:


Jasper Bryant-Greene wrote:


 From the PHP manual [2]:
| the following examples of passing by reference are invalid:
|
| foo(bar()); // Produces fatal error since PHP 5.1.0
| foo($a = 5); // Expression, not variable



if foo() expects one args by reference then why is doing:

foo($a = 5);

..wrong? I always thought that the expression (in this form) 'returns'
the variable? or does it need to be:?



Yes, but how can you modify $a = 5 from within foo()? It's an 
expression, not something that can be modified. This one is, admittedly, 


by definition the expression is evaluated _before_ the function is
called - so the expression is not passed to the function, the result
of the expression is passed ... I was under the impression that the the
expression evaluates to a 'pointer' (I'm sure thats bad terminology) to
$a ... which can taken by reference by the function.

possibly I am completely misunderstanding what goes on here.


kinda shaky.


I can understand that the following are wrong:

foo(5); // not sure this is wrong.



This is definitely wrong. For example:


your example make it clear, thanks!



?php
function foo($a) {
$a = 6;
}

foo(5);
?

Is obviously impossible, as it tries to assign the value 6 to the 
constant value 5.




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



[PHP] Fwd: Code Optimization Help

2005-09-20 Thread Joseph Crawford
Hello Everyone,

I have some code that is using COM to interact with MS Word to create a mail 
merge based on my mysql database, however it is running dreadfully slow 
13.53846 seconds to be exact. This is only running on 34 records, i could 
imagine running this on a few hundred records not to mention thousand. Is 
COM usually this slow? These load times i believe to be accurate as they 
come from zend studio's profiler.
You can see screenshots of the profile @ 
http://codebowl.dontexist.net/bugs/MailMerge/ Below you will see my code, 
anything you guys see that i could do to speed this up quite a bit i would 
appreciate it. It seems the naughty methods are CreateHeader, 
CreateDataSource, CreateDocument.


CODE
=
?php

class MailMerge {
private $mm_data_dir;
private $obj;
private $fieldcnt;
private $rowcnt;
private $letter_template;
private $envelope_template;

public function __construct($list = null, $letter = 'Has_Site', $envelope = 
'Envelope', $data_dir = 'data/mailmerge') {
if(!is_array($list)) throw new Exception('Cannot Create A Mail Merge With An 
Empty List.');
$this-mm_data_dir = 'F:/htdocs/csaf/'.$data_dir;
$this-list = $list;
$this-letter_template = $letter;
$this-envelope_template = $envelope;
$this-initilize();

$this-CreateHeaderFile();
$this-CreateDataSource();
$this-CreateDocument($this-letter_template);
$this-CreateDocument($this-envelope_template);
}

public function __destruct() {
unlink($this-mm_data_dir.'/ds.doc');
unlink($this-mm_data_dir.'/header.doc');
}

private function initilize() {
$this-rowcnt = count($this-list);
$this-fieldcnt = count($this-list[0]);
}

private function Close() {
$this-obj-Documents-Close();
}

private function Quit() {
$this-obj-Quit(); 
}

private function Release() {
$this-obj = NULL; 
}

private function CreateHeaderFile() {
$this-obj = new COM(word.application) or die('Couldnt load Word!');
if(!is_object($this-obj)) throw new Exception('Unable to instanciate 
Word!');
$this-obj-Documents-Add();
$this-obj-ActiveDocument-Tables-Add($this-obj-Selection-Range,1,$this-fieldcnt);

for($i = 0; $i = $this-rowcnt; $i++) {
foreach($this-list[$i] as $key = $value) {
$this-obj-Selection-TypeText($key);
$this-obj-Selection-MoveRight();
} 
}
$this-obj-ActiveDocument-SaveAs($this-mm_data_dir.'/header.doc');
$this-Close();
$this-Quit();
$this-Release();
}

private function CreateDataSource() {
$this-obj = new COM(word.application);
if(!is_object($this-obj)) throw new Exception('Unable to instanciate 
Word!');
$this-obj-Documents-Add();
$this-obj-ActiveDocument-Tables-Add($this-obj-Selection-Range,$this-rowcnt,$this-fieldcnt);

for($i = 0; $i = $this-rowcnt; $i++) {
foreach($this-list[$i] as $key = $value) {
$this-obj-Selection-TypeText($value);
$this-obj-Selection-MoveRight();
}
}
$this-obj-ActiveDocument-SaveAs($this-mm_data_dir.'/ds.doc');
$this-Close();
$this-Quit();
$this-Release();
}

private function CreateDocument($template) {
$this-obj = new COM(word.application); 
if(!is_object($this-obj)) throw new Exception('Unable to instanciate 
Word!');
$this-obj-Documents-Open($this-mm_data_dir.'/'.$template.'.dot');
$this-obj-ActiveDocument-MailMerge-OpenHeaderSource($this-mm_data_dir.'/header.doc');
$this-obj-ActiveDocument-MailMerge-OpenDataSource($this-mm_data_dir.'/ds.doc');
$this-obj-ActiveDocument-MailMerge-Execute();
$this-obj-ActiveDocument-SaveAs($this-mm_data_dir.'/'.$template.'.doc');
$this-Close();
$this-Quit();
$this-Release();
}
}
?

-- 
Joseph Crawford Jr.
Codebowl Solutions, Inc.
1-802-671-2021
[EMAIL PROTECTED]


[PHP] Easy question - delete strings from the beginning of space...

2005-09-20 Thread Gustav Wiberg

Hi there!

I guess this is an easy question. I have string...

Hello you

and I want to get the Hello part.

How do I do that? (I can of course search for first occurence of space and 
then use substr, but I guess there is an easier solution?


/G
http://www.varupiraten.se/

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



[PHP] Re: User error handler must not modify error context (solved)

2005-09-20 Thread Noel
Why not top-post? It's much faster to read so I won't have to scroll 
down to read the message.


Michael Sims already solved my problem. But thanks for the help and 
to Robert also. :)


Jasper Bryant-Greene...

Please don't top-post. Sorry, I assumed that code was part of your 
error_handler. Can you please post your user_error_handler() function?


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



Re: [PHP] Fwd: Code Optimization Help

2005-09-20 Thread Jochem Maas

Joseph Crawford wrote:

Hello Everyone,

I have some code that is using COM to interact with MS Word to create a mail 
merge based on my mysql database, however it is running dreadfully slow 
13.53846 seconds to be exact. This is only running on 34 records, i could 
imagine running this on a few hundred records not to mention thousand. Is 
COM usually this slow? These load times i believe to be accurate as they 
come from zend studio's profiler.
You can see screenshots of the profile @ 
http://codebowl.dontexist.net/bugs/MailMerge/ Below you will see my code, 
anything you guys see that i could do to speed this up quite a bit i would 
appreciate it. It seems the naughty methods are CreateHeader, 
CreateDataSource, CreateDocument.



CODE
=
?php

class MailMerge {
private $mm_data_dir;
private $obj;
private $fieldcnt;
private $rowcnt;
private $letter_template;
private $envelope_template;

public function __construct($list = null, $letter = 'Has_Site', $envelope = 
'Envelope', $data_dir = 'data/mailmerge') {
if(!is_array($list)) throw new Exception('Cannot Create A Mail Merge With An 
Empty List.');


// an off topic thought...
if (!is_array($list) || empty($list)) { throw new Exception(' ... '); }

more on topic ... you might try to make the com object
a singleton rather than creating a new one for each record
you are processing, and then clear the word document before
starting a new record... I could imagine starting up an
instance of Word for every record could be your bottleneck ...
given the ammount of time it takes to start up an interactive
instance of Word! (which is measured in seconds on my fairly
up2date laptop). i.e. only do this line once, for instance (untested):

class MailMerge {

static protected function getWord($clean = false)
{
static $obj;
if (!isset($obj)) {
$obj = new COM(word.application);
if ($obj instanceof COM) {
throw new Exception('I have no Word(s)');
}
}

if ((boolean)$clean) {
/* todo: make the Word instance as new */
}

return $obj;
}

/* ... rest of class ... */

private function CreateHeaderFile()
{
$this-obj = self::getWord();

/* ... rest of method ... */
}
}




$this-mm_data_dir = 'F:/htdocs/csaf/'.$data_dir;
$this-list = $list;
$this-letter_template = $letter;
$this-envelope_template = $envelope;
$this-initilize();

$this-CreateHeaderFile();
$this-CreateDataSource();
$this-CreateDocument($this-letter_template);
$this-CreateDocument($this-envelope_template);
}

public function __destruct() {
unlink($this-mm_data_dir.'/ds.doc');
unlink($this-mm_data_dir.'/header.doc');
}

private function initilize() {
$this-rowcnt = count($this-list);
$this-fieldcnt = count($this-list[0]);
}

private function Close() {
$this-obj-Documents-Close();
}

private function Quit() {
$this-obj-Quit(); 
}


private function Release() {
$this-obj = NULL; 
}


private function CreateHeaderFile() {
$this-obj = new COM(word.application) or die('Couldnt load Word!');
if(!is_object($this-obj)) throw new Exception('Unable to instanciate 
Word!');

$this-obj-Documents-Add();
$this-obj-ActiveDocument-Tables-Add($this-obj-Selection-Range,1,$this-fieldcnt);

for($i = 0; $i = $this-rowcnt; $i++) {
foreach($this-list[$i] as $key = $value) {
$this-obj-Selection-TypeText($key);
$this-obj-Selection-MoveRight();
} 
}

$this-obj-ActiveDocument-SaveAs($this-mm_data_dir.'/header.doc');
$this-Close();
$this-Quit();
$this-Release();
}

private function CreateDataSource() {
$this-obj = new COM(word.application);
if(!is_object($this-obj)) throw new Exception('Unable to instanciate 
Word!');

$this-obj-Documents-Add();
$this-obj-ActiveDocument-Tables-Add($this-obj-Selection-Range,$this-rowcnt,$this-fieldcnt);

for($i = 0; $i = $this-rowcnt; $i++) {
foreach($this-list[$i] as $key = $value) {
$this-obj-Selection-TypeText($value);
$this-obj-Selection-MoveRight();
}
}
$this-obj-ActiveDocument-SaveAs($this-mm_data_dir.'/ds.doc');
$this-Close();
$this-Quit();
$this-Release();
}

private function CreateDocument($template) {
$this-obj = new COM(word.application); 
if(!is_object($this-obj)) throw new Exception('Unable to instanciate 
Word!');

$this-obj-Documents-Open($this-mm_data_dir.'/'.$template.'.dot');
$this-obj-ActiveDocument-MailMerge-OpenHeaderSource($this-mm_data_dir.'/header.doc');
$this-obj-ActiveDocument-MailMerge-OpenDataSource($this-mm_data_dir.'/ds.doc');
$this-obj-ActiveDocument-MailMerge-Execute();
$this-obj-ActiveDocument-SaveAs($this-mm_data_dir.'/'.$template.'.doc');
$this-Close();
$this-Quit();
$this-Release();
}
}
?



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



Re: [PHP] core files

2005-09-20 Thread Jochem Maas


... I hope you have a sense of humor Jon...

Jon wrote:

I am trying to copy the files needed to run a php commandline script so that
I can send them to a different computer and run as a scheduled task.  I do
not know what I am missing but for some reason my file commands do not seem
to be working.  fopen does not work and so fwrite does not work either.  I


what does not work? what is the error?


am on a windows machine.  My script runs from my core version and it runs on


whats a 'core' version? is it a dance remix?


a different computer with an xampplite install but for some reason I have
not found the file that I am missing. Any help would be appreciated.


why do you think you are missing a file? (I think I'm 'missing' a Volvo X90,
could someone send me one?)


Thanks.


Only god can answer you're question with the (lack of) information
you provided ... you may have noticed what a shitstorm has been
brewing on planet earth for at least the last 5000 years, god is busy
and we can only help if you provide details of your OS, php 
version/setup/config,
some code, error msgs, etc. thats because we are not omnipotent
(actually John Nichel might be but he'll deny it - he can't handle the
publicity ;-)





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



RE: [PHP] Installing under IIS6.0

2005-09-20 Thread Jay Blanchard
[snip]
However, this really isn't what I'm looking for.  I'm simply looking for 
a way to parse PHP code from within existing HTML pages, so that I can 
migrate a site from Apache to IIS6.0.

Like I said, if I were using Apache, I would just add .html to my 
AddType directive, and call it good.  Is it not this simple under IIS?
[/snip]

Sorry, I just saw this thread.

In order to handle HTML you have to allow it to be handled via the ISAPI dll

Open Internet Information Services, right click on the web site, click
Properties.
On the Home Directory tab make sure Execute Permissions is set to Scripts
Only.
Click the Configuration button just to the right of that.
Click Add.
In the Executable box put the path to yous PHP ISAPI dll
In the Extension box put .html
Click OK until you get back to the IIS main. Stop the web server, then
restart. HTML files will now be handled through the PHP dll.

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



Re: [PHP] Easy question - delete strings from the beginning of space...

2005-09-20 Thread Jochem Maas

Gustav Wiberg wrote:

Hi there!

I guess this is an easy question. I have string...

Hello you

and I want to get the Hello part.

How do I do that? (I can of course search for first occurence of space 
and then use substr, but I guess there is an easier solution?


how much easier do you want it? oh and guessing kinda sucks.

$str = Hello World;
$words = explode( , $str);
echo $words[0];

... but what if you have double spaces, or a space at the beginning?



/G
http://www.varupiraten.se/



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



Re: [PHP] It's A Windows World

2005-09-20 Thread Jochem Maas

Robert Cummings wrote:

On Sun, 2005-09-18 at 03:18, viraj wrote:


no! it's not a Windows World anymore..   ;-)

http://news.netcraft.com/archives/web_server_survey.html



As much as I dislike Microsoft and its practices I bring bad news. The
above only indicates that it's not an IIS world. 


thats a good start imho :-)

force be with you in the new job Jay. :-)


There's no breakdown of
hosting environment for apache :/

Cheers,
Rob.


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



Re: [PHP] Fwd: Code Optimization Help

2005-09-20 Thread Joseph Crawford
I am not sure where you got the idea that it is creating an instance of word 
for every record, but it creates one instance then loops through the records 
using that one instance.

On 9/20/05, Jochem Maas [EMAIL PROTECTED] wrote:
 
 Joseph Crawford wrote:
  Hello Everyone,
 
  I have some code that is using COM to interact with MS Word to create a 
 mail
  merge based on my mysql database, however it is running dreadfully slow
  13.53846 seconds to be exact. This is only running on 34 records, i 
 could
  imagine running this on a few hundred records not to mention thousand. 
 Is
  COM usually this slow? These load times i believe to be accurate as they
  come from zend studio's profiler.
  You can see screenshots of the profile @
  http://codebowl.dontexist.net/bugs/MailMerge/ Below you will see my 
 code,
  anything you guys see that i could do to speed this up quite a bit i 
 would
  appreciate it. It seems the naughty methods are CreateHeader,
  CreateDataSource, CreateDocument.
 
 
  CODE
  =
  ?php
 
  class MailMerge {
  private $mm_data_dir;
  private $obj;
  private $fieldcnt;
  private $rowcnt;
  private $letter_template;
  private $envelope_template;
 
  public function __construct($list = null, $letter = 'Has_Site', 
 $envelope =
  'Envelope', $data_dir = 'data/mailmerge') {
  if(!is_array($list)) throw new Exception('Cannot Create A Mail Merge 
 With An
  Empty List.');
 
 // an off topic thought...
 if (!is_array($list) || empty($list)) { throw new Exception(' ... '); }
 
 more on topic ... you might try to make the com object
 a singleton rather than creating a new one for each record
 you are processing, and then clear the word document before
 starting a new record... I could imagine starting up an
 instance of Word for every record could be your bottleneck ...
 given the ammount of time it takes to start up an interactive
 instance of Word! (which is measured in seconds on my fairly
 up2date laptop). i.e. only do this line once, for instance (untested):
 
 class MailMerge {
 
 static protected function getWord($clean = false)
 {
 static $obj;
 if (!isset($obj)) {
 $obj = new COM(word.application);
 if ($obj instanceof COM) {
 throw new Exception('I have no Word(s)');
 }
 }
 
 if ((boolean)$clean) {
 /* todo: make the Word instance as new */
 }
 
 return $obj;
 }
 
 /* ... rest of class ... */
 
 private function CreateHeaderFile()
 {
 $this-obj = self::getWord();
 
 /* ... rest of method ... */
 }
 }
 
 
 
  $this-mm_data_dir = 'F:/htdocs/csaf/'.$data_dir;
  $this-list = $list;
  $this-letter_template = $letter;
  $this-envelope_template = $envelope;
  $this-initilize();
 
  $this-CreateHeaderFile();
  $this-CreateDataSource();
  $this-CreateDocument($this-letter_template);
  $this-CreateDocument($this-envelope_template);
  }
 
  public function __destruct() {
  unlink($this-mm_data_dir.'/ds.doc');
  unlink($this-mm_data_dir.'/header.doc');
  }
 
  private function initilize() {
  $this-rowcnt = count($this-list);
  $this-fieldcnt = count($this-list[0]);
  }
 
  private function Close() {
  $this-obj-Documents-Close();
  }
 
  private function Quit() {
  $this-obj-Quit();
  }
 
  private function Release() {
  $this-obj = NULL;
  }
 
  private function CreateHeaderFile() {
  $this-obj = new COM(word.application) or die('Couldnt load Word!');
  if(!is_object($this-obj)) throw new Exception('Unable to instanciate
  Word!');
  $this-obj-Documents-Add();
  
 $this-obj-ActiveDocument-Tables-Add($this-obj-Selection-Range,1,$this-fieldcnt);
 
  for($i = 0; $i = $this-rowcnt; $i++) {
  foreach($this-list[$i] as $key = $value) {
  $this-obj-Selection-TypeText($key);
  $this-obj-Selection-MoveRight();
  }
  }
  $this-obj-ActiveDocument-SaveAs($this-mm_data_dir.'/header.doc');
  $this-Close();
  $this-Quit();
  $this-Release();
  }
 
  private function CreateDataSource() {
  $this-obj = new COM(word.application);
  if(!is_object($this-obj)) throw new Exception('Unable to instanciate
  Word!');
  $this-obj-Documents-Add();
  
 $this-obj-ActiveDocument-Tables-Add($this-obj-Selection-Range,$this-rowcnt,$this-fieldcnt);
 
  for($i = 0; $i = $this-rowcnt; $i++) {
  foreach($this-list[$i] as $key = $value) {
  $this-obj-Selection-TypeText($value);
  $this-obj-Selection-MoveRight();
  }
  }
  $this-obj-ActiveDocument-SaveAs($this-mm_data_dir.'/ds.doc');
  $this-Close();
  $this-Quit();
  $this-Release();
  }
 
  private function CreateDocument($template) {
  $this-obj = new COM(word.application);
  if(!is_object($this-obj)) throw new Exception('Unable to instanciate
  Word!');
  $this-obj-Documents-Open($this-mm_data_dir.'/'.$template.'.dot');
  
 $this-obj-ActiveDocument-MailMerge-OpenHeaderSource($this-mm_data_dir.'/header.doc');
  
 $this-obj-ActiveDocument-MailMerge-OpenDataSource($this-mm_data_dir.'/ds.doc');
  $this-obj-ActiveDocument-MailMerge-Execute();
  
 $this-obj-ActiveDocument-SaveAs($this-mm_data_dir.'/'.$template.'.doc');
  $this-Close();

RE: [PHP] It's A Windows World

2005-09-20 Thread Jay Blanchard
[snip]
http://news.netcraft.com/archives/web_server_survey.html

force be with you in the new job Jay. :-)
[/snip]

Thanks Jochem!

Now, of course, I didn't mean that the world (generalization) was a Windows
one, but just my local world. I am working towards some things that will
allow the transition to open source platforms to be smoother, starting with
the web servers and web application servers. Migration to PHP and Apache
will take place first. I am stuck with MS-SQL Server for the primary
database for the immediate future.

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



RE: [PHP] Re: Suggestions for class design

2005-09-20 Thread Michael Sims
Murray @ PlanetThoughtful wrote:
 Once he understands how to solve class abstraction problems such as
 the one he is asking about, he will be better equipped to deal with a
 wider range of application development tasks.

I agree with this.

 This is not to trivialize your Metastorage project (or, to be more
 accurate, I know nothing about it, so it's not my place to trivialize
 it or otherwise), but to point out that 'out-of-the-box' solutions to
 fundamental coding development problems probably ultimately makes for
 a poorer programmer. I could well be wrong, but it seems this is a
 case of give a man a fish as opposed to teach a man to fish.

I see your point, but I'm not so sure I agree fully.  Manuel suggested
Metastorage (which makes sense, it's his project and he's most
familiar/comfortable with it), I suggested Propel because that is what I've
used.  I think we both suggested existing ORM's for the same reason...
namely that properly implementing a full featured ORM is an extremely
difficult thing to get right.  I don't know anything about Chris's skill as
a programmer, but he's bound to reinvent the wheel several times over, and
poorly to boot.  I believe that implementing an ORM is one of those things
that you cannot fully understand and appreciate until you've tried to do it
and failed.  IMHO it's only after you've built one that you realize what you
really need, and by then it needs to be rebuilt.  It's kind of like Fred
Brook's plan to throw one away; you will, anyhow, or at least it was for
me.

I think the whole DAO/ORM approach is something that most programmers who
are fans of OO stumble into as part of their natural development.  I know
that in my earlier projects I had implemented some type of this pattern
without fully realizing that I had done so.  It's just natural to consider
at some point that you should represent entities in your database as objects
(if you're an OO proponent).  In one of my earlier PHP projects, I
implemented a very basic ORM that represented only single entities and
didn't quite handle multiple entities very well, or the relationships
between entities (this seems to be where Chris is currently).  Then for the
next project I added better support for multiple entities and relationships,
but it was a half implementation, because I didn't represent the related
entities as full objects (for example, if a Customer has a list of phone
numbers, I had the Customer object return them as an array of strings rather
than an array of PhoneNumber objects).  I also had no support for recursion
when saving or updated objects (for example, in Propel, you can create a new
Customer object, create 5 new PhoneNumber objects, attach them to the
customer, then call the save() method on the Customer and it will recurse
through all attached objects, saving each of them).  Another thing I had
done halfway was support for querying objects (without using SQL).
Basically I had created different types of criteria that could be used, but
my support for criteria wasn't general enough.  IOW, if I didn't forsee that
you would want a particular type of criteria, then you couldn't use it.
Propel gets this right by supporting any arbitrary criteria using their
Criteria object approach (and I'm sure Metastorage has similiar
functionality).  If you can represent it using SQL, you can represent it
using Propel's Criteria.

My point is, I had implemented my own home grown ORM about 3-4 times, and
while each one was much better than the one that preceded it, I still wasn't
quite all the way towards a 100% general implementation.  That's when I
found Propel.  It got so many things right that I hadn't figured out how to
solve, as well as implementing things that I hadn't even considered yet.

Now, you could argue that going through all those iterations and refactoring
my own ORM helped me to improve my skills as a programmer, and you would be
right.  That's where I agree with you, somewhat. :)  However, I was many
many iterations away from improving my ORM to the point where it would be as
useful as Propel (and that's assuming it would ever be that useful).  The
guys who developed it (and I'm sure the same goes for Manuel and
Metastorage) concentrated on making the best general purpose ORM they could
make.  IOW their whole goal was to build an ORM, while my goal each time was
to develop one for the purposes of finishing whatever real project I
happened to be working on.  That meant they were closer to the problem, had
more experience with it, and were willing to do more to solve it more fully
and generally than I was.

Originally I intended only to look at the code they had created and learn
from it, using their ideas in my project.  I started that way for a few
days, but I realized that there was so much they had accounted for that I
didn't even think of that it would be better to simply use their tool rather
than trying to reinvent it.

I think it's important to point out, however, that I have learned 

Re: [PHP] Easy question - delete strings from the beginning of space...

2005-09-20 Thread Gustav Wiberg
- Original Message - 
From: Jochem Maas [EMAIL PROTECTED]

To: Gustav Wiberg [EMAIL PROTECTED]
Cc: PHP General php-general@lists.php.net
Sent: Tuesday, September 20, 2005 2:24 PM
Subject: Re: [PHP] Easy question - delete strings from the beginning of 
space...




Gustav Wiberg wrote:

Hi there!

I guess this is an easy question. I have string...

Hello you

and I want to get the Hello part.

How do I do that? (I can of course search for first occurence of space 
and then use substr, but I guess there is an easier solution?


how much easier do you want it? oh and guessing kinda sucks.

$str = Hello World;
$words = explode( , $str);
echo $words[0];

... but what if you have double spaces, or a space at the beginning?



/G
http://www.varupiraten.se/





--
No virus found in this incoming message.
Checked by AVG Anti-Virus.
Version: 7.0.344 / Virus Database: 267.11.3/106 - Release Date: 2005-09-19



Hi there!

Ok, I'll think I do it in my way because of double spaces etc...

Thanx anyway!

/G
http://www.varupiraten.se/
ps. Forgive me for guessing... :-)

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



Fw: [PHP] Easy question - delete strings from the beginning of space...

2005-09-20 Thread Gustav Wiberg
- Original Message - 
From: Gustav Wiberg [EMAIL PROTECTED]

To: Jochem Maas [EMAIL PROTECTED]
Cc: PHP General php-general@lists.php.net
Sent: Tuesday, September 20, 2005 3:04 PM
Subject: Re: [PHP] Easy question - delete strings from the beginning of 
space...



- Original Message - 
From: Jochem Maas [EMAIL PROTECTED]

To: Gustav Wiberg [EMAIL PROTECTED]
Cc: PHP General php-general@lists.php.net
Sent: Tuesday, September 20, 2005 2:24 PM
Subject: Re: [PHP] Easy question - delete strings from the beginning of 
space...




Gustav Wiberg wrote:

Hi there!

I guess this is an easy question. I have string...

Hello you

and I want to get the Hello part.

How do I do that? (I can of course search for first occurence of space 
and then use substr, but I guess there is an easier solution?


how much easier do you want it? oh and guessing kinda sucks.

$str = Hello World;
$words = explode( , $str);
echo $words[0];

... but what if you have double spaces, or a space at the beginning?



/G
http://www.varupiraten.se/





--
No virus found in this incoming message.
Checked by AVG Anti-Virus.
Version: 7.0.344 / Virus Database: 267.11.3/106 - Release Date: 
2005-09-19




Hi there!

Ok, I'll think I do it in my way because of double spaces etc...

Thanx anyway!

/G
http://www.varupiraten.se/
ps. Forgive me for guessing... :-)



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



Re: [PHP] Re: Suggestions for class design

2005-09-20 Thread Jochem Maas

Michael Sims wrote:

Murray @ PlanetThoughtful wrote:


Once he understands how to solve class abstraction problems such as
the one he is asking about, he will be better equipped to deal with a
wider range of application development tasks.



I agree with this.



This is not to trivialize your Metastorage project (or, to be more
accurate, I know nothing about it, so it's not my place to trivialize
it or otherwise), but to point out that 'out-of-the-box' solutions to
fundamental coding development problems probably ultimately makes for
a poorer programmer. I could well be wrong, but it seems this is a
case of give a man a fish as opposed to teach a man to fish.



I see your point, but I'm not so sure I agree fully.  Manuel suggested
Metastorage (which makes sense, it's his project and he's most
familiar/comfortable with it), I suggested Propel because that is what I've


...



Sorry, I didn't mean to ramble on that long... :)


no need, very good piece of writing on the subject matter imho!





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



Re: [PHP] Fwd: Code Optimization Help

2005-09-20 Thread Jochem Maas

Joseph Crawford wrote:
I am not sure where you got the idea that it is creating an instance of word 


I got the idea from your code, but I just gave it a quick glance...
that said you instantiate a new COM object in at least 3 places...

CreateHeader()
CreateDataSource()
CreateDocument()

which you mention might be the 'naughty' methods ... possibly then the culprit 
is
still the slow instantiation of multiple COM objects?

for every record, but it creates one instance then loops through the records 
using that one instance.


On 9/20/05, Jochem Maas [EMAIL PROTECTED] wrote:


Joseph Crawford wrote:


Hello Everyone,

I have some code that is using COM to interact with MS Word to create a 


mail


merge based on my mysql database, however it is running dreadfully slow
13.53846 seconds to be exact. This is only running on 34 records, i 


could

imagine running this on a few hundred records not to mention thousand. 


Is


COM usually this slow? These load times i believe to be accurate as they
come from zend studio's profiler.
You can see screenshots of the profile @
http://codebowl.dontexist.net/bugs/MailMerge/ Below you will see my 


code,

anything you guys see that i could do to speed this up quite a bit i 


would


appreciate it. It seems the naughty methods are CreateHeader,
CreateDataSource, CreateDocument.


CODE
=
?php

class MailMerge {
private $mm_data_dir;
private $obj;
private $fieldcnt;
private $rowcnt;
private $letter_template;
private $envelope_template;

public function __construct($list = null, $letter = 'Has_Site', 


$envelope =


'Envelope', $data_dir = 'data/mailmerge') {
if(!is_array($list)) throw new Exception('Cannot Create A Mail Merge 


With An


Empty List.');


// an off topic thought...
if (!is_array($list) || empty($list)) { throw new Exception(' ... '); }

more on topic ... you might try to make the com object
a singleton rather than creating a new one for each record
you are processing, and then clear the word document before
starting a new record... I could imagine starting up an
instance of Word for every record could be your bottleneck ...
given the ammount of time it takes to start up an interactive
instance of Word! (which is measured in seconds on my fairly
up2date laptop). i.e. only do this line once, for instance (untested):

class MailMerge {

static protected function getWord($clean = false)
{
static $obj;
if (!isset($obj)) {
$obj = new COM(word.application);
if ($obj instanceof COM) {
throw new Exception('I have no Word(s)');
}
}

if ((boolean)$clean) {
/* todo: make the Word instance as new */
}

return $obj;
}

/* ... rest of class ... */

private function CreateHeaderFile()
{
$this-obj = self::getWord();

/* ... rest of method ... */
}
}





$this-mm_data_dir = 'F:/htdocs/csaf/'.$data_dir;
$this-list = $list;
$this-letter_template = $letter;
$this-envelope_template = $envelope;
$this-initilize();

$this-CreateHeaderFile();
$this-CreateDataSource();
$this-CreateDocument($this-letter_template);
$this-CreateDocument($this-envelope_template);
}

public function __destruct() {
unlink($this-mm_data_dir.'/ds.doc');
unlink($this-mm_data_dir.'/header.doc');
}

private function initilize() {
$this-rowcnt = count($this-list);
$this-fieldcnt = count($this-list[0]);
}

private function Close() {
$this-obj-Documents-Close();
}

private function Quit() {
$this-obj-Quit();
}

private function Release() {
$this-obj = NULL;
}

private function CreateHeaderFile() {
$this-obj = new COM(word.application) or die('Couldnt load Word!');
if(!is_object($this-obj)) throw new Exception('Unable to instanciate
Word!');
$this-obj-Documents-Add();



$this-obj-ActiveDocument-Tables-Add($this-obj-Selection-Range,1,$this-fieldcnt);


for($i = 0; $i = $this-rowcnt; $i++) {
foreach($this-list[$i] as $key = $value) {
$this-obj-Selection-TypeText($key);
$this-obj-Selection-MoveRight();
}
}
$this-obj-ActiveDocument-SaveAs($this-mm_data_dir.'/header.doc');
$this-Close();
$this-Quit();
$this-Release();
}

private function CreateDataSource() {
$this-obj = new COM(word.application);
if(!is_object($this-obj)) throw new Exception('Unable to instanciate
Word!');
$this-obj-Documents-Add();



$this-obj-ActiveDocument-Tables-Add($this-obj-Selection-Range,$this-rowcnt,$this-fieldcnt);


for($i = 0; $i = $this-rowcnt; $i++) {
foreach($this-list[$i] as $key = $value) {
$this-obj-Selection-TypeText($value);
$this-obj-Selection-MoveRight();
}
}
$this-obj-ActiveDocument-SaveAs($this-mm_data_dir.'/ds.doc');
$this-Close();
$this-Quit();
$this-Release();
}

private function CreateDocument($template) {
$this-obj = new COM(word.application);
if(!is_object($this-obj)) throw new Exception('Unable to instanciate
Word!');
$this-obj-Documents-Open($this-mm_data_dir.'/'.$template.'.dot');



$this-obj-ActiveDocument-MailMerge-OpenHeaderSource($this-mm_data_dir.'/header.doc');

$this-obj-ActiveDocument-MailMerge-OpenDataSource($this-mm_data_dir.'/ds.doc');



[PHP] session

2005-09-20 Thread Roman Duriancik
Hello, I'm novice in using sessions and therefore I need some help.
?
session_start();
session_register('pocet');
$count++;
echo $count;
session_destroy();
?
a href=test.php??php echo(SID)?link/a

and when i click on link always I have in $count value 1 but I need
value 2,3,
how to do it ?

thanks

roman

.

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



Re: [PHP] session

2005-09-20 Thread Thorsten Suckow-Homberg

and when i click on link always I have in $count value 1 but I need
value 2,3,
how to do it ?


?php
session_start();

if (! isset($_SESSION['count'])) {
$_SESSION['count'] = 0;
}

$_SESSION['count']++;

//session_destroy(); - don't do that! It destroys the 
//session associated with the current user


?

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



[PHP] Re: session

2005-09-20 Thread Norbert Wenzel

Roman Duriancik wrote:

?
session_start();
session_register('pocet');
$count++;
echo $count;
session_destroy();
?
a href=test.php??php echo(SID)?link/a

and when i click on link always I have in $count value 1 but I need
value 2,3,
how to do it ?


i think this is what you asked for:

if(isset($_SESSION['count'])) {
$_SESSION['count']++;
}
else {
$_SESSION['count'] = 1;
}

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



[PHP] session

2005-09-20 Thread Roman Duriancik
Hello, I'm novice in using sessions and therefore I need some help.
?
session_start();
session_register('pocet');
$count++;
echo $count;
session_destroy();
?
a href=test.php??php echo(SID)?link/a

and when i click on link always I have in $count value 1 but I need
value 2,3,
how to do it ?

thanks

roman

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



[PHP] Re: session

2005-09-20 Thread Mark Evans

how to do it ?


http://php.grn.es/manual/en/ref.session.php

Hint: Look at example 1 where it says

?php
session_start();
if (!isset($_SESSION['count'])) {
   $_SESSION['count'] = 0;
} else {
   $_SESSION['count']++;
}

echo $_SESSION['count'];

?

a href=test6.php??php echo(SID)?link/a

Also take a look at

http://php.grn.es/manual/en/function.session-register.php

Note: the part about not using session_register()

Regards

Mark

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



Re: [PHP] core files

2005-09-20 Thread Jon
OK, OK,  Ha-ha  Thought that you guys could read my mind...

Here is the error
Warning: fopen(C:\windows\Desktop\php\php pages\phpout.txt)
[function.fopen]: failed to open stream: No such file or directory in
C:\windows\Desktop\php\php pages\phpout.txt on line 12
and of course the fwrite and fclose do not work cause the file is an invalid
stream.

I have a few computers with php installed they are all Win based except for
one nix based server.  The script that I want to make portable will need to
run on a Windows ME/9X box and an XP box.

On my testing computer I have an Installed version of PHP 5.0.3
when I run my script with this version I have no problems

On a different computer I have xampplite from
http://www.apachefriends.org/en/xampp-windows.html#646 The version in it is
5.0.4 according to the website.
I have no problems with this version either

What I have been trying to do is get the files needed for my script to run
and not have to have a lot of files that I don't need.  So I made a dir on
my desktop and copied in the files that I know I need and modified the
php.ini accordingly but for some reason fwrite is not working. It is not
creating the file.
 I have a file list if it is necessary.

Thanks again...

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



[PHP] resource id#

2005-09-20 Thread Ross
When I try to insert a field into my database it shows as Resource id#21?

I must be doing something dim.



R. 

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



[PHP] resource id#

2005-09-20 Thread Ross
When I try to insert a field into my database it shows as Resource id#21?

I must be doing something dim.



R.

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



[PHP] Re: resource id#

2005-09-20 Thread David Robley
Ross wrote:

 When I try to insert a field into my database it shows as Resource id#21?
 
 I must be doing something dim.

Indeed you are; perhaps if you show a code snippet someone can guide you to
the light :-)



Cheers
-- 
David Robley

Do not believe in miracles -- rely on them.

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



Re: [PHP] Fwd: Code Optimization Help

2005-09-20 Thread Jochem Maas

Joseph Crawford wrote:

Jochem,

I did attempt what you wanted me to try, however when i did that it just 
hung up on the OpenHeaders


$this-obj-ActiveDocument-MailMerge-OpenHeaderSource($this-mm_data_dir.'/header.doc');


maybe your Close() function should be different?:

private function Close() {
$this-obj-ActiveDocument-Close();
}

but I still think your problem is the creation of multiple COM objects...

the download on following page might give you a hint as to other methods
which are available:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbawd11/html/WordVBAWelcome_HV01135786.asp

and there is this:
http://netevil.org/talks/PHP-and-COM-2005.pdf

which might help (it's by Wez Furlong, one of the core php guys)

sorry I can't help more.



I attempted this by removing the calls to quit, and just closing the 
active document so that it would keep the COM object open, however it 
just hung up on that line, i couldnt even get zend studio to spit an 
error for me.


On 9/20/05, *Jochem Maas* [EMAIL PROTECTED] 
mailto:[EMAIL PROTECTED] wrote:


Joseph Crawford wrote:
  I am not sure where you got the idea that it is creating an
instance of word

I got the idea from your code, but I just gave it a quick glance...
that said you instantiate a new COM object in at least 3 places...

CreateHeader()
CreateDataSource()
CreateDocument()

which you mention might be the 'naughty' methods ... possibly then
the culprit is
still the slow instantiation of multiple COM objects?

  for every record, but it creates one instance then loops through
the records
  using that one instance.
 
  On 9/20/05, Jochem Maas [EMAIL PROTECTED]
mailto:[EMAIL PROTECTED] wrote:
 
 Joseph Crawford wrote:
 
 Hello Everyone,
 
 I have some code that is using COM to interact with MS Word to
create a
 
 mail
 
 merge based on my mysql database, however it is running
dreadfully slow
 13.53846 seconds to be exact. This is only running on 34 records, i
 
 could
 
 imagine running this on a few hundred records not to mention
thousand.
 
 Is
 
 COM usually this slow? These load times i believe to be accurate
as they
 come from zend studio's profiler.
 You can see screenshots of the profile @
 http://codebowl.dontexist.net/bugs/MailMerge/ Below you will see my
 
 code,
 
 anything you guys see that i could do to speed this up quite a
bit i
 
 would
 
 appreciate it. It seems the naughty methods are CreateHeader,
 CreateDataSource, CreateDocument.
 
 
 CODE
 =
 ?php
 
 class MailMerge {
 private $mm_data_dir;
 private $obj;
 private $fieldcnt;
 private $rowcnt;
 private $letter_template;
 private $envelope_template;
 
 public function __construct($list = null, $letter = 'Has_Site',
 
 $envelope =
 
 'Envelope', $data_dir = 'data/mailmerge') {
 if(!is_array($list)) throw new Exception('Cannot Create A Mail Merge
 
 With An
 
 Empty List.');
 
 // an off topic thought...
 if (!is_array($list) || empty($list)) { throw new Exception(' ...
'); }
 
 more on topic ... you might try to make the com object
 a singleton rather than creating a new one for each record
 you are processing, and then clear the word document before
 starting a new record... I could imagine starting up an
 instance of Word for every record could be your bottleneck ...
 given the ammount of time it takes to start up an interactive
 instance of Word! (which is measured in seconds on my fairly
 up2date laptop). i.e. only do this line once, for instance
(untested):
 
 class MailMerge {
 
 static protected function getWord($clean = false)
 {
 static $obj;
 if (!isset($obj)) {
 $obj = new COM(word.application );
 if ($obj instanceof COM) {
 throw new Exception('I have no Word(s)');
 }
 }
 
 if ((boolean)$clean) {
 /* todo: make the Word instance as new */
 }
 
 return $obj;
 }
 
 /* ... rest of class ... */
 
 private function CreateHeaderFile()
 {
 $this-obj = self::getWord();
 
 /* ... rest of method ... */
 }
 }
 
 
 
 
 $this-mm_data_dir = 'F:/htdocs/csaf/'.$data_dir;
 $this-list = $list;
 $this-letter_template = $letter;
 $this-envelope_template = $envelope;
 $this-initilize();
 
 $this-CreateHeaderFile();
 $this-CreateDataSource();
 $this-CreateDocument($this-letter_template);
 $this-CreateDocument($this-envelope_template);
 }
 
 public function __destruct() {
 unlink($this-mm_data_dir.'/ds.doc');
 unlink($this-mm_data_dir.'/header.doc');
 }
 
 

[PHP] session 2

2005-09-20 Thread Roman Duriancik
Tanks all for help about session
I have other question.
In php.ini I set  folder for sessions file on c:\tmp but what are
happens when disk is full, how to automatically delete nonactive
sessions files ?

thanks
roman

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



Re: [PHP] session 2

2005-09-20 Thread John Nichel

Roman Duriancik wrote:

Tanks all for help about session
I have other question.
In php.ini I set  folder for sessions file on c:\tmp but what are
happens when disk is full, how to automatically delete nonactive
sessions files ?


PHP will handle this automatically based on the session.gc_maxlifetime 
setting in the php.ini...unless you're using FAT.


It's all here

http://us2.php.net/session

--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]

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



[PHP] re: resource id #

2005-09-20 Thread Ross
I was using the variable $link in a form. is it a reserved word or 
something??


R. 

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



Re: [PHP] re: resource id #

2005-09-20 Thread Thorsten Suckow-Homberg
I was using the variable $link in a form. is it a reserved word or 
something??


Most likely the var $link is being used for db-operations (or similiar) 
previously, thus the return value of any resource-based operation is passed 
to the var $link. Check the all the scripts that are involved in presenting 
the script/form.


Best regards

Thorsten Suckow-Homberg 


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



Re: [PHP] resource id#

2005-09-20 Thread Thorsten Suckow-Homberg

When I try to insert a field into my database it shows as Resource id#21?

I must be doing something dim.



Some could would definetely help here...

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



RE: [PHP] Tidying code for PHP5.0.5/PHP4.4.0

2005-09-20 Thread Michael Sims
Jochem Maas wrote:
 foo($a = 5);
 
 by definition the expression is evaluated _before_ the function is
 called - so the expression is not passed to the function, the result
 of the expression is passed ... I was under the impression that the
 the expression evaluates to a 'pointer' (I'm sure thats bad
 terminology) to $a ... which can taken by reference by the function.
 
 possibly I am completely misunderstanding what goes on here.

When used as an expression, an assignment evaluates to whatever is on the right 
side of the assignment operator, not the left.  Example:

var_dump($a = 5);
outputs
int(5)

var_dump($a = some string);
outputs
string(11) some string

So, as far as foo() knows:

foo($a = 5);
and
foo(5);

are exactly the same...

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



[PHP] Re: core files [Oops]

2005-09-20 Thread Jon
Nevermind.  I get the award for not checking code on this one.  I did not
pay close enough attention to what I was doing and had the path with \'s
instead of /'s.  I fixed that and it started working.  Imagine that. Buggy
code was causing the error. Sorry for the trouble.

Jon [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 I am trying to copy the files needed to run a php commandline script so
that
 I can send them to a different computer and run as a scheduled task.  I do
 not know what I am missing but for some reason my file commands do not
seem
 to be working.  fopen does not work and so fwrite does not work either.  I
 am on a windows machine.  My script runs from my core version and it runs
on
 a different computer with an xampplite install but for some reason I have
 not found the file that I am missing. Any help would be appreciated.
 Thanks.

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



RE: [PHP] Is my feedback form being successfully abused?

2005-09-20 Thread Chris W. Parker
Jochem Maas mailto:[EMAIL PROTECTED]
on Tuesday, September 20, 2005 2:37 AM said:

 this 'fairly recent' class of attack is already quite well documented,
 google around for more info.

Actually I did do some googling on it before posting and was relatively
confident that the attempt to exploit the form wasn't actually
successful. I posted to the list to find out if indeed it was being
exploited despite the lack of evidence in the maillog.

 I don't if any mail classes out there deal with this issue for you,
 I wrote a simple function to attempt to check for 'problem' message
 bodies:

Thanks for the code. I'll try to get it implemented soon.


Chris.

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



Re: [PHP] Re: Suggestions for class design

2005-09-20 Thread Manuel Lemos

Hello,

on 09/20/2005 04:59 AM Murray @ PlanetThoughtful said the following:

Let's take for example a class called 'Customer' that (obviously)
manipulates customers in the database. Here is a very basic Customer
class. (Data validation and the like are left out for brevity.)

This is a basic object persistence problem.



(Unless I've already got some major design flaws I think we should be
good to go.)

 
  Where I get tripped up is when I realize I'll need to at some point
  get more than one customer at a time and thus I want to add a method
  called 'get_customers()'.


Yes, there is a problem. You are trying to retrieve objects into memory
before they exist. It makes more sense that you retrieve objects using a
factory class.

That is the approach of Metastorage. You may want to take a looka at
Metastorage before you reinvent the wheel.


Hi Manuel,

I very much understand your desire to promote your various projects, but the
original poster is asking a question that is basic to any programmer's
development in object-oriented coding.


I denote a certain bias on your part against the fact that I suggest 
projects that I have developed.


The matter is that I am suggesting projects that I use. The fact that I 
developed them is a mere coincidence. I do not always suggest projects 
that I developed as I am not such a wizard that I have the best 
solutions for everything. However, if I use and recommend certain 
solutions, mine or others is because I believe they are the best at 
least for my purposes.


What the original poster wants to know is what is the best solution 
retrieve a collection of objects. I recommended what I use and explained 
why I think it is the best approach for this purpose. He appreciated the 
reply and sent me a thank you message.


I do not understand why this could bother you or anybody else. If you 
have a better solution, nothing stops you to make your recommendations.





Once he understands how to solve class abstraction problems such as the one
he is asking about, he will be better equipped to deal with a wider range of
application development tasks.


Right, that is why I suggested something that I believe that solves his 
probleme better and even justified.




This is not to trivialize your Metastorage project (or, to be more accurate,
I know nothing about it, so it's not my place to trivialize it or
otherwise), but to point out that 'out-of-the-box' solutions to fundamental
coding development problems probably ultimately makes for a poorer
programmer. I could well be wrong, but it seems this is a case of give a
man a fish as opposed to teach a man to fish.


I think you should have learned about Metastorage first before 
commenting. It is not really a out-of-the-box solution. It is a code 
generator tool that employs well known design patterns to generate code 
to customized to the developer needs.


It is not yet another template pasting tool. It uses the JE WIN 
approach: Just Exactly What I Need. That works by letting the developer 
tell the kind of functions he wants to use, rather than bundling a pile 
of code that you may never user.


It takes in account the design of your persistent object classes to 
generate optimized code for the task, rather than generic code for 
unnecessary generic needs.


Basically it generates the code that you would generate if you were an 
expert in object persistence methodology.


Given that, I am not even saying, use this, but rather, take a look at 
the kind of code that it generates as a concrete example of what I tried 
to explain. The generated code even comes with comments so you do not 
have to wonder too much.


Whether the original poster will use Metastorage or just pick some 
ideas, that is another story.




Also, and separate from above, I don't understand the relevance of your
comment, You are trying to retrieve objects into memory before they exist.
Unless I'm horribly mistaken [1], the original poster has developed a class
that abstracts a single customer, and is asking the list for suggestions in
how to best approach a need to be able to abstract collections of customers.
This is a normal application development issue, and for the life of me I
can't grasp how your comment relates.


I tried to explain in the part of the message that you did not quote, 
why using a factory class as entry point, which is my suggestion, it 
makes more sense.


In case this was not very clear, who gives existence to the objects 
should be a parent, not a brother like he was doing. He was using a 
Customer class object to give birth to other unrelated Customer objects.


When using a factory class you can execute a query to retrieve Customer 
objects and create them on demand. This means that you do not have to 
create one Customer object first. The query may return data for 0 or 
more Customer objects. A factory may create just exactly the number of 
Customer objects as needed.


Furthermore, a factory class may solve the problem 

[PHP] comparing dates

2005-09-20 Thread Ross
Is there a quick way to compare dates in the format dd/mm/yy without 
exploding and comparing the individual parts?


R. 

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



Re: [PHP] Easy question - delete strings from the beginning of space...

2005-09-20 Thread Jordan Miller

to get rid of potential double spaces after the explode, you could do:
foreach ($words as $word) {
if (!empty($word)) {
$first = $word;
break;
}
}
echo $first;

This will always return the first word.

Jordan



On Sep 20, 2005, at 7:24 AM, Jochem Maas wrote:


how much easier do you want it? oh and guessing kinda sucks.

$str = Hello World;
$words = explode( , $str);
echo $words[0];

... but what if you have double spaces, or a space at the beginning?



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



Re: [PHP] resource id#

2005-09-20 Thread John Nichel

Ross wrote:

When I try to insert a field into my database it shows as Resource id#21?

I must be doing something dim.


Right after you try to do the insert, echo out mysql_error()

--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]

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



[PHP] [RELEASE ANNOUNCEMENT] PEAR 1.4.0 provides revolution in PHP installation

2005-09-20 Thread Greg Beaver
September 20, 2005
FOR IMMEDIATE RELEASE
Contact: Gregory Beaver ([EMAIL PROTECTED])

As of Sunday, September 18, 2005, the PEAR installer has reached
maturity as an enterprise-level installation tool for PHP code.  The
release of version 1.4.0 stable ushers in several essential features for
management of PHP extensions and packages.

1.  PEAR channels
(http://pear.php.net/manual/en/guide.migrating.channels.php)
2.  Better handling of PECL extensions and dependencies on PECL packages
(http://pear.php.net/manual/en/guide.developers.package2.peclinfo.php)
(http://pear.php.net/manual/en/guide.developers.package2.dependencies.php)
3.  more than 650 regression tests in .phpt format
4.  extensive application support through addition of post-install
scripts, custom file roles and file tasks, and the new bundle package
type (http://pear.php.net/manual/en/guide-migrating.php)

PEAR Channels provide a unique distributed installation paradigm.  By
distributing packages through a channel, users can install and configure
an application with a single step rather than the old
download/unzip/tinker system.  For instance, if a high-quality package
is written that is licensed under the GNU license, it cannot be
distributed through pear.php.net or pecl.php.net.  Now, it is possible
to set up a channel like the hypothetical pear.example.com and
distribute it that way.  The user can then install this package just
like any other with:

$ pear install pear.example.com/Packagename

Better yet, developers can depend on this package in their own packages,
removing the need to bundle dependencies.  Critical security fixes for
dependencies can be quickly updated without requiring a release for the
main application.

For PHP extensions written in C/C++, the new pecl command provides a
more robust way to install and upgrade PECL packages.  In addition, for
PECL developers, several enhancements to the way dependencies work allow
the PEAR installer to properly detect a PECL extension regardless of
whether it was built into PHP, a shared module, or installed via the
pecl command.

All of these new features come with additional stability, thanks to the
use of over 650 .phpt-based regression tests.  In the development of
PEAR 1.4.0, several low-level design flaws were uncovered in PEAR 1.3.6
and earlier that have all been fixed in version 1.4.0.  All new features
have been rigorously tested both through regression tests and in the
wild with an extensive alpha- and beta-testing period that covered
nearly a year.

The PEAR installer now has far greater application support.  The
addition of post-installation scripts allows standardized customization
of packages.  Custom file roles and file tasks allow granular
configuration of packages at the file level.  In addition, distribution
of large applications can be simplified with the new bundle package
type.  Bundles allow distributing a package and all of its dependencies
in a single file.

PEAR (http://pear.php.net) is the official code repository of the PHP
project (http://www.php.net).  In addition to providing the PEAR
installer, PEAR provides high-quality object-oriented libraries through
pear.php.net, and PHP extensions through pecl.php.net.

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



Re: [PHP] Tidying code for PHP5.0.5/PHP4.4.0

2005-09-20 Thread Dragan Stanojevic - Nevidljivi

Jochem Maas wrote:
Basically, in PHP, a reference (such as what key() takes as a 
parameter [1]) can only point to an actual variable, not directly to 
the result of a function. So you have to assign the output of the 
function to a variable first.

wtf, Im now officially confused (before I suffered unofficially :-)

if foo() expects one args by reference then why is doing:

foo($a = 5);

..wrong? I always thought that the expression (in this form) 'returns'
the variable? or does it need to be:?

foo( ($a = 5) );


Well think like this: expression != variable != value :]

Let me explain... most functions (and expressions!) return value, not
variable (unless it's passed by reference). Usually, although most
beginners don't know it, you ignore that value.

For example, you could do:

fopen( $filename, $filemode );

and in that case return value (not variable) of fopen is ignored. This
is a bad practice because you need to check it, but this is just an
example. Most other functions return values that we ignore.

Another example (not functions but expressions) is assigning a value:

$a = 5; // returns 5 (and we ignore it again)

it allows us to do the following:

$a = $b = $c = 10;

read from right to left, and it'll go something like this: assign 10 to
$c (it evaluates to 10), assign (previously assigned value) 10 to $b,
and so on

So in essence: $c = 5 in expression and returns the value of 5 not a
variable/reference which can be changed.

Hope this will help you a little,
N::

P.S. Just a thought... If you declare the method to return a ref maybe
you can get away with it...

private public  getThis() {
$tempArr = array( 'a', 'b', 'c' );

return $tempArr;
}

as opposed to:

private public getThis() { ... }


smime.p7s
Description: S/MIME Cryptographic Signature


Re: [PHP] imap_open

2005-09-20 Thread Joachim Person
Thanks Viraj,

Telneting gives an error like this (translated from Swedish language):

Connecting to imap.liu.se...Couldn't connect to the host computer, using 
port 143: The connection failed.

I guess I'm not getting any answer then.

Regards,
Joachim

viraj [EMAIL PROTECTED] skrev i meddelandet 
news:[EMAIL PROTECTED]
did you tried telneting to host's 143 port? if you are getting a
response from the IMAP server you better go through the php-imap
requirements, it's here..

http://www.php.net/imap

 ? I have got the address and the port to the imap server right, but I 
 think
 that the imap server requires some sort of secure login. Could this be the

it depends,

http://www.php.net/manual/en/function.imap-open.php

~viraj.

 problem? If yes, how can it be solved? If no, what other causes could it 
 be?

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

 

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



Re: [PHP] Tidying code for PHP5.0.5/PHP4.4.0

2005-09-20 Thread Jochem Maas

thanks everyone for the crash course in better understanding the underlying 
mechanisms!
... I'm probably not the only one that learnt something from this ;-)

Dragan Stanojevic - Nevidljivi wrote:

Jochem Maas wrote:

Basically, in PHP, a reference (such as what key() takes as a 
parameter [1]) can only point to an actual variable, not directly to 
the result of a function. So you have to assign the output of the 
function to a variable first.


wtf, Im now officially confused (before I suffered unofficially :-)

if foo() expects one args by reference then why is doing:

foo($a = 5);

..wrong? I always thought that the expression (in this form) 'returns'
the variable? or does it need to be:?

foo( ($a = 5) );



Well think like this: expression != variable != value :]

Let me explain... most functions (and expressions!) return value, not 
variable (unless it's passed by reference). Usually, although most 
beginners don't know it, you ignore that value.


For example, you could do:

fopen( $filename, $filemode );

and in that case return value (not variable) of fopen is ignored. This 
is a bad practice because you need to check it, but this is just an 
example. Most other functions return values that we ignore.


Another example (not functions but expressions) is assigning a value:

$a = 5; // returns 5 (and we ignore it again)

it allows us to do the following:

$a = $b = $c = 10;

read from right to left, and it'll go something like this: assign 10 to 
$c (it evaluates to 10), assign (previously assigned value) 10 to $b, 
and so on


So in essence: $c = 5 in expression and returns the value of 5 not a 
variable/reference which can be changed.


Hope this will help you a little,
N::

P.S. Just a thought... If you declare the method to return a ref maybe 
you can get away with it...


private public  getThis() {
$tempArr = array( 'a', 'b', 'c' );

return $tempArr;
}

as opposed to:

private public getThis() { ... }


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



Re: [PHP] imap_open

2005-09-20 Thread Joachim Person
Just want to say that

telnet imap.liu.se 993

works just fine (the port for secure communication). But then the command 
prompt starts to look strange. I cannot see when I'm typing (perhaps it has 
to do with the secure communication link?!). Where do I go from here? It 
still doesn't work with the php script.

Regards,
Joachim

viraj [EMAIL PROTECTED] skrev i meddelandet 
news:[EMAIL PROTECTED]
did you tried telneting to host's 143 port? if you are getting a
response from the IMAP server you better go through the php-imap
requirements, it's here..

http://www.php.net/imap

 ? I have got the address and the port to the imap server right, but I 
 think
 that the imap server requires some sort of secure login. Could this be the

it depends,

http://www.php.net/manual/en/function.imap-open.php

~viraj.

 problem? If yes, how can it be solved? If no, what other causes could it 
 be?

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

 

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



Re: [PHP] imap_open

2005-09-20 Thread Joachim Person
Further, when changing the imap_open line in the script to

$mbox = imap_open({imap.liu.se:993/imap/ssl}, joape382, fiol);

(I added the /imap/ssl part) I immediately got the following response:


Warning: imap_open(): Couldn't open stream {imap.liu.se:993/imap/ssl} in 
c:\inetpub\wwwroot\TestGetMail.php on line 2

Mailboxes

Warning: imap_listmailbox(): supplied argument is not a valid imap resource 
in c:\inetpub\wwwroot\TestGetMail.php on line 5
Call failed

Headers in INBOX

Warning: imap_headers(): supplied argument is not a valid imap resource in 
c:\inetpub\wwwroot\TestGetMail.php on line 16
Call failed

Warning: imap_close(): supplied argument is not a valid imap resource in 
c:\inetpub\wwwroot\TestGetMail.php on line 26

Notice: (null)(): Can't open mailbox {imap.liu.se:993/imap/ssl}: invalid 
remote specification (errflg=2) in Unknown on line 0



When not having the /imap/ssl part I only get


 Warning: imap_open(): Couldn't open stream {imap.liu.se:993} in 
c:\inetpub\wwwroot\TestGetMail.php on line 2

Fatal error: Maximum execution time of 30 seconds exceeded in 
c:\inetpub\wwwroot\TestGetMail.php on line 2

Notice: (null)(): [CLOSED] IMAP connection broken (server response) 
(errflg=2) in Unknown on line 0


as a response after 30 seconds. Does this mean I have to include a 
certifcate of some kind in some way? If I need, how to do it?

Regards,
Joachim



viraj [EMAIL PROTECTED] skrev i meddelandet 
news:[EMAIL PROTECTED]
did you tried telneting to host's 143 port? if you are getting a
response from the IMAP server you better go through the php-imap
requirements, it's here..

http://www.php.net/imap

 ? I have got the address and the port to the imap server right, but I 
 think
 that the imap server requires some sort of secure login. Could this be the

it depends,

http://www.php.net/manual/en/function.imap-open.php

~viraj.

 problem? If yes, how can it be solved? If no, what other causes could it 
 be?

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

 

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



Re: [PHP] Installing under IIS6.0

2005-09-20 Thread Dan Trainor
Jay Blanchard wrote:
 [snip]
 However, this really isn't what I'm looking for.  I'm simply looking for 
 a way to parse PHP code from within existing HTML pages, so that I can 
 migrate a site from Apache to IIS6.0.
 
 Like I said, if I were using Apache, I would just add .html to my 
 AddType directive, and call it good.  Is it not this simple under IIS?
 [/snip]
 
 Sorry, I just saw this thread.
 
 In order to handle HTML you have to allow it to be handled via the ISAPI dll
 
 Open Internet Information Services, right click on the web site, click
 Properties.
 On the Home Directory tab make sure Execute Permissions is set to Scripts
 Only.
 Click the Configuration button just to the right of that.
 Click Add.
 In the Executable box put the path to yous PHP ISAPI dll
 In the Extension box put .html
 Click OK until you get back to the IIS main. Stop the web server, then
 restart. HTML files will now be handled through the PHP dll.
 

Thanks for the response, Jay -

Some trial and error led me to do just this, which works fine.

The reason why I'm doing this, is because I'm trying to get someone to
convert from using PHP embedded inside HTML pages, to making straight
PHP pages ending with .php, so that only PHP will snag those.  For right
now I'm satisfied with a resource sacrafice to make this transition work.

Thanks again
-dant

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



Re: [PHP] Tidying code for PHP5.0.5/PHP4.4.0

2005-09-20 Thread Rasmus Lerdorf
Lester Caine wrote:
 This type of code is used in a few places, so I'd like a little help
 converting it to 'good code' under the new rules ;)
 
 Get the key from an array ( fails because key(array) )
 
 if( $pId == key( $this-getFunc() ) ) {
 
 In getFunc()
 
 return ( $this-getAssoc(select Id, Content from database...);
 
 Current fix is just to create the array and use that
 $keyarray = $this-getFunc();
 if( $pGroupId == key( $keyarray ) ) {
 
 This works fine, but is there a 'proper' way to do it now that what
 looked tidy originally fails with an error?

There is nothing wrong with that code.  key() and current() don't need
to take a reference and this has been fixed in CVS and will be in the
next release.  It was overlooked in the past because we didn't have any
sort of warning about discarded references.  We have also fixed things
such that discarded references in other circumstances such as:
array_pop, array_shift, end(), etc. will only throw an E_STRICT in PHP
5.x.  E_STRICT is the new super-pendantic warning level that is disabled
by default but can be turned on to help you track down potential sources
of errors such as doing:

  sort($this-getArray());

If you have forgotten to make the getArray() method return its array by
reference, then that sort call will do absolutely nothing and it can
often be really hard to find a bug like that.

-Rasmus

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



Re: [PHP] Tidying code for PHP5.0.5/PHP4.4.0

2005-09-20 Thread Rasmus Lerdorf
Michael Sims wrote:
 Jochem Maas wrote:
 
foo($a = 5);

by definition the expression is evaluated _before_ the function is
called - so the expression is not passed to the function, the result
of the expression is passed ... I was under the impression that the
the expression evaluates to a 'pointer' (I'm sure thats bad
terminology) to $a ... which can taken by reference by the function.

possibly I am completely misunderstanding what goes on here.
 
 
 When used as an expression, an assignment evaluates to whatever is on the 
 right side of the assignment operator, not the left.  Example:
 
 var_dump($a = 5);
 outputs
 int(5)
 
 var_dump($a = some string);
 outputs
 string(11) some string
 
 So, as far as foo() knows:
 
 foo($a = 5);
 and
 foo(5);
 
 are exactly the same...

The value passed is the same, but when passed as $a=5 then the value has
a symbol table entry associated with it whereas if you just pass in 5 it
doesn't.  That means that:

function foo($arg) { $arg =6; }

will work if you call: foo($a=5);
but you will get an error if you have: foo(5);

The above should be pretty straightforward and isn't new.  What was
always fuzzy was this slightly more involved example:

function foo($arg) { $arg =6; }
function bar() { return 5; }
foo(bar());

Here we are essentially passing 5 to foo() again, but it isn't a
constant, it is what is known as a temp_var internally in PHP.  Chances
are code like this is hiding a bug, because the temp_var is going to
drop out of scope and the change to it in foo() will be discarded.  This
was initially made to throw a fatal error in PHP 5.x, which was a
mistake on our part.  It now throws an E_STRICT instead because in some
cases this may not actually be a bug.  There are some cases where you
don't care about the discarded reference.  In PHP 4.3.x assigning
references to temp_vars could cause memory corruption which prompted the
fixes to 4.4 and the introduction of an E_NOTICE in certain cases.

-Rasmus

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



RE: [PHP] Tidying code for PHP5.0.5/PHP4.4.0

2005-09-20 Thread Michael Sims
Rasmus Lerdorf wrote:
 Michael Sims wrote:
 When used as an expression, an assignment evaluates to whatever is
 on the right side of the assignment operator, not the left. 
 Example:  
[...]
 foo($a = 5);
 and
 foo(5);
 
 are exactly the same...
 
 The value passed is the same, but when passed as $a=5 then the value
 has a symbol table entry associated with it whereas if you just pass
 in 5 it doesn't.  That means that:
 
 function foo($arg) { $arg =6; }
 
 will work if you call: foo($a=5);
 but you will get an error if you have: foo(5);

Oops, sorry for posting misinformation, I was not aware of the above...  Thanks 
for the info.

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



Re: [PHP] core files

2005-09-20 Thread Jochem Maas

Jon wrote:

OK, OK,  Ha-ha  Thought that you guys could read my mind...


no this is php-generals not php-psychics - easy mistake to make tho ;-)
glad to see you can take a little stick :-) you'll do well here ;-)

to start with, it will probably help to track down the problem if
you turn off safe_mode and don't use open_basedir for the moment. (don't know 
if you do)



Here is the error
Warning: fopen(C:\windows\Desktop\php\php pages\phpout.txt)
[function.fopen]: failed to open stream: No such file or directory in
C:\windows\Desktop\php\php pages\phpout.txt on line 12


what does your fopen() line look like?


and of course the fwrite and fclose do not work cause the file is an invalid
stream.

I have a few computers with php installed they are all Win based except for
one nix based server.  The script that I want to make portable will need to
run on a Windows ME/9X box and an XP box.


Wind ME/9x are you mad? I would drop that shit quick (jmho).



On my testing computer I have an Installed version of PHP 5.0.3
when I run my script with this version I have no problems

On a different computer I have xampplite from
http://www.apachefriends.org/en/xampp-windows.html#646 The version in it is
5.0.4 according to the website.
I have no problems with this version either


so the problem is with the *nix box? which machine has problems?
a path like 'C:\windows\Desktop\php\php pages\phpout.txt' is not going to
work on a *nix box for sure, and also if its a *nix box you probably need to
set the permissions so that the user which php/webserver is running as
can create/modify a file in the relevant dir



What I have been trying to do is get the files needed for my script to run
and not have to have a lot of files that I don't need.  So I made a dir on
my desktop and copied in the files that I know I need and modified the
php.ini accordingly but for some reason fwrite is not working. It is not
creating the file.
 I have a file list if it is necessary.

Thanks again...



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



Re: [PHP] Tidying code for PHP5.0.5/PHP4.4.0

2005-09-20 Thread Jochem Maas

Michael Sims wrote:

Jochem Maas wrote:


foo($a = 5);


by definition the expression is evaluated _before_ the function is
called - so the expression is not passed to the function, the result
of the expression is passed ... I was under the impression that the
the expression evaluates to a 'pointer' (I'm sure thats bad
terminology) to $a ... which can taken by reference by the function.

possibly I am completely misunderstanding what goes on here.



When used as an expression, an assignment evaluates to whatever is on the right 
side of the assignment operator, not the left.  Example:


right so $a evaluates to 5 and a reference to the value of $a is passed. what 
you say doesn't make sense (to me)
take a look at the following:


?

$b = 6;
$c = another string;
var_dump(($a = 5), $a, ($a = some string), $a, ($a = $b), ($a = $c), $b, $c); 
  

?

as you see dumping the expression ($a = 5) and dumpimg plain old $a result in 
the same (as far as the output
is concerned) its therefore not possible to conclude that



var_dump($a = 5);
outputs
int(5)

var_dump($a = some string);
outputs
string(11) some string

So, as far as foo() knows:

foo($a = 5);
and
foo(5);

are exactly the same...


I don't think they are, and you're examples don't prove it.
Anyone care to come up with the proof. or explain to thick-eared old me
where I am mistaken.





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



Re: [PHP] Fwd: Code Optimization Help

2005-09-20 Thread Joseph Crawford
Ok so finally i implemented my logging class into my mail merge object, this 
is the results

Word - Application Opened.
Word - Document1 Document Added.
Word - header.doc Document Saved.
Word - header.doc Document Closed.
Word - Document2 Document Added.
Word - ds.doc Document Saved.
Word - ds.doc Document Closed.
Word - Has_Site.dot Document Opened.
Word - Opening Header Source.
F:/htdocs/csaf/data/mailmerge/header.doc File Exists

I threw in a file_exists check to make sure the script was actually seeing 
the file and had the correct path. It does. This is very strange because 
nothing happens, it's like i hit a never ending loop but php never times out 
either. I have my php timeout to 30 seconds yet this has run in excess of 5 
minutes now.

The expected results for the log would look something like this
Word - Application Opened.
Word - Document1 Document Added.
Word - header.doc Document Saved.
Word - header.doc Document Closed.
Word - Document2 Document Added.
Word - ds.doc Document Saved.
Word - ds.doc Document Closed.
Word - Has_Site.dot Document Opened.
Word - Opening Header Source.
F:/htdocs/csaf/data/mailmerge/header.doc File Exists
Word - Opening Data Source.
Word - Executing Merge.
Word - Has_Site.doc Document Saved.
Word - Has_Site.doc Document Closed.
Word - Merge Successful.


The code that is hanging is below

private function CreateDocument($template) {
$this-obj-Documents-Open($this-mm_data_dir.'/'.$template.'.dot');
Logger::log('Word - '.$this-obj-ActiveDocument-Name().' Document 
Opened.');

Logger::log('Word - Opening Header Source.');
if(file_exists($this-mm_data_dir.'/header.doc')) {
Logger::log($this-mm_data_dir.'/header.doc File Exists');
}
// THIS IS THE LINE THAT HANGS, THE FILE EXISTS AND IS POPULATED THE FILE 
CONTENTS CAN BE SEEN HERE
http://codebowl.dontexist.net/bugs/MailMerge/3.jpg$this-obj-ActiveDocument-MailMerge-OpenHeaderSource($this-mm_data_dir.'/header.doc');
Logger::log('Word - Opening Data Source.');
$this-obj-ActiveDocument-MailMerge-OpenDataSource($this-mm_data_dir.'/ds.doc');
Logger::log('Word - Executing Merge.');
$this-obj-ActiveDocument-MailMerge-Execute();
$this-obj-ActiveDocument-SaveAs($this-mm_data_dir.'/'.$template.'.doc');
Logger::log('Word - '.$this-obj-ActiveDocument-Name().' Saved.'); 
Logger::log('Word - '.$this-obj-ActiveDocument-Name().' Document 
Closed.');
$this-obj-ActiveDocument-Close();
}

Any help with this would be appreciated. I am not sure why it is choosing to 
hang today ;( I have been going through the COM object API documentation and 
i dont see myself doing anything i shouldnt be doing.

You can see the full code here
http://pastebin.com/369068
that is if it hasnt expired, if so send a reply and i will post again ;)
Thanks in advance

-- 
Joseph Crawford Jr.
Codebowl Solutions, Inc.
1-802-671-2021
[EMAIL PROTECTED]


Re: [PHP] comparing dates

2005-09-20 Thread Philip Hallstrom

Is there a quick way to compare dates in the format dd/mm/yy without
exploding and comparing the individual parts?


Compare them in what way?  Before, after, days between?

In any case, i'd look at strtotime() to convert them into timestamps, then 
diff them to get the number of seconds b/n them, then go from there.


If strtotime() won't do it because it expects mm/dd/yy (consider 01/02/05 
is that feb 1st or jan 2nd?) then split up the string and use mktime().


good luck.

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



[PHP] [RELEASE ANNOUNCEMENT] PEAR 1.4.0 provides revolution in PHP installation

2005-09-20 Thread Greg Beaver
September 20, 2005
FOR IMMEDIATE RELEASE
Contact: Gregory Beaver ([EMAIL PROTECTED])

As of Sunday, September 18, 2005, the PEAR installer has reached
maturity as an enterprise-level installation tool for PHP code.  The
release of version 1.4.0 stable ushers in several essential features for
management of PHP extensions and packages.

1.  PEAR channels
(http://pear.php.net/manual/en/guide.migrating.channels.php)
2.  Better handling of PECL extensions and dependencies on PECL packages
(http://pear.php.net/manual/en/guide.developers.package2.peclinfo.php)
(http://pear.php.net/manual/en/guide.developers.package2.dependencies.php)
3.  more than 650 regression tests in .phpt format
4.  extensive application support through addition of post-install
scripts, custom file roles and file tasks, and the new bundle package
type (http://pear.php.net/manual/en/guide-migrating.php)

PEAR Channels provide a unique distributed installation paradigm.  By
distributing packages through a channel, users can install and configure
an application with a single step rather than the old
download/unzip/tinker system.  For instance, if a high-quality package
is written that is licensed under the GNU license, it cannot be
distributed through pear.php.net or pecl.php.net.  Now, it is possible
to set up a channel like the hypothetical pear.example.com and
distribute it that way.  The user can then install this package just
like any other with:

$ pear install pear.example.com/Packagename

Better yet, developers can depend on this package in their own packages,
removing the need to bundle dependencies.  Critical security fixes for
dependencies can be quickly updated without requiring a release for the
main application.

For PHP extensions written in C/C++, the new pecl command provides a
more robust way to install and upgrade PECL packages.  In addition, for
PECL developers, several enhancements to the way dependencies work allow
the PEAR installer to properly detect a PECL extension regardless of
whether it was built into PHP, a shared module, or installed via the
pecl command.

All of these new features come with additional stability, thanks to the
use of over 650 .phpt-based regression tests.  In the development of
PEAR 1.4.0, several low-level design flaws were uncovered in PEAR 1.3.6
and earlier that have all been fixed in version 1.4.0.  All new features
have been rigorously tested both through regression tests and in the
wild with an extensive alpha- and beta-testing period that covered
nearly a year.

The PEAR installer now has far greater application support.  The
addition of post-installation scripts allows standardized customization
of packages.  Custom file roles and file tasks allow granular
configuration of packages at the file level.  In addition, distribution
of large applications can be simplified with the new bundle package
type.  Bundles allow distributing a package and all of its dependencies
in a single file.

PEAR (http://pear.php.net) is the official code repository of the PHP
project (http://www.php.net).  In addition to providing the PEAR
installer, PEAR provides high-quality object-oriented libraries through
pear.php.net, and PHP extensions through pecl.php.net.

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



[PHP] Re: user can post items while outhers cannot?

2005-09-20 Thread James Benson
Probably your code, changes were made in the newer versions of PHP which 
make some older scripts unusable, register globals for instance, do you 
have the PHP.ini settings to show errors turned on, you should, if you 
post the code snippet someone will probably be able tell whether its the 
code or not if your not sure,



James



Joeffrey Betita wrote:

hello
  i installed mysql-standard-4.1.13-pc-linux-gnu-i686.tar.gz, i followed
the instruction on the INSTALL-BINARY file. after that i installed
httpd-2.0.54.tar.gz followed the instruction on the INSTALL file. also
installed php-5.0.4.tar.gz
followed the install intruction in the INSTALL file. CentOS release 4.0
(Final) is the linux distribution. some user when trying to post an item
cannot post an item. they are being redirected to the welcome page. once
they click the post item button. while other user can post an item
succesfully. i been looking at the apache access and error logs and
/var/log/messages no luck. what log files should i be looking for. did i
miss anything while installing on the ./configure [options] mysql, apache,
php etc. on our old server the version of apache-2.0.47, mysql-4.0.15a-log,
php-4.3.3 the OS is RH9 before our only problem is too many connections
error when they browse our website. is this a apache, MySQL, PHP etc.
problem. i just would like to know. any help would be appreciated. thank you
very much.


rgds,
Joeffrey



--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.344 / Virus Database: 267.11.3/106 - Release Date: 9/19/2005


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



[PHP] BOOKING SYSTEM

2005-09-20 Thread php @ net mines

Hi all

I have a hotel booking system where for sppecific periods we have specific 
availability


e.g. hotel_id, hotel_name, hotel_fromperiod, hotel_toperiod, 
hotel_availablesinglerooms

1, Hilton, 20/06/05, 20/08/05, 20

We have a second table for recording the bookings

e.g.hotel1_id, hotel1_name, hotel1_fromperiod, hotel1_toperiod, 
hotel1_availablesinglerooms

1, Hilton, 01/07/05, 20/07/05, 1
2, Hilton, 20/06/05, 25/07/05, 1
3, Hilton, 25/06/05, 27/06/05, 19
4, Hilton, 05/07/05, 05/08/05, 2

Let's say that someone wants to book from the 25/06/05 - 29/06/05 what kind 
of function-SQL do I have to run to check whether there is availability?
(in this example there should be availability between 27 and 29 but not 
between 25 and 27).


Is this way of structuring the easiest and more efficient?

Thank you

Mario 


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



RE: [PHP] Tidying code for PHP5.0.5/PHP4.4.0

2005-09-20 Thread Michael Sims
Jochem Maas wrote:
 Michael Sims wrote:
 So, as far as foo() knows:
 
 foo($a = 5);
 and
 foo(5);
 
 are exactly the same...
 
 I don't think they are, and you're examples don't prove it.
 Anyone care to come up with the proof. 

No, I was wrong, Rasmus corrected me.  That's my one allowed mistake for the 
day.  I promise to wait until tomorrow before making another one. ;)

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




[PHP] Php logging into online bank to get details automatically

2005-09-20 Thread I. Gray

Hi all.

I thought I may of read of this somewhere- but I may be wrong. I am also
not sure whether this is allowed by banks, so please let me know- I want
to stay on the right side of the law!

I'd like a php script to access my bank balances and send me an email
daily. I know how to set up cron and use the php mail feature, and to
parse web pages using php but the problem is reading a page in SSL and
putting info in multiple forms. For example my bank asks for two
security numbers then 2 digits from a password on the next page. Is it
possible to use php to do this? Is there a script out there which would
help me here. I have googled to try and find out but to no avail.

Thanks.

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



RE: [PHP] Tidying code for PHP5.0.5/PHP4.4.0

2005-09-20 Thread Murray @ PlanetThoughtful
 Jochem Maas wrote:
  Michael Sims wrote:
  So, as far as foo() knows:
 
  foo($a = 5);
  and
  foo(5);
 
  are exactly the same...
 
  I don't think they are, and you're examples don't prove it.
  Anyone care to come up with the proof.
 
 No, I was wrong, Rasmus corrected me.  That's my one allowed mistake for
 the day.  I promise to wait until tomorrow before making another one. ;)

Who was it that said, If you find that you only made one mistake today, you
weren't looking hard enough?

Oh, that's right, it was me. ;)

Off to make more mistakes...

Much warmth,

Murray
---
Lost in thought...
http://www.planetthoughtful.org

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



RE: [PHP] Re: Suggestions for class design

2005-09-20 Thread Murray @ PlanetThoughtful
[snippage]

 I do not understand why this could bother you or anybody else. If you
 have a better solution, nothing stops you to make your recommendations.

Hi Manuel,

I did make my recommendation. To you. It went something like (and I'm
paraphrasing), Your proposed solution doesn't solve the original poster's
conceptual problem with abstracting classes that deal with collections of
objects in conjunction with classes that abstract single objects.

In other words, and I realize I'm stretching out on a limb with this
metaphor, I saw in your post an attempt to treat the symptoms without
offering a cure for the disease.

Actually, that really is a terrible metaphor. I'm certain I'll think of a
better one about 3 seconds after I hit 'send'. Isn't that always the way?

And your perception of bias may or may not be accurate. I don't recall
delivering wrath-of-god denunciation of your suggestion to use a project you
developed, just acknowledged a desire to promote a project you're probably
(and perhaps justifiably) proud of. You say that wasn't a component of your
recommendation. I'm willing to accept that, not that I expect you to be
losing any sleep over whether or not I believe you.

This is a reality of expressing opinions on a public list: others are free
to disagree with you. See Michael Sims' response to the same post you're
addressing here. He makes some great points and I for one am glad he had an
opportunity to make them in response and counterpoint to a post I made. His
thoughts enrich the list, as do yours, and as, I hope, do mine.

  This is not to trivialize your Metastorage project (or, to be more
 accurate,
  I know nothing about it, so it's not my place to trivialize it or
  otherwise), but to point out that 'out-of-the-box' solutions to
 fundamental
  coding development problems probably ultimately makes for a poorer
  programmer. I could well be wrong, but it seems this is a case of give
 a
  man a fish as opposed to teach a man to fish.
 
 I think you should have learned about Metastorage first before
 commenting. It is not really a out-of-the-box solution. It is a code
 generator tool that employs well known design patterns to generate code
 to customized to the developer needs.

At some point I just may do that. It's an interesting concept, if nothing
else. My comments remain relevant, however, regardless of my knowledge of
your project. At least, and this is important, that's my opinion.

  Also, and separate from above, I don't understand the relevance of your
  comment, You are trying to retrieve objects into memory before they
 exist.
  Unless I'm horribly mistaken [1], the original poster has developed a
 class
  that abstracts a single customer, and is asking the list for suggestions
 in
  how to best approach a need to be able to abstract collections of
 customers.
  This is a normal application development issue, and for the life of me I
  can't grasp how your comment relates.
 
 I tried to explain in the part of the message that you did not quote,
 why using a factory class as entry point, which is my suggestion, it
 makes more sense.

Thank you for the extra explanation. I still don't understand the comment's
relevancy to the actual question being asked by the original poster, but I
will explain, in case it's of interest, why that comment caused me some
confusion:

- The original poster outlined that he had created a class that represented
a customer.

- He told the list he was having difficulties with the concept of
abstracting a collection of customers

- He received some helpful suggestions from the list about how to approach
that task

- None of which would have meant he was 'trying to retrieve objects into
memory before they exist.' I don't know about anyone else, but what that
comment implied to me was that the original poster was attempting to
instantiate a class as an object before including the file that contained
the class definition.

I may well have misunderstood what you meant by your comment, but it still
stands out as not being relevant to the problem the original poster was
describing.

Much warmth,

Murray
---
Lost in thought...
http://www.planetthoughtful.org

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



RE: [PHP] Re: Suggestions for class design

2005-09-20 Thread Murray @ PlanetThoughtful
  This is not to trivialize your Metastorage project (or, to be more
  accurate, I know nothing about it, so it's not my place to trivialize
  it or otherwise), but to point out that 'out-of-the-box' solutions to
  fundamental coding development problems probably ultimately makes for
  a poorer programmer. I could well be wrong, but it seems this is a
  case of give a man a fish as opposed to teach a man to fish.
 
 I see your point, but I'm not so sure I agree fully.  Manuel suggested
 Metastorage (which makes sense, it's his project and he's most
 familiar/comfortable with it), I suggested Propel because that is what
 I've
 used.  I think we both suggested existing ORM's for the same reason...
 namely that properly implementing a full featured ORM is an extremely
 difficult thing to get right.  I don't know anything about Chris's skill
 as
 a programmer, but he's bound to reinvent the wheel several times over, and
 poorly to boot.  I believe that implementing an ORM is one of those things
 that you cannot fully understand and appreciate until you've tried to do
 it
 and failed.  IMHO it's only after you've built one that you realize what
 you
 really need, and by then it needs to be rebuilt.  It's kind of like Fred
 Brook's plan to throw one away; you will, anyhow, or at least it was for
 me.

Hi Michael,

You've hit on a point that I implied in my original post, but should have
been more explicit about. If I can add some emphasis: * IMHO it's only after
you've built one that you realize what you really need *

I couldn't agree more. As I read and understand the original poster's
question, he is still in the 'building one' phase of his development as an
OO PHP coder. If this wasn't the case, I doubt he'd be asking the question
he asked.

My post was not aimed at saying 'using packaged approaches to solve coding
problems is bad', but to say 'the original poster is asking a fundamental
learning question, so a packaged approach will possibly, maybe even
probably, hamper his development as a programmer at this point.' Put another
way, working out how to implement a class to handle the question he asked
would not be incredibly challenging, particularly with the help and advice
of people on this list, and would add to his understanding of how OO works
generically and in PHP. Both very good things.

I use several package solutions in my own projects. Notably, MDB2 and
HTML_QuickForm. I use MDB2 because it means my projects can be more flexible
to any decisions made to change the backend storage technology. I use
HTML_QuickForm because it provides convenient methods to building forms, and
it minimizes the mixture of HTML and PHP code in my pages, something I
personally prefer. Having said which, before adopting either of these
packages I was satisfied that I understood how to achieve the same results
using nothing more than my own coding skills. 

In other words, as a programmer I am comfortable working directly with a
variety of data storage backends, employing classes to abstract different
collections of data objects. I am comfortable building, validating, and
processing forms. The packages I use are for convenience, rather than
placing me at arm's length to understanding the programming concepts and
needs they address.

Also, I don't disagree that there are some brilliant packages out there,
written by people who've taken time to learn more about a specific problem
or set of problems than the average programmer would have to spend,
particularly across the broad range of coding demands an application may
touch upon. Again I reiterate: using packages to address application needs
is not a bad thing, while avoiding learning the basics of programming by
using such packages almost certainly is, particularly if you're taking your
development as a programmer seriously, and consider yourself to be aiming at
becoming a 'professional' programmer.

[here there be snippage]

 My point is, I had implemented my own home grown ORM about 3-4 times, and
 while each one was much better than the one that preceded it, I still
 wasn't
 quite all the way towards a 100% general implementation.  That's when I
 found Propel.  It got so many things right that I hadn't figured out how
 to
 solve, as well as implementing things that I hadn't even considered yet.
 
 Now, you could argue that going through all those iterations and
 refactoring
 my own ORM helped me to improve my skills as a programmer, and you would
 be
 right.  That's where I agree with you, somewhat. :)  However, I was many
 many iterations away from improving my ORM to the point where it would be
 as
 useful as Propel (and that's assuming it would ever be that useful).  The
 guys who developed it (and I'm sure the same goes for Manuel and
 Metastorage) concentrated on making the best general purpose ORM they
 could
 make.  IOW their whole goal was to build an ORM, while my goal each time
 was
 to develop one for the purposes of finishing whatever real project I
 

[PHP] specifying a font in PHP-generated email

2005-09-20 Thread Kenn
Greetings.

I'm attempting to create an HTML email via PHP and cannot get the email
to render in the correct font.  I've made several stabs at it, the most
recent one below.  The same code that works just fine on a web page
won't work for me here.  What am I doing wrong? 

Any and all help appreciated.

Kenn


?php
$headers = From: [EMAIL PROTECTED];
$headers .= MIME-Version: 1.0\r\n;
$boundary = uniqid(HTMLDEMO);
$headers .= Content-Type: multipart/alternative .
   ; boundary = $boundary\r\n\r\n;
$headers .= This is a MIME encoded message.\r\n\r\n;
$headers .= --$boundary\r\n .
   Content-Type: text/plain; charset=ISO-8859-1\r\n .
   Content-Transfer-Encoding: base64\r\n\r\n;
$headers .= chunk_split(base64_encode(This is the plain text version!));
$headers .= --$boundary\r\n .
   Content-Type: text/html; charset=ISO-8859-1\r\n .
   Content-Transfer-Encoding: base64\r\n\r\n;
$headers .= chunk_split(base64_encode(HTML
HEAD
TITLE New Document /TITLE
style type=\text/css\
!--
h1 {color: #00;
font-family: \verdana\ ; }
--
/style
/HEAD
BODY
testingbr
h1TESTING 222/h1 test over.
/BODY
/HTML
));
//send message
mail([EMAIL PROTECTED], Another HTML Message, , $headers);
?

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



Re: [PHP] Php logging into online bank to get details automatically

2005-09-20 Thread John Nichel

I. Gray wrote:

Hi all.

I thought I may of read of this somewhere- but I may be wrong. I am also
not sure whether this is allowed by banks, so please let me know- I want
to stay on the right side of the law!


Your account...I can't see where it would be a problem with how you 
access it.



I'd like a php script to access my bank balances and send me an email
daily. I know how to set up cron and use the php mail feature, and to
parse web pages using php but the problem is reading a page in SSL and
putting info in multiple forms. For example my bank asks for two
security numbers then 2 digits from a password on the next page. Is it
possible to use php to do this? Is there a script out there which would
help me here. I have googled to try and find out but to no avail.


Try cURL...it may help.  http://www.php.net/curl

--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]

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



RE: [PHP] Re: Suggestions for class design

2005-09-20 Thread Michael Sims
Murray @ PlanetThoughtful wrote:
 My post was not aimed at saying 'using packaged approaches to solve
 coding problems is bad', but to say 'the original poster is asking a
 fundamental learning question, so a packaged approach will possibly,
 maybe even probably, hamper his development as a programmer at this
 point.'
[...]

Gotcha.  Makes sense; thanks for explaining...

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



Re: [PHP] Php logging into online bank to get details automatically

2005-09-20 Thread I. Gray
Curl- ahh, thanks not something I've looked into yet. Are there any 
other resources out there that I could look at for learning about it?


Thanks.

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



RE: [PHP] Suggestions for class design

2005-09-20 Thread Chris W. Parker
Sorry I've been so quiet on this topic since I started it but I've
basically been overwhelmed with information! :) I was hoping the
answer(s) would be a lot more plain and simple than it(they) has been so
I could get to implementing some things right away. But I'm afraid it's
going to take me longer than I'd hoped.

It would be great if someone could contribute some more fleshed out and
basic code, but I know we're probably all busy.

As I have spare time I'll go over again (and again) the messages in this
topic as well as Propel and Metastorage.


Thanks,
Chris.

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



[PHP] Chat module

2005-09-20 Thread Vinicius Mapelli Schmaedek
Somebody knows a chat module to be used for conversation between only 
two people?


PS: sorry, my english is not very good  :P

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



RE: [PHP] Re: Suggestions for class design

2005-09-20 Thread Chris W. Parker
Murray @ PlanetThoughtful mailto:[EMAIL PROTECTED]
on Tuesday, September 20, 2005 8:15 AM said:

 And it's also worth mentioning at this point that it might present
 more of a challenge to the original poster to implement and make use
 of a complex data abstraction package [1] than to learn a solution
 that not only addresses his specific question but also helps in his
 learning as a programmer.

Yep. You got it.

Basic building blocks are much better for me than taking an already
mature system and shoehorning it into my app, or rather, shoehorning my
app into it.


Chris.

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



Re: [PHP] Php logging into online bank to get details automatically

2005-09-20 Thread Jasper Bryant-Greene

John Nichel wrote:

I. Gray wrote:


I thought I may of read of this somewhere- but I may be wrong. I am also
not sure whether this is allowed by banks, so please let me know- I want
to stay on the right side of the law!


Your account...I can't see where it would be a problem with how you 
access it.


Here in New Zealand most banks have a clause in their Internet Banking 
terms of use saying that you may not use automated systems to access the 
banking system. Many of them include those silly CAPTCHA things to try 
and prevent them too.


IANAL, but you may want to have a close look at your bank's terms of use.


I'd like a php script to access my bank balances and send me an email
daily. I know how to set up cron and use the php mail feature, and to
parse web pages using php but the problem is reading a page in SSL and
putting info in multiple forms. For example my bank asks for two
security numbers then 2 digits from a password on the next page. Is it
possible to use php to do this? Is there a script out there which would
help me here. I have googled to try and find out but to no avail.


Try cURL...it may help.  http://www.php.net/curl


Even file_get_contents() and friends can access SSL URLs, provided PHP 
is compiled with SSL support, but they can't send POST requests which 
you need for logging in, etc.


So use CURL to post to the login form, and then get the session cookie 
that they send back, and send that along with your request for the 
balances page.


Once you've got the content of the page just apply string functions or 
some regex magic to get your balances, or go hardcore and try to parse 
their page with the DOM functions.


Remember that your code will likely break if they make substantial 
changes to their site design.


--
Jasper Bryant-Greene
Freelance web developer
http://jasper.bryant-greene.name/

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



Re: [PHP] specifying a font in PHP-generated email

2005-09-20 Thread Richard Davey
Hello Kenn,

Tuesday, September 20, 2005, 9:32:47 PM, you wrote:

 I'm attempting to create an HTML email via PHP and cannot get the
 email to render in the correct font. I've made several stabs at it,
 the most recent one below. The same code that works just fine on a
 web page won't work for me here. What am I doing wrong?

Forget trying to include style elements in the header block for
emails, most mail clients strip them out totally. There is no
foolproof way to embedded CSS into an email and have all clients
handle it correctly (if at all). Lots of mail clients will attempt to
render the HTML themselves and don't support any form of CSS at all,
whereas others (like Outlook) use the IE rendering engine on Windows.

My suggestion? Embed the font styles into the email body and don't
even bother with a head section. I'd even go so far as to suggest
you use the HTML 4.x font tags instead of CSS.

But as with everything on the Internet, your mileage will always vary.

This article should also help: http://www.alistapart.com/articles/cssemail

-- 
Best regards,
 Richardmailto:[EMAIL PROTECTED]

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



Re: [PHP] Chat module

2005-09-20 Thread adriano ghezzi
should be not too difficult to setup using a couple of web pages
running on localhost e socket
hope help






2005/9/20, Vinicius Mapelli Schmaedek [EMAIL PROTECTED]:
 Somebody knows a chat module to be used for conversation between only
 two people?
 
 PS: sorry, my english is not very good  :P
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 


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



[PHP] help out a noob w/ include switch?

2005-09-20 Thread jay thompson
Hi All,
My very first post to this group as I'm a freshly spanked new born php
baby. Hope I have the correct stop for noob tech questions. Please
re-direct me if I have it wrong. I've been doing web dev for a quite while
with a variety of methods (html, xhtml/css, cfml, flash/as, on and on...).
I work mainly for non-profit organizations and thought it was about time to
get away from commercial software. I'm doing my first site now w/ a
XHTML/CSS template that uses PHP to insert data from a switch container and
from a MySQL db. 

My problem occurs only on the server (NT 5 b.2195, PHP 4.3.10, IIS 5.0) but
works great on my dev rig (XAMPP 1.4.15, VectorLinux).

My template index.php uses 'include' to get '$vars' from two files. one
for the body text and title, and the other for the navigation. Click on a
link in the navbar and index.php reloads with the new navbar and the
associated content each into it's div. Works great on my test rig but the
server the site will be hosted from ignores the urlencoded vars and just
loads the switch defaults. For whatever reason I tried return() instead of
break. Again, it worked on my rig but not the server. I know i'm missing
some dumb little thing but I have not figured out what yet. I also tried
session_unset() at the beginning of the index.php in case the problem was
with caching. Didn't work either but may be due to incorrect usage. Any
help or advice is very greatly appreciated!!

jt.

index.php:
?php
include 'content.php';   //sets the section title
echo $title;
?
?php
include 'navigate.php';  //sets appropriate navigation menu
echo $navigate;
?
?php
echo $content;   //loads body text
?

content.php:
?php
switch ($cont)
{
case artist1:
$title = 'event title';
$content = 'psome text/p

psome more text/p

p class=sig- artist name/p';
break;
case artist2,3,4:
[...]
break;
default:
$title = 'event title';
$content = 'psome text/p

psome more text/p

p class=sig- artist name/p';
break;
}
?

navigate.php:
?php
switch ($nav)
{
case 1:
$navigate = 'ullia 
href=index.php?nav=1amp;cont=artist1Link
titlebr /by artist1/a/lilia
href=index.php?nav=2amp;cont=artist2link titlebr /by
artist2/a/lilia href=some more stuff/a/lilia
href=Contact/a/li/ul';
break;
case 2,3,4:
[...]
break;
default:
$navigate = 'ullia 
href=index.php?nav=1amp;cont=artist1Link
titlebr /by artist1/a/lilia
href=index.php?nav=2amp;cont=artist2link titlebr /by
artist2/a/lilia href=some more stuff/a/lilia
href=Contact/a/li/ul';
break;
}
?

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



Re: [PHP] help out a noob w/ include switch?

2005-09-20 Thread Robert Cummings
On Tue, 2005-09-20 at 18:41, jay thompson wrote:
 Hi All,
 My very first post to this group as I'm a freshly spanked new born php
 baby. Hope I have the correct stop for noob tech questions. Please
 [-- SNP --]

Try verifying your include path in php.ini for the NT version.

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



Re: [PHP] BOOKING SYSTEM

2005-09-20 Thread adriano ghezzi
well I did it in the past, at the end after a lot of tests and
simulation i decided for

warehouse table

id_hotel, date, num_total_rooms, num_booked_rooms

this is day by day handling it is really flexible you can satisfy each
kind of request with very
simple queries
you also gain more flexibility in period definition you canalso easily
handling dsingle day workout and so on

 





2005/9/20, php @ net mines [EMAIL PROTECTED]:
 Hi all
 
 I have a hotel booking system where for sppecific periods we have specific
 availability
 
 e.g. hotel_id, hotel_name, hotel_fromperiod, hotel_toperiod,
 hotel_availablesinglerooms
 1, Hilton, 20/06/05, 20/08/05, 20
 
 We have a second table for recording the bookings
 
 e.g.hotel1_id, hotel1_name, hotel1_fromperiod, hotel1_toperiod,
 hotel1_availablesinglerooms
 1, Hilton, 01/07/05, 20/07/05, 1
 2, Hilton, 20/06/05, 25/07/05, 1
 3, Hilton, 25/06/05, 27/06/05, 19
 4, Hilton, 05/07/05, 05/08/05, 2
 
 Let's say that someone wants to book from the 25/06/05 - 29/06/05 what kind
 of function-SQL do I have to run to check whether there is availability?
 (in this example there should be availability between 27 and 29 but not
 between 25 and 27).
 
 Is this way of structuring the easiest and more efficient?
 
 Thank you
 
 Mario
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 


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



[PHP] Re: help out a noob w/ include switch?

2005-09-20 Thread Ben
jay thompson said the following on 09/20/05 15:41:

 My problem occurs only on the server (NT 5 b.2195, PHP 4.3.10, IIS 5.0) but
 works great on my dev rig (XAMPP 1.4.15, VectorLinux).

At first guess I'd say register globals is on for your test rig and off
for your server.

Since your variables are being passed in the url you should be
referencing them with $_GET['variablename'], so for instance at the
top of navigate.php you should have:

switch ($_GET['nav'])

- Ben

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



Re: [PHP] help out a noob w/ include switch?

2005-09-20 Thread Thorsten Suckow-Homberg

Hi All,
   My very first post to this group as I'm a freshly spanked new born 
php

baby. Hope I have the correct stop for noob tech questions.

Welcome :)


[source]


First guess: On your live server the ini-value error_reporting is switched 
to report anything but notices and warnings or even completely turned off.
Second guess: in the switch statement you provided us as the bogus 
code-fragment you did really forget to use

'

so you should try

 case 'artist1':
...

instead of

 case artist1:

and, for integer values, use

case 1:
case 2:
case 3:
...

instead of

case 1,2,3:
...


I hope this was valuable, or, in other words: HTH

Best regards

Thorsten 


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



Re: [PHP] help out a noob w/ include switch?

2005-09-20 Thread Jasper Bryant-Greene

jay thompson wrote:

index.php:
?php
include 'content.php';   //sets the section title
echo $title;
?
?php
include 'navigate.php';  //sets appropriate navigation menu
echo $navigate;
?
?php
echo $content;   //loads body text
?


There is no need to switch in and out of PHP there. Replace all the ? 
immediately followed by ?php with nothing.




content.php:
?php
switch ($cont)
{
case artist1:
$title = 'event title';
$content = 'psome text/p

psome more text/p

p class=sig- artist name/p';
break;
case artist2,3,4:
[...]
break;
default:
$title = 'event title';
$content = 'psome text/p

psome more text/p

p class=sig- artist name/p';
break;
}
?


Unless you really have a constant defined called artist1, you probably 
want to rewrite the case statements as:


case 'artist1':
[...]
case 'artist2,3,4':
[...]

etc (with the quotes added).

If you actually mean 'artist2', 'artist3', and 'artist4' as separate 
artists, then you'll need to do:


case 'artist2':
case 'artist3':
case 'artist4':

separately.



navigate.php:
?php
switch ($nav)
{
case 1:
$navigate = 'ullia 
href=index.php?nav=1amp;cont=artist1Link
titlebr /by artist1/a/lilia
href=index.php?nav=2amp;cont=artist2link titlebr /by
artist2/a/lilia href=some more stuff/a/lilia
href=Contact/a/li/ul';
break;
case 2,3,4:
[...]
break;


as far as I know, you need to actually do these as separate case statements:

case 2:
case 3:
case 4:
[...]
break;


default:
$navigate = 'ullia 
href=index.php?nav=1amp;cont=artist1Link
titlebr /by artist1/a/lilia
href=index.php?nav=2amp;cont=artist2link titlebr /by
artist2/a/lilia href=some more stuff/a/lilia
href=Contact/a/li/ul';
break;
}
?



--
Jasper Bryant-Greene
Freelance web developer
http://jasper.bryant-greene.name/

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



Re: [PHP] help out a noob w/ include switch?

2005-09-20 Thread Robert Cummings
On Tue, 2005-09-20 at 19:14, Thorsten Suckow-Homberg wrote:
  Hi All,
 My very first post to this group as I'm a freshly spanked new born 
  php
  baby. Hope I have the correct stop for noob tech questions.
 Welcome :)
 
  [source]
 
 First guess: On your live server the ini-value error_reporting is switched 
 to report anything but notices and warnings or even completely turned off.
 Second guess: in the switch statement you provided us as the bogus 
 code-fragment you did really forget to use
 '
 
 so you should try
 
   case 'artist1':
 ...
 
 instead of
 
   case artist1:
 
 and, for integer values, use
 
 case 1:
 case 2:
 case 3:
 ...
 
 instead of
 
 case 1,2,3:
 ...
 
 
 I hope this was valuable, or, in other words: HTH

*heheh* More valuable than my response I'm sure. I musta barely glanced
at it to miss all those flaws. Guess I tried to home in on something
that would cause a difference between one server and another.

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



[PHP] professional code quick tip

2005-09-20 Thread adriano ghezzi
hy guys this night I'm quite tired 

I need a little tip

 ok var n could be from 0 to 12

var f must be set 
f=1 if0n=4
f=2 if   5n=7
f=3 if  8n=12
f=4 if n12

due to my fatigue I coded four if-if else statement,

in other languages it is possible use conditional epression in switch case
like 
switch $n

case (0n=4):


but no in php

any suggestion for more professional coding then 4 if/else statement

tia

a.g.

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



Re: [PHP] professional code quick tip

2005-09-20 Thread Robert Cummings
On Tue, 2005-09-20 at 19:20, adriano ghezzi wrote:
 hy guys this night I'm quite tired 
 
 I need a little tip
 
  ok var n could be from 0 to 12
 
 var f must be set 
 f=1 if0n=4
 f=2 if   5n=7
 f=3 if  8n=12
 f=4 if n12
 
 due to my fatigue I coded four if-if else statement,
 
 in other languages it is possible use conditional epression in switch case
 like 
 switch $n
 
 case (0n=4):
 
 
 but no in php
 
 any suggestion for more professional coding then 4 if/else statement

For such a small set I'd say that's as good as it gets. However if there
were 100 intervals you could try the following:

function f( $n )
{
$map = array
(
// min,   max,f
array(   0, 4,1 ),
array(   5, 7,2 ),
array(   8,12,3 ),
array(  17,  null,4 ),
);

foreach( $map as $criteria )
{
if( $criteria[0] === null || $n  $criteria[0]

$criteria[1] === null || $n = $criteria[1] )
{
return $criteria[2];
}
}

return null;
}

I think your code is flawed by the way, the lower endpoints are only
compared for greater than value and not equal to value meaning $n with
value 4 would not match any f value.

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



Re: [PHP] help out a noob w/ include switch?

2005-09-20 Thread jt
Thanks Thorsten and Rob,
Sry my bogus code was error filled. This is not the case with the 
actual 
code. I was a little quick in removing the large amounts of text that are 
actually contained in the cases and case 1,2,3: is just to say there are 
many more cases. Could this be a problem - Is the server trying to return the 
values with $_GET to the browser? I assume the text from the content.php and 
navigation.php would be inserted on the server but I don't really know. In 
your suggestion, Thorsten, I actually used   case artist1 rather than case 
'artist1'. I switched to single quotes and there is no difference. 

To the .ini settings suggested by both, I don't know what to do. If the 
problem is with a server setting, I have to know what it is to tell my server 
admin to change. He's not familiar with PHP as he uses CFM. He has a PHP 
server running just in case someone asked for it. I am the first. From 
phpinfo() I have found these two settings: include_path .;C:\PHP\pear for 
local and master; and error_reporting is 341 for local and master. I don't 
know if these are correct or how I should code my site to fit within them. 

Thanks again!!
jt


On September 20, 2005 11:14 pm, you wrote:
  Hi All,
 My very first post to this group as I'm a freshly spanked new born
  php
  baby. Hope I have the correct stop for noob tech questions.

 Welcome :)

  [source]

 First guess: On your live server the ini-value error_reporting is
 switched to report anything but notices and warnings or even completely
 turned off. Second guess: in the switch statement you provided us as the
 bogus code-fragment you did really forget to use
 '

 so you should try

   case 'artist1':
 ...

 instead of

   case artist1:

 and, for integer values, use

 case 1:
 case 2:
 case 3:
 ...

 instead of

 case 1,2,3:
 ...


 I hope this was valuable, or, in other words: HTH

 Best regards

 Thorsten

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



Re: [PHP] professional code quick tip

2005-09-20 Thread Thorsten Suckow-Homberg
in other languages it is possible use conditional epression in switch 
case

like
switch $n

case (0n=4):


but no in php


You could use the following statement:

?php
switch (true) {
case (0  $n = 4):
$f = 1;
break;
case (5  $n = 7):
$f = 2;
break;
case (8  $n = 12):
$f = 3;
break;
default:
$f = 4;
break;
}
?

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



Re: [PHP] help out a noob w/ include switch?

2005-09-20 Thread Robert Cummings
On Tue, 2005-09-20 at 19:41, jt wrote:
 Thanks Thorsten and Rob,
   Sry my bogus code was error filled. This is not the case with the 
 actual 
 code. I was a little quick in removing the large amounts of text that are 
 actually contained in the cases and case 1,2,3: is just to say there are 
 many more cases. Could this be a problem - Is the server trying to return the 
 values with $_GET to the browser? I assume the text from the content.php and 
 navigation.php would be inserted on the server but I don't really know. In 
 your suggestion, Thorsten, I actually used   case artist1 rather than case 
 'artist1'. I switched to single quotes and there is no difference. 
 
 To the .ini settings suggested by both, I don't know what to do. If the 
 problem is with a server setting, I have to know what it is to tell my server 
 admin to change. He's not familiar with PHP as he uses CFM. He has a PHP 
 server running just in case someone asked for it. I am the first. From 
 phpinfo() I have found these two settings: include_path .;C:\PHP\pear for 
 local and master; and error_reporting is 341 for local and master. I don't 
 know if these are correct or how I should code my site to fit within them. 

Add this to the top of your script (at least while debugging):

ini_set( 'display_errors',   1 );
ini_set( 'error_reporting', -1 );

That way all problems will be displayed to you in your browser. You
might also want to change the include to require, then PHP will generate
an error if it can't find the the file. let us know what turns up.

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



  1   2   >