Re: [PHP] Php error with MySql

2005-01-07 Thread Stan F

- Original Message -
From: Wil [EMAIL PROTECTED]
To: php-general@lists.php.net
Sent: Thursday, January 06, 2005 9:35 PM
Subject: [PHP] Php error with MySql


 I get the following error

 Warning: mysql_num_rows(): supplied argument is not a valid MySQL result
 resource in /home/wilmail/public_html/elblog.php on line 7
 n=   //error ends here

 with the following bit of code

 $qResult = mysql_query (SELECT * FROM blog_entries ORDER BY id DESC);


Try   echo mysql_error()  just after your query. It's rather common to
make typos or forget to select DB.

 $nRows = mysql_num_rows($qResult);
 $rString =n=.$nRows;

 If I am just naming a variable how is the argument not valid?

 Thanks,

 Wil

 --
 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] On large application organization [long and possibly boring]

2005-01-07 Thread Josh Whiting
 If I have a large app what is the difference, other than having a very
 large file, of doing this
 
 switch($action){
   /* several dozen cases to follow */
   case foo:
   writing out all of the code
   break;
 }
 
 and this
 
 switch($action){
   /* several dozen cases to follow */
   case foo:
   include that will handle processing this case
   break;
 }
 
 Correct me if I am wrong, but includes (and/or requires) will get all of
 the code in all of the cases regardless if the case is being processed.
 That being the case the code would essentially be the same length. Given
 that, would there be an efficieny issue?
 
 This would (the second way) also make the project easier to work on by
 multiple programmers at the same time, similar to modular work being
 done by programmers on C++ projects.

Correction: include() statements are executed at *run time*, which means
that if the case is not executed, the include will not be executed and
the file is not even read!  The include() method is not only more
efficient but also easier to maintain as you suggest.

Otherwise, I'm curious as to why you're using a large switch, not that 
it's bad inherently IMHO, but there may be a better overall approach. 

/jw

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



Re: [PHP] Persistent PHP web application?

2005-01-07 Thread Jason Barnett
Does not up to date mean the code isn't working with current releases
of php 4 or 5? I'd be interested in giving it a try.
I believe this is the case.  AFAIK the APC library doesn't support PHP5 
or at least it didn't when I looked at it.  If you want to pitch in 
support for APC you should just download it (or PEAR INSTALL it from the 
command line to try it :) )

Forgive my ignorance of Apache and PHP internals, but I'm not
understanding the concept of your implementation. I'm not enivisioning
allowing a PHP script to be able to meddle with the Apache request
process.  

I'm picturing an extension that would simply not allow an uncautious or
unknowing scripter to ruin the server, but would only allow him to store
all his app defs and data model startup stuff in a one-shot performance
booster.  It could even do it in a separate (CLI?) interpreter and copy
the data over (but only once!) to the Apache-embedded interpreter using 
a shared memory resource... hmmm.
So your process is something like (correct me if I misunderstand):
php_script
- have a PHP script with all global variables and class definitions that 
will be available to *all* scripts
- parse the PHP file to generate default values for variables
  - as a side note: would this include any autoglobals such as 
$_SERVER, $_ENV, etc. ?  I would think not at least for our first version.
- have a function translate all object definitions into the binary 
version of the definition and return that definition as a string.
- have a function translate each PHP variable into the binary value and 
return these as a string as well.
- write all of these strings to some file (test.static)
/php_script

Restart server.  Here is where I get really fuzzy, mostly because I have 
never written an extension.  ;)

extension
- During MINIT
  - Lock file (test.static) for reading
  - We read from the source file (test.static)
  - We initialize the non-object variables in a PHP-usable form
  - We *try* to initialize objects.  Likely to be some issues here, for 
example, when a class definition changes.
- As a side note, should we create a superglobal array to store 
these global variables similar to $_SESSION?  Maybe $_SHARED?  It is 
likely a pain to implement, but would be cool.  :)
- Module needs a fetch function to get the value in shared memory.
  - It needs to get a lock to read to that part of shared memory 
(forgive me but I don't know the right term here)
  - For objects, this needs to check access level (private, protected, 
public) and return appropriate errors
- Module needs a write function to write to shared memory.
  - It needs to get a lock to write to that part of shared memory
  - For objects, this needs to return appropriate errors for modifying 
properties (i.e. private, protected, public) and return appropriate errors
- During shutdown (I think it's called MSHUTDOWN)
  - Lock file (test.static) for writing
  - Recreate the test.static file
/extension

The above suggestion is quite messy and probably not thread-safe, but 
it's a start.  ;)

--
Teach a person to fish...
Ask smart questions: http://www.catb.org/~esr/faqs/smart-questions.html
PHP Manual: http://php.net/manual/
php-general archives: http://marc.theaimsgroup.com/?l=php-generalw=2
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] E-mails with mail() as UTF-8

2005-01-07 Thread Kimmo Alm
Hey again!
I'm having major trouble using mail() to deliver UTF-8 e-mails.
They get sent and delivered successfully, but seem to be... messed up when  
they arrive (they go through my ISP's relay e-mail server).

My headers basically look like this: From: Test  
[EMAIL PROTECTED]\nMIME-Version: 1.0\nContent-Type: text/plain;  
charset=UTF-8\n.

I want to be able to use UTF-8 chars both in the subject and the body.
When I check the letters in my e-mail client (Opera's built-in one -- M2),  
it shows UTF-16. Also, the headers look different than from the ones I  
send.

Is the relay server altering my letters? What the hell is happening?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Persistent PHP web application?

2005-01-07 Thread Josh Whiting
  Call me crazy or ignorant, i'm both, but would it be possible to build
  an extension that, in its MINIT hook as you suggest, actually runs a
  separate PHP script that contains global definitions, then makes those
  definitions available to later scripts?  this is basically my original
  desire of having a one-time, persistent global include for each apache
  process.  i realize you suggest pulling array data from a source like a
  DB or XML file, which would be a 90% solution for me, but the next step
  (a PHP script) just seemed logical/exciting...
  
  i realize i'm reaching with this, and it implies a conundrum (how does
  an extension run a PHP script if PHP hasn't fully started yet) but this
  kind of thing is just what makes me go and learn new things (C, php/zend
  internals) and I just might try to do it if it was feasible, for the fun
  of it, because it could be useful to lots of people, even if it took me
  a year or two to pull off.
  
  alas, this is a question for the pecl-dev list.
  
  (the mental gears are churning...)
 
 The apache-hooks SAPI can do this, although when I initially wrote it 
 nobody seemed interested.  George fixed it/rewrote it to work much better, 
 but nobody was interested in his version either, so the current 
 implementation isn't up to date anymore.  The problem was likely that 
 people really didn't understand how to use it and it is a rather unsafe 
 thing to let PHP scripts fiddle with all the various Apache request hooks.  
 You can really toast your server that way.  A simple generic data loading 
 extension is something people will be able to understand and they are 
 unlikely to destroy their server with it.
 
 -Rasmus

Does not up to date mean the code isn't working with current releases
of php 4 or 5? I'd be interested in giving it a try.

Forgive my ignorance of Apache and PHP internals, but I'm not
understanding the concept of your implementation. I'm not enivisioning
allowing a PHP script to be able to meddle with the Apache request
process.  

I'm picturing an extension that would simply not allow an uncautious or
unknowing scripter to ruin the server, but would only allow him to store
all his app defs and data model startup stuff in a one-shot performance
booster.  It could even do it in a separate (CLI?) interpreter and copy
the data over (but only once!) to the Apache-embedded interpreter using 
a shared memory resource... hmmm.

I'm not versed enough to suggest a feasible implementation, but if 
the overall goal is feasible then I'm willing to climb the learning 
curve.

I'm also quite surprised there wasn't much interest in these concepts, I
admit the benefits would be small for most apps, but complex apps with
large data setup could save valuable time, and having persistent
namespaces/modules is plugged as a worthy feature of mod_perl and
mod_python, for what it's worth.

/jw

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



Re: [PHP] On large application organization [long and possibly boring]

2005-01-07 Thread Jason Barnett
Jamie Alessio wrote:
Correct me if I am wrong, but includes (and/or requires) will get all of
the code in all of the cases regardless if the case is being processed.
You're wrong. The include() and require() statements are only evaluated 
when they are reached in your application code, so there is a big 
difference between your two examples. In you use the second example the 
code will only be included by PHP if the application logic enters the 
case statement that contains the include() statement. Here's a quick 
example to demonstrate this:

That was what I thought also.  However just to add to the confusion: I 
think require'd files were evaluated no matter what back in PHP4.  Even 
if they were part of a conditional.  At least that's my recollection of 
it; I haven't used PHP4 since 4.3.2 ;)

Bottom line: I always require_once at the top of a file for any files 
that I will require.  No sense in doing anything else if the required 
files aren't there.  For conditionally including files include_once() 
has always made the most sense to me.

--
Teach a person to fish...
Ask smart questions: http://www.catb.org/~esr/faqs/smart-questions.html
PHP Manual: http://php.net/manual/
php-general archives: http://marc.theaimsgroup.com/?l=php-generalw=2
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] PEAR Spreadsheet_Excel_Writer

2005-01-07 Thread Pedro Irán Méndez Pérez
somebody have a example of this class?, because the package don't have,
thank's :)

 =
¿Acaso se olvidará la mujer de su bebé, y dejará de compadecerse del hijo
de su vientre? Aunque ellas se olviden, yo no me olvidaré de ti

Isa 40:27
 =

Atte   Pedro Irán Méndez Pérez

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



[PHP] Re: E-mails with mail() as UTF-8

2005-01-07 Thread HarryG
Possibly the relay server can not send messages in the UTF-8 format so it
has to convert the message.

Try to install a local mail server on your pc smtp server in IIS on Windows
or Postfix in linux and then try use your local server to delivery the mail
rather than the isp's mail server

Kimmo Alm [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
Hey again!

I'm having major trouble using mail() to deliver UTF-8 e-mails.

They get sent and delivered successfully, but seem to be... messed up when
they arrive (they go through my ISP's relay e-mail server).

My headers basically look like this: From: Test
[EMAIL PROTECTED]\nMIME-Version: 1.0\nContent-Type: text/plain;
charset=UTF-8\n.

I want to be able to use UTF-8 chars both in the subject and the body.

When I check the letters in my e-mail client (Opera's built-in one -- M2),
it shows UTF-16. Also, the headers look different than from the ones I
send.

Is the relay server altering my letters? What the hell is happening?

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



Re: [PHP] bizzare duplicate mail() call

2005-01-07 Thread Jason Wong
On Friday 07 January 2005 05:45, Jed R. Brubaker wrote:

[snip]

 The emails are frequent enough (every couple of minutes) that it is very
 easy to track, but I don't have a clue as to what would be the cause.

 Does anyone have any suggestions as to where to start looking?

Your mail server logs.

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
New Year Resolution: Ignore top posted posts

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



Re: [PHP] On large application organization [long and possibly boring]

2005-01-07 Thread Jason Barnett
Otherwise, I'm curious as to why you're using a large switch, not that 
it's bad inherently IMHO, but there may be a better overall approach. 

/jw
I don't know why *he* wants to do it, but one useful example is the MVC 
model (google MVC phppatterns if you're unfamiliar with the term). 
For a given action he can include the class definitions he will need to 
perform that action.

Jay, are you using PHP5?  Because if you are then I thought of something 
else.  You can put each class into its own file and define your own 
__autoload() function to include a file just in time.  The main 
downside to this is if you use someone else's code and they have also 
defined their own __autoload() function then you get an error!  :(

--
Teach a person to fish...
Ask smart questions: http://www.catb.org/~esr/faqs/smart-questions.html
PHP Manual: http://php.net/manual/
php-general archives: http://marc.theaimsgroup.com/?l=php-generalw=2
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] bizzare duplicate mail() call

2005-01-07 Thread Richard Davey
Hello Jed,

Thursday, January 6, 2005, 9:45:38 PM, you wrote:

JRB What is so strange is that it only occurs for these odd periods of time. 
For
JRB example, yesterday from 4pm to this morning at 7am, 2 copies would be sent.
JRB Last week for several days, 5 copies would be sent.

JRB The emails are frequent enough (every couple of minutes) that it is very
JRB easy to track, but I don't have a clue as to what would be the cause.

Rule out if this is a mail server glitch or a PHP script one - one
simple way would be to locate the scripts that send out the mail and
perhaps get them to write an entry to a text file with something
simple like a timestamp and a message of mail sent. Get the script
to append the data to the log rather than over-write.

Then just view the log file after this situation has happened again.
If there are 5 instances of a mail being sent then the error is with
the PHP script logic, or the fact the script is being called 5 times
somehow. If not, the error is with the mail server.

Best regards,

Richard Davey
-- 
 http://www.launchcode.co.uk - PHP Development Services
 I am not young enough to know everything. - Oscar Wilde

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



Re: [PHP] bizzare duplicate mail() call

2005-01-07 Thread Jamie Alessio
The first place I would look is in your web server logs to establish if 
the pages are actually requested multiple times at the time the 
duplicate emails are sent.

- Jamie
Hello all - this problem is so wierd that I don't even know where to start. 
Hopefully you all can give me a couple leads.

I have some reporting systems going on in various places on the server - 
mail() is called when a user does this or that. These scripts are farily 
simple, so I am next to certain is isn't the code - but every once in a 
while, more than one duplicate email will be sent.

What is so strange is that it only occurs for these odd periods of time. For 
example, yesterday from 4pm to this morning at 7am, 2 copies would be sent. 
Last week for several days, 5 copies would be sent.

The emails are frequent enough (every couple of minutes) that it is very 
easy to track, but I don't have a clue as to what would be the cause.

Does anyone have any suggestions as to where to start looking?
Thanks in advance! 

 

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


[PHP] PHP Unit Tests - which framework to use?

2005-01-07 Thread dAniel hAhler
Hello PHP - General,

I'm looking for a PHP Unit Test framework and found so far:
 SimpleTest: https://sourceforge.net/projects/simpletest/
 PEAR PHPUnit:
  - http://pear.php.net/package/PHPUnit
  - http://pear.php.net/package/PHPUnit2
 Sourceforge PHPUnit: http://phpunit.sourceforge.net/

While SF PHPUnit seems to have stalled (2002-10) there are still PEAR
PHPUnit and Simpletest.

I'd like to hear your opinions/experiences on what's better to use.

I'm mainly searching it for an OSS project, but would like to use it at
work, too.

I'm still on PHP4 mainly - but tests could be done/run with PHP5 of
course (if PHPUnit2 supports that).

Thanks for any input.

 
-- 
shinE!
GnuPG/PGP key: http://thequod.de/danielhahler.asc
ICQ#152282665
Random software tip: [***] The Bat! - Natural E-Mail System
(http://www.ritlabs.com/the_bat/)

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



Re: [PHP] call a function within the same class

2005-01-07 Thread kalinga
great!, thanks for the detailed answer.

vk.

p.s.
I hope following URL will be helpfull to php oop beginners..
http://www.zend.com/zend/tut/class-intro.php


On Thu, 6 Jan 2005 08:57:48 -0800 (PST), Richard Lynch [EMAIL PROTECTED] 
wrote:
 kalinga wrote:
  Dear all,
  I recently started PHP OOP and I'm bit confused about best and the most
  efficient methods when 'declaring a class' and 'calling function',
  could somebody
  explain me with following sample code, it would be great..
 
  thanks..
 
  class classLdap{
 
  $rslt = $_POST['rslt'];
 
function ldapConnect($rslt){

..
return $rslt;
  }// end function ldapConnect
 
function ldapAdd($rslt){
// i want to call ldapConnect($rslt) here what is the best
  method.
 
  $rslt = classLdap::ldapConnect($rslt);
 
 This is generally done when you:
 A) Don't have an instance of a classLdap to work with.
 B) Calling ldapConnect() on the instance you have would cause side effects
 to the instance (or other objects) that you don't want to happen in some
 unusual case.
 
 A. does not apply here, as you are in the method of the class, so you have
 '$this' which is the instance you have created.
 
 B. might or might not apply, but it all depends on YOUR application and
 what you want it to do...
 
  //or
//(curently i'm doing this way, it's to lengthy)
 
   $new_classLdap = new classLdap;
 $rslt = $new_classLdap-ldapConnect($rslt);
 
 This can also be used to avoid altering the existing object you have
 created -- though it's a bit more expensive than the previous way of doing
 that.
 
 There might be some super RARE case where you really really need an object
 instantiated to have it be valid, and you would *HAVE* to do the above.
 
 But that would be super rare, so this is probably not what you want.
 
  //or
 
 $rslt = $this-ldapConnect($rslt);
 
 
 works if you just want to affect *THIS* same object that you have -- In
 other words, use $this- when you are thinking about 'this' object that
 you have created and want it to change itself in some way.  Kind of like a
 self-help sort of deal.
 
 You might not want to assign the result back into $rslt -- depending on
 what $rslt actually *IS* which I don't know, since you have it coming in
 from $_POST...
 
 Which you also need to do some checking on, since it's NOT SAFE to accept
 $_POST data -- *any* Bad Guy out there could send any nasty thing they
 want to your script through $_POST.
 
  }// end function ldapAdd
 
  }// end class
 
 Based on what you are doing, and your experience level, I'd say stick with
 the last answer:
 
 $this-ldapConnect($rslt)
 
 unless you have a very specific need to use the others.
 
 Just keep it in the back of your mind that there *ARE* alternatives, so
 that, years from now, when you run into one of those weird-o cases where
 you need the others, you'll remember that they exist as alternatives.
 
 --
 Like Music?
 http://l-i-e.com/artists.htm
 
 


-- 
vk.

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



[PHP] String replace inside img

2005-01-07 Thread Fredrik Arild Takle
I have a some problems doing a search and replace in a string.
I want to replace:
img ALT= src=base/image.php?id=3 border=0
with
img ALT= src=image.php?id=3 border=0

Note ALT, src, border properties may come in random order.

My solution today is a not good enough because I only do an eregi_replace on 
all image.php, I only want to replace those inside a img

Todays solution
 $string = eregi_replace(base\/image.php, image.php, $string);

Solution?

Best Regards
-Fredrik A. Takle 

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



[PHP] Fetch data from dbf file?

2005-01-07 Thread Supri anto
hi all,
did anyone know how to fetch data from dbf file (Clipper) ? 

best regards,
suprie
-- 
Jangan tanyakan apa yang Indonesia telah berikan pada mu
tapi bertanyalah apa yang telah engkau berikan kepada Indonesia

-BEGIN GEEK CODE BLOCK-
Version: 3.1
GU/IT  d- s: a-- C++ UL P L++ E W++ N* o-- K- 
w PS  Y-- PGP- t++ 5 X R++ tv  b+ DI D+ G e+ h* r- z?
 --END GEEK CODE BLOCK--

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



Re: [PHP] PHP Unit Tests - which framework to use?

2005-01-07 Thread Dirk Kredler
Am Freitag, 7. Januar 2005 09:49 schrieb dAniel hAhler:
 I'm looking for a PHP Unit Test framework and found so far:
  SimpleTest: https://sourceforge.net/projects/simpletest/
  PEAR PHPUnit:
   - http://pear.php.net/package/PHPUnit
   - http://pear.php.net/package/PHPUnit2
  Sourceforge PHPUnit: http://phpunit.sourceforge.net/

 While SF PHPUnit seems to have stalled (2002-10) there are still PEAR
 PHPUnit and Simpletest.
...
 I'm still on PHP4 mainly - but tests could be done/run with PHP5 of
 course (if PHPUnit2 supports that).

Hey :)

for my PHP4 Projects i happily use PHPUnit from Sebastian Bergmann,
i like it very much and it seems to me, it is the best Unit-Test-Framework for 
PHP4.

All PHP5 Projects take the advanced features from PHPUnit2 (which is indeed 
only for PHP5) in credit - again the Framework is from Sebastian and i must 
commit: He does his job on it very,very well :)

So in one sentence: I use PHPUnit for PHP4 and PHPUnit2 for PHP5 and i am 
really happy with it.

Have fun,
Dirk

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



RE: [PHP] On large application organization [long and possibly bo ring]

2005-01-07 Thread Ford, Mike
To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm



On 07 January 2005 00:37, Josh Whiting wrote:

 Correction: include() statements are executed at *run time*,
 which means
 that if the case is not executed, the include will not be executed and
 the file is not even read!  The include() method is not only more
 efficient but also easier to maintain as you suggest.

The efficiency point is at least debatable -- opening and reading the file
is actually quite an expensive operation, the cost of which may outweigh the
savings in not parsing unused code.  However, if the speed question is not
an issue for your site, the maintainability is certainly a big plus.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



RE: [PHP] Re: On large application organization [long and possibl y boring]

2005-01-07 Thread Ford, Mike
To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm



On 06 January 2005 23:40, Jason Barnett wrote:

 I thought there was a difference for include and require for
 conditionals.  But apparently not.  :)

There used to be, somewhere way back in the days of PHP 4.0.x (where x5) --
but nowadays the only difference is whether an error is thrown or not if the
file doesn't exist.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



RE: [PHP] On large application organization [long and possibly bo ring]

2005-01-07 Thread Ford, Mike
To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm



On 07 January 2005 00:20, Jason Barnett wrote:

 That was what I thought also.  However just to add to the
 confusion: I
 think require'd files were evaluated no matter what back in
 PHP4.  Even
 if they were part of a conditional.  At least that's my
 recollection of
 it; I haven't used PHP4 since 4.3.2 ;)

Back in about 4.0.2 or .3, that was the case; the current behaviour has been
in place since at least 4.0.5.

 Bottom line: I always require_once at the top of a file for any files
 that I will require.  No sense in doing anything else if the required
 files aren't there.  For conditionally including files include_once()
 has always made the most sense to me.

I'm not sure that's the best strategy: since include() will continue
executing your script even if the file does not exist, you shouldn't use
include() if anything which follows will fail in the absence of the
(non-)included code.  If the content of the other file is essential to the
correct operation of your script, you should use require(), since that will
terminate with a fatal error if the required file is not present.

It makes sense to require() files in a conditional branch if *only* the code
in that branch is dependent on the required file.  If all (or at least
enough) branches rely on the file, then requiring it at the top of the file
is a sensible move.

Whether you use the basic include()/require() or the _once versions depends
on whether you want the code in the file to be executed each time the
require/include is executed or not.  For initialization of constants or
parameter variables, the _once versions make sense; for code which contains
substantive logic or output, it may not, especially if inside a loop.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



Re: [PHP] String replace inside img

2005-01-07 Thread Jason Wong
On Friday 07 January 2005 07:32, Fredrik Arild Takle wrote:
 I have a some problems doing a search and replace in a string.
 I want to replace:
 img ALT= src=base/image.php?id=3 border=0
 with
 img ALT= src=image.php?id=3 border=0

 Note ALT, src, border properties may come in random order.

 My solution today is a not good enough because I only do an eregi_replace
 on all image.php, I only want to replace those inside a img

 Todays solution
  $string = eregi_replace(base\/image.php, image.php, $string);

 Solution?

The quick and dirty solution would be to

  str_replace('src=base/image.php', 'src=image.php', ...)

based on the assumption that 'src=base/image.php' only appears inside an 
img tag.

Otherwise:

$doo = 'img ALT= src=base/image.php?id=3 border=0';
$dah = preg_replace('|(img .*src=)(.*)(\?id=\d+ .*)|ie', 
'$1.basename($2).$3', $doo);
echo $dah, NL;

Season to taste.

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
New Year Resolution: Ignore top posted posts

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



Re: [PHP] Persistent PHP web application?

2005-01-07 Thread William Lovaton
Hi everybody in this thread,

The phpbeans (or sockets) kind of solutions won't work as Josh Whiting
(original author of this thread) would expect.

phpbeans is a good idea to share (complex) business logic and data
between many web servers but it will have to serialize and unserialize
the data to send it across the network and it will kill the purpose of
this discussion.

See the post from Rasmus who says that APC package is able to store data
in a shared memory segment without serialization.  It still does a
mem_cpy() though.  This would be a real solution for the problem, but
there are some others.
http://pecl.php.net/package/APC

Rasmus, you said this feature is currently in CVS... any idea about a
new release?  What kind of features offers the currently stable version
(2.0.4) in this regard?

Do you know where can I look for performance comparison between APC and
other opcode cache systems like Turck, Zend Accel or eA??

Thanx to all,


-William


El jue, 06-01-2005 a las 13:32 -0700, Adrian Madrid escribió:
 I've done some benchmaring and it is quite fast, specially compared to 
 talking to the DB. Also, phpbeans provides a daemon that can give you 
 the solution you are looking for, I believe.
 
 Adrian
 
 
 Rasmus Lerdorf wrote:
 
  Adrian Madrid wrote:
 
  I think I understand where you're coming from. I've had a similar 
  problem and the best solution I've found is eAccelerator (previously 
  known as Turck MMCache). What EA does is keep the bytecodes PHP 
  compiles inshared memory so next time you need that script PHP 
  doesn't need to recompile, EA returns the bytecode from SHM. Now, 
  since PHP scripts are compiled and saved in SHM all I need to do is 
  /save/ the data that does not change often but requires a lot of 
  queries as code (an array inside a script) and include it whenever I 
  need the data. No recompiling, no need to touch the DB again, pure 
  speed. I hope all this helps you. I personally don't need extra 
  processes and stuff like that but if you really want all that you can 
  take a look at phpbeans.
 
 
  What you are talking about is opcode caching.  While it certainly 
  speeds things up, it can be done much faster.  When you cache a file 
  that contains a large PHP array definition, all you are caching are 
  the instructions to create that array.  On every request these 
  instructions need to be loaded from shared memory and executed in 
  order to recreate the array.  This can be quite slow.  What we are 
  discussing here are ways to avoid recreating the array on every 
  request which is quite different.
 
  -Rasmus
 
 
 
 -- 
 Adrian Madrid
 HyperX Inc. 
 Mobile: 801.815.1870
 Office: 801.566.0670 
 [EMAIL PROTECTED] 
 www.hyperxmedia.com 
 
 9000 S. 45 W.
 Sandy, UT 84070
 

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



RE: [PHP] On large application organization [long and possibly boring]

2005-01-07 Thread Jay Blanchard
[snip]
 
 Otherwise, I'm curious as to why you're using a large switch, not that

 it's bad inherently IMHO, but there may be a better overall approach. 
 
 /jw

I don't know why *he* wants to do it, but one useful example is the MVC 
model (google MVC phppatterns if you're unfamiliar with the term). 
For a given action he can include the class definitions he will need to 
perform that action.

Jay, are you using PHP5?  Because if you are then I thought of something

else.  You can put each class into its own file and define your own 
__autoload() function to include a file just in time.  The main 
downside to this is if you use someone else's code and they have also 
defined their own __autoload() function then you get an error!  :(
[/snip]

We have not moved to 5 yet, but sounds closer to what I am looking for.
We will probably upgrade to 5 after we get two of our highest priority
projects are launched. 

All of our projects are intranet applications for office use, so
sometimes efficiency questions are really moot as we use multi-processor
servers to deliver most of the goods. Occasionaly we will expose a web
interface to the public, but not typically.

Remember, I am old school. My first programming venture was in the 70's
with FORTRAN, so all of you young bucks view programming differently
than I do. I have a tendency to view things more from a C or C++ POV in
terms of construction at this stage. That is why the above mentioned MVC
model is comfortable to me. 

We have kind of been doing top-down methodology for a few years with
PHP, but projects are becoming more complex as the corporate culture is
coming around to my way of understanding data and the manipulation of
the data (normalization was not in their vocabulary prior to my arrival
several years ago, imagine starting a large data driven company without
a programmer/database admin  *shudder*). Therefore the MVC is
somewhat more fitting, but it can have a downside where code
maintainability comes into play. 

Josh, I am interested in what you mean by but there may be a better
overall approach. 

I appreciate all of ya'll's insight on this and for setting me straight
on the includes/requires band wagon. I made some incorrect assumptions
(and didn't run the simple tests I could have run myself, as a couple of
you have pointed out) and I will now have to eat some crow in front of
my more youthful programmers. My saving grace? They didn't prove me
wrong with these very simple tests either! (I know you're reading
thisI can hear you chuckling you SRB's...first one to say something
buys lunch)

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



Re: [PHP] On large application organization [long and possibly bo

2005-01-07 Thread Jason Barnett
the file is not even read!  The include() method is not only more
efficient but also easier to maintain as you suggest.

The efficiency point is at least debatable -- opening and reading the file
is actually quite an expensive operation, the cost of which may outweigh the
A good point not to be taken lightly.  However, if you cache script 
opcodes (e.g. eAccelerator) then the efficiency of only including code 
that is absolutely needed will increase.

--
Teach a person to fish...
Ask smart questions: http://www.catb.org/~esr/faqs/smart-questions.html
PHP Manual: http://php.net/manual/
php-general archives: http://marc.theaimsgroup.com/?l=php-generalw=2
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] GD Module

2005-01-07 Thread Jeff McKeon
I've been searching the net all moring for this.  Can anyone give me a
link were I can find information on how to compile PHP with GD module
support?

Thanks,

Jeff

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



RE: [PHP] GD Module

2005-01-07 Thread Jay Blanchard
[snip]
I've been searching the net all moring for this.  Can anyone give me a
link were I can find information on how to compile PHP with GD module
support?
[/snip]

http://us2.php.net/GD

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



[PHP] Re: E-mails with mail() as UTF-8

2005-01-07 Thread Kimmo Alm
On Fri, 7 Jan 2005 18:50:50 +1100, HarryG [EMAIL PROTECTED] wrote:
Possibly the relay server can not send messages in the UTF-8 format so it
has to convert the message.
Try to install a local mail server on your pc smtp server in IIS on  
Windows
or Postfix in linux and then try use your local server to delivery the  
mail
rather than the isp's mail server

Well... I'm developing on a Wintel (PHP 5 and Apache 2). I obviously use a  
simple SMTP client (QK STMP Server), but us customers in my ISP are  
required to use the ISP's special e-mail server for outgoing e-mails. They  
block outgoing traffic on port 25 for their clients...

It'd be nice if there was a way to save the e-mail to a file on the HDD  
rather than trying to deliver it... then I could see if it really differs.

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


Re: [PHP] On large application organization [long and possibly boring]

2005-01-07 Thread John Nichel
Jay Blanchard wrote:
snip
Remember, I am old school. My first programming venture was in the 70's
with FORTRAN, so all of you young bucks view programming differently
than I do.
/snip
Old fart.  I didn't venture into programming until 1980 with BASIC on an 
Atari. ;)

Somebody wake-up grandpa Jay...he fell asleep in his oatmeal again.  *L*
--
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] On large application organization [long and possibly boring]

2005-01-07 Thread Jason Barnett
Remember, I am old school. My first programming venture was in the 70's
with FORTRAN, so all of you young bucks view programming differently
than I do. I have a tendency to view things more from a C or C++ POV in
I am indeed a young buck... but now I find myself moving (backwards?) 
because I have a BASIC/PHP point of view... and now I want to learn more 
about C.  Mostly I want enough knowledge of C so that I can at least go 
out and start building my own PHP extensions.  I have George 
Schlossnagle's book which is *excellent* at describing the process for 
building a module... but it assumes a level of proficiency with C that I 
just don't have yet.  :(

terms of construction at this stage. That is why the above mentioned MVC
model is comfortable to me. 

We have kind of been doing top-down methodology for a few years with
PHP, but projects are becoming more complex as the corporate culture is
coming around to my way of understanding data and the manipulation of
the data (normalization was not in their vocabulary prior to my arrival
several years ago, imagine starting a large data driven company without
a programmer/database admin  *shudder*). Therefore the MVC is
somewhat more fitting, but it can have a downside where code
maintainability comes into play. 

Josh, I am interested in what you mean by but there may be a better
overall approach. 

I appreciate all of ya'll's insight on this and for setting me straight
on the includes/requires band wagon. I made some incorrect assumptions
(and didn't run the simple tests I could have run myself, as a couple of
you have pointed out) and I will now have to eat some crow in front of
Yeah, well, at least we didn't give you any of the RTFM crap haha
my more youthful programmers. My saving grace? They didn't prove me
wrong with these very simple tests either! (I know you're reading
thisI can hear you chuckling you SRB's...first one to say something
buys lunch)
Byte me.  ;)
--
Teach a person to fish...
Ask smart questions: http://www.catb.org/~esr/faqs/smart-questions.html
PHP Manual: http://php.net/manual/
php-general archives: http://marc.theaimsgroup.com/?l=php-generalw=2
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] GD Module

2005-01-07 Thread John Nichel
Jeff McKeon wrote:
I've been searching the net all moring for this.  Can anyone give me a
link were I can find information on how to compile PHP with GD module
support?
http://us4.php.net/gd
--
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] On large application organization [long and possibly boring]

2005-01-07 Thread Jesse Castro
[snip]
You're wrong. The include() and require() statements are only evaluated
when they are reached in your application code, so there is a big
difference between your two examples. In you use the second example the
code will only be included by PHP if the application logic enters the
case statement that contains the include() statement. Here's a quick
example to demonstrate this:


// 1.php
///
?php
$include = 0;

if($include)
  include('2.php');

hello();

?


// 2.php
///
?
function hello() {
  print Hello;
}
?

Save those two snippets into files named 1.php and 2.php. Pull up 1.php
in your browser and you'll see that the hello() function is undefined.
[/snip]

This doesn't prove the case either way.  It would be similar to writing
this code:
?php
$include = 0;

if($include){
  function hello() {
  print Hello;
  } 
}
hello();

?

Which also throws an error.  We looked a while and found nothing
in the documentation, so we ended up putting an error in the include
file.  
foo.php

?

$include = b;

switch ($include){
 case a:
   include(foo2.php);
 break;
 case b:
   echo bar;
 break;
}

?

foo2.php
?
//note syntax error
echo foo
?

Assumably, if includes were processed before the script was 
executed, it would show a syntax error in foo2.php.  We ran
the test and no error was returned, so that pretty much answers
the question (READ: includes are not processed until they
are called).  
Just out of curiosity, a lot of people had answers to this
question, but I couldn't find a shred of evidence in the 
documentation.  Did you do similar tests, hear from gurus, or
something of like?  Or did I just miss it somewhere?

Regards,
Jesse R. Castro

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



Re: [PHP] GD Module

2005-01-07 Thread Richard Lynch
Jeff McKeon wrote:
 I've been searching the net all moring for this.  Can anyone give me a
 link were I can find information on how to compile PHP with GD module
 support?

The only not-so-obvious thing is you need to download and install the
libraries for JPEG, TIFF, etc so GD can use them -- Or not, if you don't
want support for those.

You can do those from source also, or use RPMs -- but you need to install
an RPM for jpeg-devel, tiff-devel, xyz-devel etc any time you want to be
able to compile source that uses the corresponding library.

It seems de reguire to include this now:
http://php.net/gd
though I'm not sure compile instructions are actually there...

Google for PHP GD Install Tutorial though, and I'll bet you find something.

-- 
Like Music?
http://l-i-e.com/artists.htm

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



RE: [PHP] On large application organization [long and possibly boring]

2005-01-07 Thread Richard Lynch
 Just out of curiosity, a lot of people had answers to this question, but
 I couldn't find a shred of evidence in the
 documentation.  Did you do similar tests, hear from gurus, or something
 of like?  Or did I just miss it somewhere?

Once upon a time, a long time ago, require and include were different.

In fact, they were different in exactly the way being discussed, only more
so.

'require' would be loaded *ONCE* when the script got there, and the values
within the file required would be whatever they were upon that first load.

'include' would be re-loaded each time it was reached.

This cause all manner of confusion, and somewhere around version 3 or 4,
was abandoned.

The only difference now is that require signals an ERROR and include only
a WARNING.

In either case, if your require/include is inside a conditional, it will
NOT be seen by PHP until that line of code is executed.

This is the way 'include' worked, and the way most people who were
confused in earlier versions though 'require' should have worked.  Now
it does.

-- 
Like Music?
http://l-i-e.com/artists.htm

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



[PHP] Multiple POP accounts on Webmail Front

2005-01-07 Thread James Nunnerley
Hi All,

 

Bit of a side question, but it's still php related.

 

Does anyone know of a Webmail client, preferably open-source, that is able
to support single login, to allow users to collect and use multiple POP3 or
IMAP accounts?

 

I'm currently using Ilohamail, and have used Squirrel in the past, but
neither, I don't, think support multiple POP3 accounts on one login.

 

Any ideas?

 

Cheers

James



Re: [PHP] Php error with MySql

2005-01-07 Thread Wil Hitchman
Apologies...just have had loose fingers
- Original Message - 
From: Jay Blanchard [EMAIL PROTECTED]
To: Wil [EMAIL PROTECTED]; php-general@lists.php.net
Sent: Thursday, January 06, 2005 3:31 PM
Subject: RE: [PHP] Php error with MySql

[snip]
...stuff...
Wil
[/snip]
I replied to this over an hour ago, please do not repost.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] On large application organization [long and possibly boring]

2005-01-07 Thread Jason Barnett
Consider yourself bytten, RTFM indeed! (BTW, this behavior is not really
mentioned anywhere that I can find in TFM, it is more or less an
assumption to be made from an example which would not prove the include)
OK this is the last time I push the button on this one, but since you 
asked ;)

http://php.net/manual/en/function.require.php
Note:  Prior to PHP 4.0.2, the following applies: require()  will 
always attempt to read the target file, even if the line it's on never 
executes. The conditional statement won't affect require(). However, if 
the line on which the require() occurs is not executed, neither will any 
of the code in the target file be executed. Similarly, looping 
structures do not affect the behaviour of require(). Although the code 
contained in the target file is still subject to the loop, the require() 
itself happens only once.

OK so I had my version wrong... ah well *sigh*
--
Teach a person to fish...
Ask smart questions: http://www.catb.org/~esr/faqs/smart-questions.html
PHP Manual: http://php.net/manual/
php-general archives: http://marc.theaimsgroup.com/?l=php-generalw=2
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] On large application organization [long and possibly bo

2005-01-07 Thread Jason Barnett
Bottom line: I always require_once at the top of a file for any files
that I will require.  No sense in doing anything else if the required
files aren't there.  For conditionally including files include_once()
has always made the most sense to me.

I'm not sure that's the best strategy: since include() will continue
executing your script even if the file does not exist, you shouldn't use
include() if anything which follows will fail in the absence of the
(non-)included code.  If the content of the other file is essential to the
correct operation of your script, you should use require(), since that will
terminate with a fatal error if the required file is not present.
Isn't this what I said?  :P  Oh well, no biggie.
It makes sense to require() files in a conditional branch if *only* the code
in that branch is dependent on the required file.  If all (or at least
enough) branches rely on the file, then requiring it at the top of the file
is a sensible move.
Ah, now I'm getting more what you mean.  To be clear: I generally try to 
split up my files into the lowest common denominator and keep 
functionality seperated.  The way that I delegate files I generally put 
one class / module into one file; this just makes it easier for me to 
manage code.  So if I *need* a certain class / module for another class 
/ module to work, then I just require_once at the top of the file.

Whether you use the basic include()/require() or the _once versions depends
on whether you want the code in the file to be executed each time the
require/include is executed or not.  For initialization of constants or
parameter variables, the _once versions make sense; for code which contains
substantive logic or output, it may not, especially if inside a loop.
Excellent point.  Most of what I delegate to includes falls into the 
categories of constant / variable initialization / class definition / 
function definition.  In fact I do it that way to prevent my logic 
errors from include'ing the wrong way just as you have described.

--
Teach a person to fish...
Ask smart questions: http://www.catb.org/~esr/faqs/smart-questions.html
PHP Manual: http://php.net/manual/
php-general archives: http://marc.theaimsgroup.com/?l=php-generalw=2
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: PHP Unit Tests - which framework to use?

2005-01-07 Thread Matthew Weier O'Phinney
* dAniel hAhler [EMAIL PROTECTED]:
 I'm looking for a PHP Unit Test framework and found so far:
  SimpleTest: https://sourceforge.net/projects/simpletest/
  PEAR PHPUnit:
   - http://pear.php.net/package/PHPUnit
   - http://pear.php.net/package/PHPUnit2
  Sourceforge PHPUnit: http://phpunit.sourceforge.net/

 While SF PHPUnit seems to have stalled (2002-10) there are still PEAR
 PHPUnit and Simpletest.

 I'd like to hear your opinions/experiences on what's better to use.

 I'm mainly searching it for an OSS project, but would like to use it at
 work, too.

 I'm still on PHP4 mainly - but tests could be done/run with PHP5 of
 course (if PHPUnit2 supports that).

I've used both PEAR::PHPUnit and SimpleTest. I like SimpleTest better...
mainly because it's documented so well. I was up and running with
SimpleTest in a matter of an hour, whereas I'd struggled for the better
part of a day trying to figure out from the docs how to use PHPUnit --
and only managed a portion of what I accomplished with SimpleTest in
that hour.  

'Course, the PHPUnit docs may have been improved since I last tried it
-- YMMV.

-- 
Matthew Weier O'Phinney   | mailto:[EMAIL PROTECTED]
Webmaster and IT Specialist   | http://www.garden.org
National Gardening Association| http://www.kidsgardening.com
802-863-5251 x156 | http://nationalgardenmonth.org

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



Re: [PHP] On large application organization [long and possibly boring]

2005-01-07 Thread Jamie Alessio
 This doesn't prove the case either way.

Nice catch on that one but actually there might be another problem with 
my example. According to example 16-8 on http://us2.php.net/include/  
Because include() and require()  are special language constructs, you 
must enclose them within a statement block if it's inside a conditional 
block. So, I think I would need to rewrite

if($include)
 include('2.php');
to be 

if($include) {
 include('2.php');
}
in order for it to work as desired. I'm not exactly sure what it means 
to work as desired though. Maybe it only applies if you have 
additional else/elseif statements in the block?

BUT, also from documentation on http://us2.php.net/include/ it looks 
like your example might not hold any water either. Be warned that parse 
error in required file doesn't cause processing halting. Based on that 
it appears that introducing the parse error in foo2.php doesn't prove 
that the file wasn't included. So, how do we actually prove this one way 
or the other? I guess we could just like at the underlying C code. Any 
takers?

- Jamie
[snip]
You're wrong. The include() and require() statements are only evaluated
when they are reached in your application code, so there is a big
difference between your two examples. In you use the second example the
code will only be included by PHP if the application logic enters the
case statement that contains the include() statement. Here's a quick
example to demonstrate this:

// 1.php
///
?php
$include = 0;
if($include)
 include('2.php');

hello();
?

// 2.php
///
?
function hello() {
 print Hello;
}
?
Save those two snippets into files named 1.php and 2.php. Pull up 1.php
in your browser and you'll see that the hello() function is undefined.
[/snip]
This doesn't prove the case either way.  It would be similar to writing
this code:
?php
$include = 0;
if($include){
 function hello() {
  print Hello;
 }  
}
hello();
?
Which also throws an error.  We looked a while and found nothing
in the documentation, so we ended up putting an error in the include
file.  
foo.php

?
$include = b;
switch ($include){
case a:
  include(foo2.php);
break;
case b:
  echo bar;
break;
}
?
foo2.php
?
//note syntax error
echo foo
?
Assumably, if includes were processed before the script was 
executed, it would show a syntax error in foo2.php.  We ran
the test and no error was returned, so that pretty much answers
the question (READ: includes are not processed until they
are called).  
Just out of curiosity, a lot of people had answers to this
question, but I couldn't find a shred of evidence in the 
documentation.  Did you do similar tests, hear from gurus, or
something of like?  Or did I just miss it somewhere?

Regards,
Jesse R. Castro
 

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


RE: [PHP] On large application organization [long and possibly boring]

2005-01-07 Thread Jesse Castro
[snip]
You're wrong. The include() and require() statements are only evaluated
when they are reached in your application code, so there is a big
difference between your two examples. In you use the second example the
code will only be included by PHP if the application logic enters the
case statement that contains the include() statement. Here's a quick
example to demonstrate this:


// 1.php
///
?php
$include = 0;

if($include)
  include('2.php');

hello();

?


// 2.php
///
?
function hello() {
  print Hello;
}
?

Save those two snippets into files named 1.php and 2.php. Pull up 1.php
in your browser and you'll see that the hello() function is undefined.
[/snip]

This doesn't prove the case either way.  It would be similar to writing
this code: ?php $include = 0;

if($include){
  function hello() {
  print Hello;
  } 
}
hello();

?

Which also throws an error.  We looked a while and found nothing in the
documentation, so we ended up putting an error in the include file.  
foo.php

?

$include = b;

switch ($include){
 case a:
   include(foo2.php);
 break;
 case b:
   echo bar;
 break;
}

?

foo2.php
?
//note syntax error
echo foo
?

Assumably, if includes were processed before the script was 
executed, it would show a syntax error in foo2.php.  We ran
the test (v 4.2.1) and no error was returned, so that pretty 
much answers the question (READ: includes are not processed 
until they are called).  
Just out of curiosity, a lot of people had answers to this question, but
I couldn't find a shred of evidence in the 
documentation.  Did you do similar tests, hear from gurus, or something
of like?  Or did I just miss it somewhere?

Regards,
Jesse R. Castro

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



Re: [PHP] Persistent PHP web application?

2005-01-07 Thread Rasmus Lerdorf
On Fri, 7 Jan 2005, William Lovaton wrote:
 The phpbeans (or sockets) kind of solutions won't work as Josh Whiting
 (original author of this thread) would expect.
 
 phpbeans is a good idea to share (complex) business logic and data
 between many web servers but it will have to serialize and unserialize
 the data to send it across the network and it will kill the purpose of
 this discussion.
 
 See the post from Rasmus who says that APC package is able to store data
 in a shared memory segment without serialization.  It still does a
 mem_cpy() though.  This would be a real solution for the problem, but
 there are some others.
 http://pecl.php.net/package/APC
 
 Rasmus, you said this feature is currently in CVS... any idea about a
 new release?  What kind of features offers the currently stable version
 (2.0.4) in this regard?

2.0.4 does not support this.  I have a patch I am testing to fix some 
other issues and once I get that working I will probably push out a new 
release.

 Do you know where can I look for performance comparison between APC and
 other opcode cache systems like Turck, Zend Accel or eA??

These days they are all in the same ballpark.  The optimizer in APC is not 
very strong so it loses a percent or two there, but on the other hand many 
people turn off the optimizer in other caches because it sometimes screws 
up their scripts.

-Rasmus

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



RE: [PHP] On large application organization [long and possibly boring]

2005-01-07 Thread Jay Blanchard
[snip]
 I appreciate all of ya'll's insight on this and for setting me
straight
 on the includes/requires band wagon. I made some incorrect assumptions
 (and didn't run the simple tests I could have run myself, as a couple
of
 you have pointed out) and I will now have to eat some crow in front of

Yeah, well, at least we didn't give you any of the RTFM crap haha

 my more youthful programmers. My saving grace? They didn't prove me
 wrong with these very simple tests either! (I know you're reading
 thisI can hear you chuckling you SRB's...first one to say
something
 buys lunch)

Byte me.  ;)
[/snip]


Consider yourself bytten, RTFM indeed! (BTW, this behavior is not really
mentioned anywhere that I can find in TFM, it is more or less an
assumption to be made from an example which would not prove the include)

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



Re: [PHP] Image copying

2005-01-07 Thread Liam Gibbs
Richard, thanks. This made it much clearer. I read this, then stepped away
and thought about it later and it makes so much more sense. Basically, I
guess I ended up with the result IMG SRC = Resource id #x in my HTML.
Man, I thought I was telling it to print the results of the resource ID, but
it was printing it on its own. Now the problem is solved! Thanks so much.

And Jason's little bit helped as well. That was my jumping off point.

Thanks so much, guys! Now onto the next brow-beating

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



Re: [PHP] On large application organization [long and possibly boring]

2005-01-07 Thread Jason Barnett
Assumably, if includes were processed before the script was 
executed, it would show a syntax error in foo2.php.  We ran
Good point about the syntax error.
the test (v 4.2.1) and no error was returned, so that pretty 
much answers the question (READ: includes are not processed 
until they are called).  
Just out of curiosity, a lot of people had answers to this question, but
I couldn't find a shred of evidence in the 
documentation.  Did you do similar tests, hear from gurus, or something
of like?  Or did I just miss it somewhere?

Testing.  In my case I was testing for user-defined classes rather than 
parser errors (because PHP would have to parse an include'd or require'd 
file in order to have the definition), but your example is probably 
better than my own.  Nice.

--
Teach a person to fish...
Ask smart questions: http://www.catb.org/~esr/faqs/smart-questions.html
PHP Manual: http://php.net/manual/
php-general archives: http://marc.theaimsgroup.com/?l=php-generalw=2
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] On large application organization [long and possibly boring]

2005-01-07 Thread Jay Blanchard
[snip]
BUT, also from documentation on http://us2.php.net/include/ it looks 
like your example might not hold any water either. Be warned that parse

error in required file doesn't cause processing halting. Based on that 
it appears that introducing the parse error in foo2.php doesn't prove 
that the file wasn't included. So, how do we actually prove this one way

or the other? I guess we could just like at the underlying C code. Any 
takers?
[/snip]

Actually, it does prove it. If there is a syntax error in the included
file and the include file is loaded into the calling file you will get a
syntax error. Since no syntax error is reported it pretty much shows
that the file was not included when the case wasn't called.

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



Re: [PHP] Compiling PHP with external mySQL libraries

2005-01-07 Thread Richard Lynch
DAvid wrote:
 1) Does adding 'shared,' as a ./configure option mean the module is
 compiled
 as an external, dynamically loaded module as compared to the module being
 statically linked into the 'exe' file? So that adding 'shared,' means I
 must
 add a line in the PHP ini file to load the extension (or load with a
 funcion
 call).

Yes.

'shared' == .dll or .so dynamic library to load in
'static' == library is bundled into php binary

 2) When configuring PHP with mysql support by something like
 '--with-mysql=/usr' does it automatically create a shared module? i.e do
 both these following configs produce the same result '--with-mysql=/usr'
 and
 '--with-mysql=shared,/usr'?

No.
'shared' creates the DLL/.so and you need to load it.
absence of 'shared' means it's bundled in.

 The reason I ask, is I see many PHP info pages that specify
 '--with-mysql=[DIR]' without the 'shared,' bit, and they do specify an
 external library with the [DIR] part, but in the mysql info section
 'MYSQL_MODULE_TYPE' shows as 'external'. I thought 'shared,' would have to
 be added to create an external dynamic loaded module?

'external' versus 'built-in' is another wrinkle.

Here's how I understand it:

'shared' versus 'static' is the usual for libraries.

There's a MySQL guy on the PHP team, who also provides a 'built-in' versus
'external' MySQL.

He basically maintains a copy of the MySQL library *directly* in PHP
source code.

So it breaks down like:
Built-in -- source code *in* PHP source
External -- usual deal of source code from MySQL
 static -- bundle MySQL library into php binary
 shared -- create DLL/.so library to be loaded in

I don't think the static/shared option has any meaning under 'Built-in' --
'Built-in' is kind of like static inherently, only even more so.

I'm not sure of the benefits of 'built-in'...
Performance gain???
Convenience of not needing to get ./configure to find MySQL source???
Bragging rights for PHP and MySQL??? :-)

The downside is that you'be *GOT* to run the exact same version of MySQL
that is built-in to PHP source -- If that's on 4.x.y and you're running
4.x.(y+1) don't go there.  If you manage to get it to run, you'll run this
risk that eventually you'll run across that *one* function that changed
betwween y and (y+1) and Bam! you've got a nasty bug.

The pros and cons of 'static' versus 'shared' are pretty well-documented
elsewhere and are common enough to enough modules and other software
packages with the same structure.

But 'built-in' versus 'external' I'm not sure if that's been documented
why/when...  Maybe Google for it.

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] On large application organization [long and possibly boring]

2005-01-07 Thread Richard Lynch
Jay Blanchard wrote:
 switch($action){
   /* several dozen cases to follow */
   case foo:
   writing out all of the code
   break;
 }

 and this

 switch($action){
   /* several dozen cases to follow */
   case foo:
   include that will handle processing this case
   break;
 }

Performance-wise, there is probably a minor 'loss' to the second one.

But the maintenance benefits of the secodn one FAR OUTWEIGHT the
performance question.

The only conceivable exception to that is if you *HAD* to put all of that
long code inside some loop that runs a zillion times...  You've got bigger
problems to solve if you're doing that anyway.

 Correct me if I am wrong, but includes (and/or requires) will get all of
 the code in all of the cases regardless if the case is being processed.

That got covered in depth already.

 etc

One thing I will say:

When I first started with PHP, I did this, because I was coming from a
desktop application background.

But it ends up being not all that maintainable, and you end up having to
open up and track too many files with too many interactions when you go
down this route.

I abandoned this style and have never regretted it.

YMMV

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] migrating to PHP 5 + Apache 2 from PHP 4.3.8 + Apache 1.3.33.

2005-01-07 Thread symbulos partners
Jason Barnett wrote:
 exercise for myself, but then again I don't need to either.  ;)  This
 would also be something that would be a great benefit to share with the
 PHP community if you decide to compile this list of thread-safe
 extensions.

If we could share a bit of the effort with someone else, we would be
available (February). Eventually we could host the page on our website, f
necessary.

We could have a simple php base page where people could flag libraries /
sets of functions after checking. A simple table, in order to understand. 

We could manage it by e-mail eventually.
-- 
symbulos partners
-.-
symbulos - ethical services for your organisation
http://www.symbulos.com

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



Re: [PHP] Multiple POP accounts on Webmail Front

2005-01-07 Thread Greg Donald
On Fri, 7 Jan 2005 16:26:02 -, James Nunnerley
[EMAIL PROTECTED] wrote:
 Does anyone know of a Webmail client, preferably open-source, that is able
 to support single login, to allow users to collect and use multiple POP3 or
 IMAP accounts?

http://www.horde.org/imp/4.0/

snip
Fetching mails from other email accounts to view with IMP
/snip


-- 
Greg Donald
Zend Certified Engineer
http://destiney.com/

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



Re: [PHP] PHP 5 confusion

2005-01-07 Thread Richard Lynch
 Reading the PHP 5 documentation at: HYPERLINK
 http://www.php.net/manual/en/language.oop5.basic.phphttp://www.php.net/man
 ual/en/language.oop5.basic.php, I am confused.

 In the example given, what is the difference between:
 $assigned  =  $instance;
 $reference  = $instance;

 I would expect all of the var_dump to display NULL

 The doc says When assigning an already created instance of an object to a
 new variable, the new variable will access the same instance as the object
 that was assigned. so the above assignments seem the same to me and
 setting
 $instance to NULL should also set $assigned to NULL.

I think they intendeed for you to assume $instance had something in it:

$instance = new foo();
$assigned  =  $instance;
$reference  = $instance;

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] On large application organization [long and possibly boring]

2005-01-07 Thread Richard Lynch
Jamie Alessio wrote:
 BUT, also from documentation on http://us2.php.net/include/ it looks
 like your example might not hold any water either. Be warned that parse
 error in required file doesn't cause processing halting. Based on that
 it appears that introducing the parse error in foo2.php doesn't prove
 that the file wasn't included. So, how do we actually prove this one way
 or the other? I guess we could just like at the underlying C code. Any
 takers?

I think the warning you quote is, in fact, trying to say this:

Be warned that a parse error in an included/required fill will not halt
processing until that file is included/required.

In other words, just because your script loads once with no parse errors,
doesn't mean it always will if external conditions change which files get
included/required within that script.

My thesis is that the quote implies the answer to the original question.

After doing this for most of a decade, I'm gonna tell you:

The include/require files do *NOT* get loaded until PHP encounters the
line that includes/requires them!

Here's a dog-simple test.

Take a *BIG* text file.  I mean *BIG*.  Like, War  Peace big.  No, no,
like, Dictionary Of English *BIG*.  The biggest text file you can find.

Now do something like this:

#!/usr/local/bin/php -q
?php
  if (isset($argv[1])){
require 'monster_text_file.txt';
  }
  echo Hi\n;
?

Now run that script like:
./foo.php 1  /dev/null
./foo.php   /dev/null

If you really think PHP can *read* the file that fast, I want to know your
hard drive makemodel. :-)

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] Multiple POP accounts on Webmail Front

2005-01-07 Thread Richard Lynch
James Nunnerley wrote:
 Bit of a side question, but it's still php related.

 Does anyone know of a Webmail client, preferably open-source, that is able
 to support single login, to allow users to collect and use multiple POP3
 or
 IMAP accounts?

 I'm currently using Ilohamail, and have used Squirrel in the past, but
 neither, I don't, think support multiple POP3 accounts on one login.

Either squirrel mail supports simple Fetching of multiple POP3 accounts,
or my web-host did a lot of hacking or he found some kind of plug-in for
squirrel mail...

I use squirrel mail, and it *definitely* lets me set up username/password
to Fetch multiple accounts.

IIRC, It does not do IMAP, it does not handle secure connections, it does
not ...

But if all you want is insecure POP3, it works quite nicely.

Won't let me take on different personalities when responding, however. :-(

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] Multiple POP accounts on Webmail Front

2005-01-07 Thread Steve Buehler
Well, Squirrelmail does.sort of.  This might not be exactly what you 
are looking for, but you can add the fetchmail plugin to squirrelmail so 
that it can pull email from other pop3 accounts.
http://www.squirrelmail.org/plugin_view.php?id=50

Steve
At 10:26 AM 1/7/2005, James Nunnerley wrote:
Hi All,

Bit of a side question, but it's still php related.

Does anyone know of a Webmail client, preferably open-source, that is able
to support single login, to allow users to collect and use multiple POP3 or
IMAP accounts?

I'm currently using Ilohamail, and have used Squirrel in the past, but
neither, I don't, think support multiple POP3 accounts on one login.

Any ideas?

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


RE: [PHP] On large application organization [long and possibly boring]

2005-01-07 Thread Jay Blanchard
[snip]
Richard Lynch speaks:
But it ends up being not all that maintainable, and you end up having to
open up and track too many files with too many interactions when you go
down this route.

I abandoned this style and have never regretted it.

YMMV
[/snip]

In favor of what?

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



Re: [PHP] Multiple POP accounts on Webmail Front

2005-01-07 Thread Jamie Alessio

IIRC, It does not do IMAP, it does not handle secure connections, it does
not ...
 

Squirrelmail does support IMAP. I'm using it to access a courier IMAP 
server with no problems.

From http://www.squirrelmail.org/about.php
It includes built-in pure PHP support for the IMAP and SMTP protocols
I found the Horde system to be a huge pain to set up and install. Maybe 
that has changed since I tried it a few years ago but I was quickly up 
and running with squirrelmail in just a few minutes so that's my 
recommendation if it does in fact support multiple pop accounts. 
Alternatively, you could always use something like fetchmail 
(http://catb.org/~esr/fetchmail/) to pull the multiple pop accounts down 
into a single account and then check that one account via webmail. Might 
give you faster access instead of having your webmail app doing pop 
accesses to a bunch of different accounts?

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


RE: [PHP] On large application organization [long and possibly boring]

2005-01-07 Thread Richard Lynch
Jay Blanchard wrote:
 [snip]
 Richard Lynch speaks:
 But it ends up being not all that maintainable, and you end up having to
 open up and track too many files with too many interactions when you go
 down this route.

 I abandoned this style and have never regretted it.

 YMMV
 [/snip]

 In favor of what?

Depends on the site -- on its size/scale mostly.

Small/Medium sites:
The URL matches a file, and that file includes any common code, and
handles the specific actions of that URL.  Tracking errors and code logic
is simplified immensely.

For a larger site, I don't believe in a cookie-cutter approach, so don't
have a single answer for you.  All I know is, I haven't had a
monster-switch to deal with an action since then, and when I have to go
maintain code that *DOES* have a monster-switch, I know why.  It's a PITA
to figure out what's pulling what in where, and I end up with too many
windows open with code scatter across too many files.

I guess the only rules I can give are:
1. Given a bug report about URL X, and only X, I should know exactly which
file to open to find the most likely source of the bug -- the distinctive
parts that make X be different from all the other pages.

2. Given a bug report that seems to involve multiple URLs, I should know
just from the error report, where the problem is most likely to be.

Throwing everything in a monster-switch right away doubles the number of
potential files, at minimum, but even higher than that for weird syntax
errors or simple mistakes in the switch login, which never ends up being
as simple as a switch().  You end up having almost ALL the files being
included being suspect when things get weird.  Get rid of that switch, and
have a more reasonable rational systematic way to know what's included,
and more importantly, what code is *NOT* *POSSIBLY* included, and your
possible source of Bug #8766533 shrinks dramatically.

Got my fire-proof undies on now.

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] migrating to PHP 5 + Apache 2 from PHP 4.3.8 + Apache 1.3.33.

2005-01-07 Thread Richard Lynch
symbulos partners wrote:
 Jason Barnett wrote:
 exercise for myself, but then again I don't need to either.  ;)  This
 would also be something that would be a great benefit to share with the
 PHP community if you decide to compile this list of thread-safe
 extensions.

 If we could share a bit of the effort with someone else, we would be
 available (February). Eventually we could host the page on our website, f
 necessary.

 We could have a simple php base page where people could flag libraries /
 sets of functions after checking. A simple table, in order to understand.

 We could manage it by e-mail eventually.

After checking?

There is *NO* exhaustive test to do, from everything I've ever heard...

Now if you want to come up with a test harness that claims to stress-test
some given code-base, with version numbers of all the under-lying code,
and hardware, come to think of it, and try to track the amount of testing
that has been done, and assign probability curves to the thread-safeness
of any given combination...

It ain't gonna be no simple table, though, really.

You might get somebody to say Core PHP is Thread-safe

They might even believe that.

They *might* even be right.

For their version of PHP.

On their OS.

Under that *version* of their OS.

With their hardware.

It don't mean a whole lot to anybody who doesn't have that *exact* same
setup.

You'd almost have to work out a list of all known variables, and then a
weighting system for (number-of-hours-run X
number-of-concurrent-processes) multiplied by the server load to give each
report a score

If I tell you it's been fine on my low-traffic servers, it don't mean
squat.  If Rasmus tells you PHP X + MySQL Y + OS Z == Good on Yahoo,
that has some meaning, but not a whole lot if you change *any* of the
variables in the equation.

So then, you'd have a very large (and quite sparse, probably) matrix of
the probability that any given combination of every software package (and
hardware?) is thread-safe.

Not saying it's not a Good Idea, nor that you shouldn't be doing this:  I
just want you to understand that you've severely under-estimated the scale
and scope of the problem to be addressed, and have a concomitant
simplisitic design going here.

Make it complex enough to be useful, and make it easy to search and report
on various combinations, it could be a real boon.

But if your site just says PHP 4.1.3 + MySQL 3.23.4 == Good...  I'm not
going to put much faith in that for thread-safety.

But maybe I'm just a negative guy :-)

-- 
Like Music?
http://l-i-e.com/artists.htm

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



[PHP] On large application organization [long and possibly boring]

2005-01-07 Thread Joe Harman
This is Definatley a good conversation... I've realy thought of doing
it this way... but i do agree with the person who said that 'having to
keep track of a ton of different files could get complicated ... i
can't imagine the performance difference would be that big... but then
again, i suppose it is relative to how big your applicatin is going to
be

Cheers!
Joe


-- Forwarded message --
From: Jay Blanchard [EMAIL PROTECTED]
Date: Thu, 6 Jan 2005 14:30:23 -0600
Subject: [PHP] On large application organization [long and possibly boring]
To: PHP Mailing Lists php-general@lists.php.net


Good afternoon gurus and gurettes,

If I have a large app what is the difference, other than having a very
large file, of doing this

switch($action){
   /* several dozen cases to follow */
   case foo:
   writing out all of the code
   break;
}

and this

switch($action){
   /* several dozen cases to follow */
   case foo:
   include that will handle processing this case
   break;
}

Correct me if I am wrong, but includes (and/or requires) will get all of
the code in all of the cases regardless if the case is being processed.
That being the case the code would essentially be the same length. Given
that, would there be an efficieny issue?

This would (the second way) also make the project easier to work on by
multiple programmers at the same time, similar to modular work being
done by programmers on C++ projects.

One of the reasons for doing this is so that global includes and certain
class definitions, such as an error checking function relavent to most
cases, can be included once.

--
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] Need a Calender class that can access a DB

2005-01-07 Thread Phillip S. Baker
Greetings All,

I have the need to find a calender class/script. What I am trying to do is
have a view by month calender that lists all classes for the month. People
can see the names of the classes in the month display and then click on the
link and get the detailed information about the class through this view.

We have a custom look for the class descriptions and such so I do not need
the whole standard calendar stuff that is often out there. Just the main
calendar feature that will allow me to pull records from a MySQL DB and let
me create links to the appropiate pages that I am coding.

The database with the classes is already in place. So I am just looking for
a view events by month class or script that I can use and plug into the DB I
already without having to build this thig from scratch.

Is there anyone that already has something that I can use or can you point
me to something on sourceforge or phpbuilder or some other site I am not
aware of.

I would appreciate any points in the right direction.
Thanks in advance.
--
Blessed Be

Phillip

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



[PHP] Pagination Optimization

2005-01-07 Thread Bruno B B Magalhães
Hi guys,
currently I have a function in my framework´s mysql driver , that fetch 
paginated results... Here it´s:

===
/*
*  Fetch paginated results
*/
function fetch_paginated($query='',$page=1,$itens=20)
{
$this-query($query.' LIMIT 
'.(($page*$itens)-$itens).','.$itens);

if($this-num_rows()  0)
{
while($this-fetch_array())
{
$results[] = $this-row;
}
}
else
{
return null;
}

$this-query($query.' LIMIT 0,'.(($page*$itens)-$itens));
$this-pages_before = ceil($this-num_rows()/$itens);

$this-query($query.' LIMIT 
'.($page*$itens).',100');
$this-pages_after = ceil($this-num_rows()/$itens);

$this-query($query);
$this-total_pages = ceil($this-num_rows()/$itens);

return $results;
}
===
My question is: Is there ANY way to speed up this function, or any way 
to fetch paginated results quicker? I had a project list, without 
pagination, and when I added the pagination function, it slowed down up 
to 0.0125 secs. Before it was running at 0.0600 more or less, and now 
it´s running at 0.07 to 0.075...

Best Regards,
Bruno B B Magalhães
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: Pagination Optimization

2005-01-07 Thread M. Sokolewicz
first of all, you're running 4 queries here. 4 queries is a lot! 
Especially when you don't need more than 2 ;)
the problem here is that your queries are pretty unknown to this 
function. Although it does a nice result for that unknowing, there's a 
few minor things that make it faster.

First of all, would be using less queries.
What I usually do is issue a query like this:
SELECT count(some_unique_col) WHERE 
(that_where_clause_youre_using_in_the_select_query)
then, we do some math.

$pages_before = $page-1;
$rows_before = $pages_before*$itens;
$rows_after = $total_number_of_rows-($page*$itens);
$pages_after = ceil($rows_after/20);
Then do the actual selecting of the rows using the limit.
The thing that makes it slow in your example is the fact that 4 times 
you're selecting ALL data from the relevant rows, and buffer it. You 
buffer it, but don't use any of it, except for the number of rows. Mysql 
does a far quicker job at this than PHP would, so use mysql. :)
Then, you're using 3 queries to determine the rows around the page; even 
though, with a bit of simple math, you can calculate it. And trust me on 
this, simple math is faster ;)

anyway, hope that helped.
Bruno B B Magalhães wrote:
 Hi guys,

 currently I have a function in my framework´s mysql driver , that fetch
 paginated results... Here it´s:

 ===
 /*
 *  Fetch paginated results
 */
 function fetch_paginated($query='',$page=1,$itens=20)
 {
 $this-query($query.' LIMIT 
'.(($page*$itens)-$itens).','.$itens);

 if($this-num_rows()  0)
 {
 while($this-fetch_array())
 {
 $results[] = $this-row;
 }
 }
 else
 {
 return null;
 }

 $this-query($query.' LIMIT 0,'.(($page*$itens)-$itens));
 $this-pages_before = ceil($this-num_rows()/$itens);

 $this-query($query.' LIMIT
 '.($page*$itens).',100');
 $this-pages_after = ceil($this-num_rows()/$itens);

 $this-query($query);
 $this-total_pages = ceil($this-num_rows()/$itens);

 return $results;
 }
 ===

 My question is: Is there ANY way to speed up this function, or any way
 to fetch paginated results quicker? I had a project list, without
 pagination, and when I added the pagination function, it slowed down up
 to 0.0125 secs. Before it was running at 0.0600 more or less, and now
 it´s running at 0.07 to 0.075...

 Best Regards,
 Bruno B B Magalhães

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


[PHP] Re: E-mails with mail() as UTF-8

2005-01-07 Thread Manuel Lemos
Hello,
on 01/07/2005 01:33 AM Kimmo Alm said the following:
Hey again!
I'm having major trouble using mail() to deliver UTF-8 e-mails.
They get sent and delivered successfully, but seem to be... messed up 
when  they arrive (they go through my ISP's relay e-mail server).

My headers basically look like this: From: Test  
[EMAIL PROTECTED]\nMIME-Version: 1.0\nContent-Type: text/plain;  
charset=UTF-8\n.

I want to be able to use UTF-8 chars both in the subject and the body.
When I check the letters in my e-mail client (Opera's built-in one -- 
M2),  it shows UTF-16. Also, the headers look different than from the 
ones I  send.

Is the relay server altering my letters? What the hell is happening?
When you use UTF-8 encoding it may end up including 8 bit characters. In 
this case you need to use quoted-printbale encoding to compose the 
message body and some MTA may filter the unencoded 8 bit bytes . For the 
headers it is the same except the encoding is q-encoding.

If you do not know how to encode messages with quoted-printable and 
q-encoding, you may want to try this popular MIME message composing and 
sending class. Just specify that the default encoding charset is utf-8 
and it will be sent without corruption:

http://www.phpclasses.org/mimemessage
--
Regards,
Manuel Lemos
PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/
PHP Reviews - Reviews of PHP books and other products
http://www.phpclasses.org/reviews/
Metastorage - Data object relational mapping layer generator
http://www.meta-language.net/metastorage.html
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] preg match

2005-01-07 Thread Chandana Bandara
This php script perform matching text of some certain URLs. but in this 
preg_match it wont match few patterns   _ .
with help of this script , can some body help me to match the other all 
patterns .plz ?



?php

$user=root;
$pass=;
$db=aa;
$dblink = mysql_connect(localhost:3306, $user, $pass)or 
die(Could not connect to db);
mysql_select_db($db) or die (can't select the db);

$result = mysql_query (select indexNo,Reply from Acknowledgement order 
by indexNo) or die (Invalid query);
while ( $rset= mysql_fetch_array($result)) {
/* Lets check the reply with the database*/
$chk_msg= $rset[Reply];
//echo checking $chk_msg in $msgbr;
if ( preg_match(/$chk_msg/, $msg, $match) ) {
// match found
$SQL=update Status set Status = 'UP' where 
ServiceNo=.$rset[ServiceNo];
mysql_query ($SQL) or die (Invalid 2nd query);
}else{
// SERIVCE DOWN
// nothing to do here.
//echo No match..br;
}

}
mysql_close($dblink);

?

thanx in advance, 
chandana

Re: [PHP] preg match

2005-01-07 Thread Rory Browne
I'm not sure what you're trying to do with preg_match, since the
parameters you send to it, are from the database, and an  undeclared
variable $msg(which is what exactly). Unless you give us examples of
the arguments to preg_match, and what you expect the results should
be, as well as what they are, we can't really be of much help.

Having that said:
You are using /$chk_msg/ as the first  parameter. since you are
simply putting /'s around $chk_msg, this leads me to suggest that you
don't need regex at all, and perhaps would be better using some of the
string functions. strpos() ( http://www.php.net/strpos ) springs to
mind.

Just a few tips:
As an aside, I notice that you are connecting to localhost:3306. Just
incase you didn't know, when you connect to localhost through
mysql_connect, assuming you are on a unix host, it uses a unix socket,
regardless if  you specify a port. If you want to override this
behavour, and use TCP sockets, you can connect to 127.0.0.1.


On Sat, 8 Jan 2005 00:37:34 +0600, Chandana Bandara
[EMAIL PROTECTED] wrote:
 This php script perform matching text of some certain URLs. but in this 
 preg_match it wont match few patterns   _ .
 with help of this script , can some body help me to match the other all 
 patterns .plz ?
 
 ?php
 
 $user=root;
 $pass=;
 $db=aa;
 $dblink = mysql_connect(localhost:3306, $user, $pass)or 
 die(Could not connect to db);
 mysql_select_db($db) or die (can't select the db);
 
 $result = mysql_query (select indexNo,Reply from Acknowledgement 
 order by indexNo) or die (Invalid query);
 while ( $rset= mysql_fetch_array($result)) {
 /* Lets check the reply with the database*/
 $chk_msg= $rset[Reply];
 //echo checking $chk_msg in $msgbr;
 if ( preg_match(/$chk_msg/, $msg, $match) ) {
 // match found
 $SQL=update Status set Status = 'UP' where 
 ServiceNo=.$rset[ServiceNo];
 mysql_query ($SQL) or die (Invalid 2nd query);
 }else{
 // SERIVCE DOWN
 // nothing to do here.
 //echo No match..br;
 }
 
 }
 mysql_close($dblink);
 
 ?
 
 thanx in advance,
 chandana


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