Re: [PHP] Embedding foreach loops

2009-08-11 Thread hessiess
Do *NOT* get into the habit of outputting your HTML using echo or print
statements, it becomes unmaintainable very quickly, use a templating
language, ether with a framework(recomended) or standalone.

You should learn the basics of HTML and CSS, go and read
http://htmldog.com/, btw to add a newline you need to use br /.

 I am using the print function to display my html. I cannot get the
 line return ( \n ) character to actually push the html onto the next
 line, it just gets displayed instead. Should I be using echo?


 Allen, you off and running again?

 echo blah..  \n; //-- this will print  the literal 'blah..  '  and
 then a newline into your HTML *source code*
 echo 'blah..  \n'; //-- this will print the literal 'blah..  \n' into
 your HTML *source code*

 IIRC print is the same as echo.  That is not your apparent issue.

 Say if you are stuck again, and on what exactly.

 -John

 --
 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] Radio buttons problem

2009-08-11 Thread leledumbo

 Unless, of course, what you have is
 
name[], email[], sex[0]
name[], email[], sex[1]
name[], email[], sex[2] 

Yep, that's exactly what I have.

 If it's important to you that the indexes match across name[], email[] and
 sex[], then you must supply
 them explicitly for every field in the group

I guess there's no other way than this, so OK I'll do it. Thanks.
-- 
View this message in context: 
http://www.nabble.com/Radio-buttons-problem-tp24786766p24912487.html
Sent from the PHP - General mailing list archive at Nabble.com.


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



Re: [PHP] reason for a Notice:.. on one site but not another? (Same code.)

2009-08-11 Thread Ashley Sheridan
On Mon, 2009-08-10 at 15:40 -0300, Martin Scotta wrote:
 This intelligence is given by the laziness of the  operator.
 
 $res = a()  b(); # if a() is false then b() does not evaluate
 $res = a()  b(); # b() evaluates no matter a()'s result
 
 so, order matters.
 
 On Mon, Aug 10, 2009 at 3:29 PM, Andrew Ballard aball...@gmail.com wrote:
 
  On Mon, Aug 10, 2009 at 1:50 PM, Ralph Deffkeralph_def...@yahoo.de
  wrote:
   this is not intelligence its just pure math. the '' says if BOTH
   expressions are true then the whole expression is true.
  
   so if the first one is false, the whole is false, why checking the next
  one
   in the underlaying C it would be something like this
   {
   if ( expression == false ) return false;
   if ( expression == false) return false;
   return true;
   }
  
   ralph
   ralph_def...@yahoo.de
 
  That's logically correct, and while PHP does implement this
  short-circuit logic, not all languages do. In that regard, I
  appreciate what John meant by saying it makes it look more
  intelligent. Some languages evaluate each of the conditions to their
  respective boolean results before evaluating the logical operators.
 
  Andrew
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 
 
You get the same thing in bash. You call a bunch of commands to run in
series, but the next one only runs if it's predecessor was successful.
It's frequent to see this sort of command chain:

./configure  make  make install

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


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



Re: [PHP] Embedding foreach loops

2009-08-11 Thread Ashley Sheridan
On Tue, 2009-08-11 at 07:13 +, hessi...@hessiess.com wrote:
 Do *NOT* get into the habit of outputting your HTML using echo or print
 statements, it becomes unmaintainable very quickly, use a templating
 language, ether with a framework(recomended) or standalone.
 
 You should learn the basics of HTML and CSS, go and read
 http://htmldog.com/, btw to add a newline you need to use br /.
 
  I am using the print function to display my html. I cannot get the
  line return ( \n ) character to actually push the html onto the next
  line, it just gets displayed instead. Should I be using echo?
 
 
  Allen, you off and running again?
 
  echo blah..  \n; //-- this will print  the literal 'blah..  '  and
  then a newline into your HTML *source code*
  echo 'blah..  \n'; //-- this will print the literal 'blah..  \n' into
  your HTML *source code*
 
  IIRC print is the same as echo.  That is not your apparent issue.
 
  Say if you are stuck again, and on what exactly.
 
  -John
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 
 

*Or* you could use the heredoc syntax, which I'm quite a fan of.

print EOC
psome content here/p
pcontent with a php $variable here/p


pthis gets displayed after the extra new lines in the source/p
EOC;

Still easy to maintain.

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


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



[PHP] Synchronizing autonumber fields

2009-08-11 Thread Leidago !Noabeb
Hi

I have the following tables setup in MYSQL:

Region 1 Region 2
HQ
Tbl1 with autonumbered (PK) Tbl1 with autonumbered (PK)
Tbl1 autonumbered-PK

To explain the above. Basically there are two regions that collect
information and then at the end of each month they have to send the
information to HQ. This is fine, but the problem comes when the
information (the data in the tables) is submitted to HQ. All three
tables have the same names and the same structure. We want to
synchronize the information sent by the regions into one table at HQ.
How can we do this without having the duplicate number problem?

Thanks

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



Re: [PHP] Synchronizing autonumber fields

2009-08-11 Thread Per Jessen
Leidago !Noabeb wrote:

 Hi
 
 I have the following tables setup in MYSQL:
 
 Region 1 Region 2
 HQ
 Tbl1 with autonumbered (PK) Tbl1 with autonumbered (PK)
 Tbl1 autonumbered-PK
 
 To explain the above. Basically there are two regions that collect
 information and then at the end of each month they have to send the
 information to HQ. This is fine, but the problem comes when the
 information (the data in the tables) is submitted to HQ. All three
 tables have the same names and the same structure. We want to
 synchronize the information sent by the regions into one table at HQ.
 How can we do this without having the duplicate number problem?

Typically you would do this by having a sufficiently large offset
between the numbers.  


/Per

-- 
Per Jessen, Zürich (19.6°C)


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



Re: [PHP] Sending email w/ attachments

2009-08-11 Thread Devendra Jadhav
Check out this link http://www.learnphp-tutorial.com/Email.cfm

On Tue, Aug 11, 2009 at 8:52 AM, Skip Evans s...@bigskypenguin.com wrote:

 Bastien Koert wrote:


 Use PHPMailer or one of the other classes available...makes life
 so much easier


 eric cartman
Kick Ass!!!
 /eric cartman

 Yes! Wow! Was that a breeze! That class rocks!

 Thanks tons, Bastien!

 I have to admit when I first saw your reply I thought, Oh, man, another
 class to learn? But I know this is so close to working.

 I look at the sample and thought, This looks easy, and had it working in
 no time.

 Big thanks again!

 Attachments were a big deal here and this makes it a breeze, AND it looks
 like multiple attachments would be no problem?

 Very cool!


 Skip

 --
 
 Skip Evans
 Big Sky Penguin, LLC
 503 S Baldwin St, #1
 Madison WI 53703
 608.250.2720
 http://bigskypenguin.com
 
 Those of you who believe in
 telekinesis, raise my hand.
  -- Kurt Vonnegut

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




-- 
Devendra Jadhav


[PHP] Re: Synchronizing autonumber fields

2009-08-11 Thread Ralph Deffke
hi there,

this is typical app for db repliction mechanism. it depnds of the size off
your project.

have a look here:
http://dev.mysql.com/doc/refman/5.1/en/replication-howto.html

if this is oversized for u do a dump of each table without the
auto_increment fields. if u read in these tables the main database then does
use its own record id.
to identifie these records use a subsidairy finegerprint field.

another way would be not to use a ai field for identifying the record, use a
timestamp field to have an unique index on the tables. it is very unlikeley
that two records are written at the same time in the various subsidaries. a
timestamp field is a breakdown to the milisecond. however there is still a
chance of 1 to some billion, that two records have the same key.

just some possibilities

cheers
ralph
ralph_def...@yahoo.de


Leidago !Noabeb leid...@googlemail.com wrote in message
news:5bcf496e0908110004w94d29c2j4b01806822ca0...@mail.gmail.com...
 Hi

 I have the following tables setup in MYSQL:

 Region 1 Region 2
 HQ
 Tbl1 with autonumbered (PK) Tbl1 with autonumbered (PK)
 Tbl1 autonumbered-PK

 To explain the above. Basically there are two regions that collect
 information and then at the end of each month they have to send the
 information to HQ. This is fine, but the problem comes when the
 information (the data in the tables) is submitted to HQ. All three
 tables have the same names and the same structure. We want to
 synchronize the information sent by the regions into one table at HQ.
 How can we do this without having the duplicate number problem?

 Thanks



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



[PHP] Re: Synchronizing autonumber fields

2009-08-11 Thread Ollisso
On Tue, 11 Aug 2009 10:04:52 +0300, Leidago !Noabeb  
leid...@googlemail.com wrote:



Hi

I have the following tables setup in MYSQL:

Region 1 Region 2
HQ
Tbl1 with autonumbered (PK) Tbl1 with autonumbered (PK)
Tbl1 autonumbered-PK

To explain the above. Basically there are two regions that collect
information and then at the end of each month they have to send the
information to HQ. This is fine, but the problem comes when the
information (the data in the tables) is submitted to HQ. All three
tables have the same names and the same structure. We want to
synchronize the information sent by the regions into one table at HQ.
How can we do this without having the duplicate number problem?

Thanks


You can change system, so it will increment not by one, but by 2:

then Region 1 with have numbers:
1, 3 ,5 , 7 , etc
Region 2: 2, 4 ,6, 8 etc

then they are going to be easily mixed together.
As a bonus - it will be easy to see from where this record came.

Only problem - you can do it only on server level, not table level
http://forums.mysql.com/read.php?10,269379,269436#msg-269436


--

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



RE: [PHP] how to say inverse your value (to a boolean)?

2009-08-11 Thread Ford, Mike
 -Original Message-
 From: Daevid Vincent [mailto:dae...@daevid.com]
 Sent: 11 August 2009 02:19
 
 Then YOU have more aggressive error_reporting than the default
 setting
 turned on. You might consider turning it down a notch. NOTICEs are
 basically
 useless and bloat your code IMHO -- and apparently the PHP devs too
 as per
 this...
 
 http://us2.php.net/manual/en/function.error-reporting.php
 
 // Report all errors except E_NOTICE
 // This is the default value set in php.ini
 error_reporting(E_ALL ^ E_NOTICE);

Yes, but recent versions also have the following recommended settings:

; error_reporting
;   Development Value: E_ALL | E_STRICT
;   Production Value: E_ALL  ~E_DEPRECATED

; display_errors
;   Development Value: On
;   Production Value: Off


Cheers!

Mike
 -- 
Mike Ford,
Electronic Information Developer, Libraries and Learning Innovation,  
Leeds Metropolitan University, C507, Civic Quarter Campus, 
Woodhouse Lane, LEEDS,  LS1 3HE,  United Kingdom 
Email: m.f...@leedsmet.ac.uk 
Tel: +44 113 812 4730






To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

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



RE: [PHP] Re: how to say inverse your value (to a boolean)?

2009-08-11 Thread Ford, Mike
 -Original Message-
 From: Ralph Deffke [mailto:ralph_def...@yahoo.de]
 Sent: 11 August 2009 01:45
 
 u...
 try
 echo pre;
 for( $i=0 ; $i10; $i++){
   echo something  . (($a = $a^1) ? red\n : green\n);
 }

The ^ operator is one that has an assigning version, so the above can be 
slightly shortened to:

   echo something  . (($a ^= 1) ? red\n : green\n);

Cheers!

Mike
 -- 
Mike Ford,
Electronic Information Developer, Libraries and Learning Innovation,  
Leeds Metropolitan University, C507, Civic Quarter Campus, 
Woodhouse Lane, LEEDS,  LS1 3HE,  United Kingdom 
Email: m.f...@leedsmet.ac.uk 
Tel: +44 113 812 4730





To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

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



Re: [PHP] Sending email w/ attachments

2009-08-11 Thread Richard Heyes
Hi,

 Very cool!

I'll take that as a compliment... :-)

-- 
Richard Heyes
HTML5 graphing: RGraph - www.rgraph.net (updated 8th August)

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



Re: [PHP] how to say inverse your value (to a boolean)?

2009-08-11 Thread David Otton
2009/8/11 Daevid Vincent dae...@daevid.com:

 NO! For the love of God and all that is holy, don't do that accumulator /
 mod hack.
 That's so 1980's. And why make the CPU do all that math for every row...

 Just do this. It's quick and simple:

 CSS:
        .dataRow1 { background-color: #DFDFDF; }
        .dataRow2 { background-color: #FF; }

 foreach ($foo_array as $foo) {
   ?tr class=?= ($dr = !$dr) ? dataRow1 : dataRow2 ?td?= $foo
 ?/td/tr?php
 }

A change request just came in - the interaction designer wants every
third line to have a grey background, instead of every second line.

 No need to initialize $dr as by default PHP will make it a boolean false,
 then each itteration, it will toggle true/false and substitute the CSS class

Um. No. Just no.

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



Re: [PHP] how to say inverse your value (to a boolean)?

2009-08-11 Thread Ashley Sheridan
On Tue, 2009-08-11 at 11:28 +0100, David Otton wrote:
 2009/8/11 Daevid Vincent dae...@daevid.com:
 
  NO! For the love of God and all that is holy, don't do that accumulator /
  mod hack.
  That's so 1980's. And why make the CPU do all that math for every row...
 
  Just do this. It's quick and simple:
 
  CSS:
 .dataRow1 { background-color: #DFDFDF; }
 .dataRow2 { background-color: #FF; }
 
  foreach ($foo_array as $foo) {
?tr class=?= ($dr = !$dr) ? dataRow1 : dataRow2 ?td?= $foo
  ?/td/tr?php
  }
 
 A change request just came in - the interaction designer wants every
 third line to have a grey background, instead of every second line.
 
  No need to initialize $dr as by default PHP will make it a boolean false,
  then each itteration, it will toggle true/false and substitute the CSS class
 
 Um. No. Just no.
 
I tend to do something like this:

$count = 0;
foreach($foo_array as $foo)
{
$class = ($count % 3 == 0)?'class=thirdRow':'';
print tr $classtd$foo/td/tr;
}

You only need to give one row the class, as you style up all the rows
and only change the row that needs to change.

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


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



Re: [PHP] how to say inverse your value (to a boolean)?

2009-08-11 Thread Ralph Deffke
seems they changing idears on the fly? could it be that the designer is a
smal ugly person while u a a good looking ladykiller ?

on that background I would design a function where u can change ti what ever
u want on the fly something like this

var $a;
function alternate(  $a, $_b=array( red, red ,green ,... ) {
if( count( $_b )  $a ) {
return $_b[ $a++ ] ;
}
$a=0;
return $_b[ $a++ ] ;
}

so now u can do what ever anybody wants on just putting the right values
into the array

cheers

ralph
ralph_def...@yahoo.de

David Otton phpm...@jawbone.freeserve.co.uk wrote in message
news:193d27170908110328p43b4722fkc46b0bcda97fc...@mail.gmail.com...
2009/8/11 Daevid Vincent dae...@daevid.com:

 NO! For the love of God and all that is holy, don't do that accumulator /
 mod hack.
 That's so 1980's. And why make the CPU do all that math for every
row...

 Just do this. It's quick and simple:

 CSS:
 .dataRow1 { background-color: #DFDFDF; }
 .dataRow2 { background-color: #FF; }

 foreach ($foo_array as $foo) {
 ?tr class=?= ($dr = !$dr) ? dataRow1 : dataRow2 ?td?= $foo
 ?/td/tr?php
 }

A change request just came in - the interaction designer wants every
third line to have a grey background, instead of every second line.

 No need to initialize $dr as by default PHP will make it a boolean
false,
 then each itteration, it will toggle true/false and substitute the CSS
class

Um. No. Just no.



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



Re: [PHP] APC optimization in CLI

2009-08-11 Thread Robert Cummings

Daevid Vincent wrote:
From: Robert Cummings [mailto:rob...@interjinn.com] 

However, accelerators don't make scripts faster per se. 
They merely cut out the script reading and parsing time. 


Which is a HUGE portion of time since PHP is a two-pass step. One that reads
and compiles to opcodes (with syntax checking) and another which actually
executes it.


No, it's a small portion for most CLI scripts.

So, while 
you may experience 10% gain within the first second of your script 
running, the use of an accelerator should have no bearing 
down the road 
except for the initial dynamic load of other scripts at runtime.


This is sort of misleading.


No. It is not.


You will experience faster page loads if it's a web php file, and if APC
does allow you to run cached scripts via CLI, then these scripts will start
execution immediately too.


I've already mentioned it's efficacy in a web environment. I am 
explaining the cases where you won't get much value... namely CLI scripts.


Long running scripts will see almost no benefit from an accelerator. 


PHP scripts are (like it or not) NOT designed to be daemons and run for long


Maybe you mean PHP was not meant to be used for daemons because I SURE 
AS HELL designed some of my scripts to be daemons and run for a long 
time... some run for months uninterrupted (usually need to reboot for OS 
updates once in a while). As for the former comment... that's a matter 
of opinion.



periods of time. The GC is no optimized for such things. It's quite
inneficient from what I've read. The whole purpose of a PHP _page_ is to get
in and get out. Hit it and quit it. Therefore memory efficiency is not as
important as speed and ease of use.


The GC works fine if you avoid circular references.


This is the general reason why CLI acceleration isn't very useful. That
said 
though, one could certainly glean an advantage if they had a 
cron job or other daemon that was loading a script often.


As is probably often the case, moreso than a long running script.


I would argue otherwise when the CLI is being used.


I think a code optimizer is what would be desired if you're trying to make a
faster script. However in this day and age, I suspect that the 2nd phase of
the compiler already does all the optimizing it can before creating the byte
code. 


You would be wrong... very few accelerators have bundled optimizers. 
Some may do a small amount of optimization, but not a lot.


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

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



Re: [PHP] Sending email w/ attachments

2009-08-11 Thread Phpster





On Aug 10, 2009, at 11:22 PM, Skip Evans s...@bigskypenguin.com wrote:


Bastien Koert wrote:

Use PHPMailer or one of the other classes available...makes life
so much easier


eric cartman
   Kick Ass!!!
/eric cartman

Yes! Wow! Was that a breeze! That class rocks!

Thanks tons, Bastien!

I have to admit when I first saw your reply I thought, Oh, man,  
another class to learn? But I know this is so close to working.


I look at the sample and thought, This looks easy, and had it  
working in no time.


Big thanks again!

Attachments were a big deal here and this makes it a breeze, AND it  
looks like multiple attachments would be no problem?


Very cool!

Skip

--

Skip Evans
Big Sky Penguin, LLC
503 S Baldwin St, #1
Madison WI 53703
608.250.2720
http://bigskypenguin.com

Those of you who believe in
telekinesis, raise my hand.
-- Kurt Vonnegut



Yep, I created a wrapper for the class and pass in attachments as an  
array. Then just loop thru the array with the attachment code. It's  
very easy.


Bastien

Sent from my iPod

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



Re: [PHP] Synchronizing autonumber fields

2009-08-11 Thread Phpster





On Aug 11, 2009, at 3:04 AM, Leidago !Noabeb  
leid...@googlemail.com wrote:



Hi

I have the following tables setup in MYSQL:

Region 1 Region 2
   HQ
Tbl1 with autonumbered (PK) Tbl1 with autonumbered (PK)
   Tbl1 autonumbered-PK

To explain the above. Basically there are two regions that collect
information and then at the end of each month they have to send the
information to HQ. This is fine, but the problem comes when the
information (the data in the tables) is submitted to HQ. All three
tables have the same names and the same structure. We want to
synchronize the information sent by the regions into one table at HQ.
How can we do this without having the duplicate number problem?

Thanks

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



The simplest thing would be to have the main table have it's own auto  
increment key and use the two sub tables keys as a numerical field,  
perhaps as a foreign key.


As a general rule, ai keys should only be used for uniqueness, and not  
have any real meaning within the datasets.


Bastien

Sent from my iPod

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



Re: [PHP] Sending email w/ attachments

2009-08-11 Thread Richard Heyes
Hi,

 ...

Sorry, quoted wrong email. Oopsy...

-- 
Richard Heyes
HTML5 graphing: RGraph - www.rgraph.net (updated 8th August)

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



[PHP] Re: MySQL auto_increment fields Server version: 5.1.32-community-log

2009-08-11 Thread Nisse Engström
On Mon, 10 Aug 2009 01:17:21 +0200, Ralph Deffke wrote:

 On Sun, 9 Aug 2009 20:17:15 +0200, Ralph Deffke wrote:

 I'm facing the fact that it seems that auto_increment fields in a table not
 start at 1 like it was in earlier versions even if I install mySQL brand new
 creating all tables new. it seems to me that auto_increments handling has
 
 I should mention that I use MyISAM as storage engine what makes it even more
 wiered.

Also check out auto_increment_offset (introduced in 5.0.2):

http://dev.mysql.com/doc/refman/5.0/en/replication-options-master.html#sysvar_auto_increment_offset


/Nisse

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



Re: [PHP] how to say inverse your value (to a boolean)?

2009-08-11 Thread tedd

At 4:16 PM -0600 8/10/09, John Butler wrote:

quick Q:
I have this inside a foreach{}  that I want to alternate between on 
and off so I can alternate the background-color of my tr's.


$tableRowBGcolorBoolCounter != $tableRowBGcolorBoolCounter; 
//-boolean on and off


I am looking thru' docs and books, but can't remember (nor find now) 
in PHP how to say inverse your value (to a boolean).

?

TIA! -G


John:

Here's my solution:

http://webbytedd.com/b/color-rows/

Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] how to say inverse your value (to a boolean)?

2009-08-11 Thread tedd

At 8:46 AM -0400 8/11/09, tedd wrote:

At 4:16 PM -0600 8/10/09, John Butler wrote:

quick Q:
I have this inside a foreach{}  that I want to alternate between on 
and off so I can alternate the background-color of my tr's.


$tableRowBGcolorBoolCounter != $tableRowBGcolorBoolCounter; 
//-boolean on and off


I am looking thru' docs and books, but can't remember (nor find 
now) in PHP how to say inverse your value (to a boolean).

?

TIA! -G


John:

Here's my solution:

http://webbytedd.com/b/color-rows/

Cheers,

tedd


However, my solution (after reading others) is for an alternating row 
color (a boolean operation).


The problem was NOT making every third row a different color or 
making every row a different color. Those problems would require 
different solutions.


There is nothing wrong with embedding php within html, which is 
really a misnomer because it's the php interpreter that's sending the 
resultant html to the browser. It is not sending php snip-its for the 
browser to handle. So, embedding code such as:


tr class=row?php echo($i++  1);?

Is a valid statement that works. It would be nice if you initialize 
the $i value, but it will work either way.


My solution, provided via the above link, is a valid solution.

Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] how to say inverse your value (to a boolean)?

2009-08-11 Thread Martin Scotta
On Tue, Aug 11, 2009 at 10:09 AM, tedd tedd.sperl...@gmail.com wrote:

 At 8:46 AM -0400 8/11/09, tedd wrote:

 At 4:16 PM -0600 8/10/09, John Butler wrote:

 quick Q:
 I have this inside a foreach{}  that I want to alternate between on and
 off so I can alternate the background-color of my tr's.

 $tableRowBGcolorBoolCounter != $tableRowBGcolorBoolCounter; //-boolean on
 and off

 I am looking thru' docs and books, but can't remember (nor find now) in
 PHP how to say inverse your value (to a boolean).
 ?

 TIA! -G


 John:

 Here's my solution:

 http://webbytedd.com/b/color-rows/

 Cheers,

 tedd


 However, my solution (after reading others) is for an alternating row color
 (a boolean operation).

 The problem was NOT making every third row a different color or making
 every row a different color. Those problems would require different
 solutions.

 There is nothing wrong with embedding php within html, which is really a
 misnomer because it's the php interpreter that's sending the resultant html
 to the browser. It is not sending php snip-its for the browser to handle.
 So, embedding code such as:

 tr class=row?php echo($i++  1);?

 Is a valid statement that works. It would be nice if you initialize the $i
 value, but it will work either way.

 My solution, provided via the above link, is a valid solution.


 Cheers,

 tedd

 --
 ---
 http://sperling.com  http://ancientstones.com  http://earthstones.com

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



A change request just came in - the interaction designer wants every
third line to have a grey background, instead of every second line.

# before was $styles = array( 'even', 'odd' );
# after new requirements it is...
$styles = array( 'white', 'white', 'gray' );
foreach($items as $item)
{
printf( 'li class=%s%s/li', current( $styles ), $item );

next( $styles ) or  reset( $styles );
}

The simplest solution is always the best choice.
This provides maintainability and flexibility to changes ( that we don't
know yet )

-- 
Martin Scotta


Re: [PHP] how to say inverse your value (to a boolean)?

2009-08-11 Thread Conor Mac Aoidh

quick Q:
I have this inside a foreach{}  that I want to alternate between on  
and

off so I can alternate the background-color of my tr's.

$tableRowBGcolorBoolCounter != $tableRowBGcolorBoolCounter;  
//-boolean on

and off

I am looking thru' docs and books, but can't remember (nor find now)  
in

PHP how to say inverse your value (to a boolean).
?

TIA! -G


If I was going to do that then I would use jQuery:

script type=text/javascript
$(document).ready(function(){
$(table tr:even).addClass(even);;
$(table tr:odd).addClass(odd);;
});
/script

And yes I know that this is a PHP mailing list lol

--
Conor

http://conormacaoidh.com

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



Re: [PHP] Synchronizing autonumber fields

2009-08-11 Thread tedd

At 9:04 AM +0200 8/11/09, Leidago !Noabeb wrote:

Hi

I have the following tables setup in MYSQL:

Region 1 Region 2
HQ
Tbl1 with autonumbered (PK) Tbl1 with autonumbered (PK)
Tbl1 autonumbered-PK

To explain the above. Basically there are two regions that collect
information and then at the end of each month they have to send the
information to HQ. This is fine, but the problem comes when the
information (the data in the tables) is submitted to HQ. All three
tables have the same names and the same structure. We want to
synchronize the information sent by the regions into one table at HQ.
How can we do this without having the duplicate number problem?


Leidago :

Basically you have data from Region 1 and Region 2 and you want to 
send that information to HQ.


There are several ways to do this, but why not simply have a field in 
your table that defines which region. Clearly, HQ doesn't want to 
lose track of where the data came from, right?


As such, I don't see any problem with HQ receiving data from either 
region regardless of the possibility of the data having the same 
number problem, whatever that may be.


The number problem is reminiscent of one of those We have to 
consider the index of the records for some purpose when that's 
usually for the internal workings of the database. If you want to 
access this data like a relational database, then you can use the 
index. But remember that the indexes do not have to be sequential 
without gaps. In the real world records are both created and deleted.


In any event, Region 1 data might have:

Index - Name - Address
1. Sam 123 Main
2. Joe 456 Elm
3. Ed 789 Oak

So Region 2 data might have:

Index - Name - Address
1. Harry 456 Oak
2. Sally 789 Pine
3. Wally 123 Maple

Thus, HQ data would be:

Index - Region - Region Index - Name - Address
1. 1 1 Sam 123 Main
2. 1 2 Joe 456 Elm
3. 1 3 Ed 789 Oak
4  2 1 Harry 456 Oak
5. 2 2 Sally 789 Pine
6. 2 3 Wally 123 Maple

Just add the data sent from Regions 1 and 2 to the HQ database. Also, 
note that the indexes do not have to match, or be sequential without 
gaps  -- they could have been:


Region 1:

Index - Name - Address
456. Sam 123 Main
458. Joe 456 Elm
560. Ed 789 Oak

Region 2:

Index - Name - Address
1010. Harry 456 Oak
1014. Sally 789 Pine
1021. Wally 123 Maple

Thus, HQ could be:

Index - Region - Region Index - Name - Address
4567. 1 456 Sam 123 Main
4568. 1 458 Joe 456 Elm
4569. 1 560 Ed 789 Oak
4570  2 1010 Harry 456 Oak
4571. 2 1014 Sally 789 Pine
4572. 2 1021 Wally 123 Maple

This is the way I would solve this problem. In fact, depending upon 
what you want to do with the data, I might dispense with recording 
the Name, Address, and other such data in HQ and just record the 
indexes from Region 1 and 2. After all, that's redundant data unless 
you're going to drop the data collected in Region 1 and 2 after the 
exchange. If so, then there's no need to record their indexes.


HTH's

tedd


--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] how to say inverse your value (to a boolean)?

2009-08-11 Thread tedd

At 2:29 PM +0100 8/11/09, Conor Mac Aoidh wrote:

quick Q:
I have this inside a foreach{}  that I want to alternate between on and
off so I can alternate the background-color of my tr's.

$tableRowBGcolorBoolCounter != $tableRowBGcolorBoolCounter; //-boolean on
and off

I am looking thru' docs and books, but can't remember (nor find now) in
PHP how to say inverse your value (to a boolean).
?

TIA! -G


If I was going to do that then I would use jQuery:

script type=text/javascript
$(document).ready(function(){
$(table tr:even).addClass(even);;
$(table tr:odd).addClass(odd);;
});
/script

And yes I know that this is a PHP mailing list lol

--
Conor



And if javascript is turned off?

Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] how to say inverse your value (to a boolean)?

2009-08-11 Thread tedd

At 10:27 AM -0300 8/11/09, Martin Scotta wrote:

A change request just came in - the interaction designer wants every
third line to have a grey background, instead of every second line.

# before was $styles = array( 'even', 'odd' );
# after new requirements it is...
$styles = array( 'white', 'white', 'gray' );
foreach($items as $item)
{

printf( 'li class=%s%s/li', current( $styles ), $item );

next( $styles ) or  reset( $styles );

}

The simplest solution is always the best choice.
This provides maintainability and flexibility to changes ( that we 
don't know yet )


--
Martin Scotta


The simplest solution is in the eyes of the beholder.

My solution was the simplest for the problem presented.

You presented a different problem with a different solution.

Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



[PHP] ereg_replace to preg_replace translation

2009-08-11 Thread m a r k u s

Hi all,

I see that from PHP 5.3.0 ereg_replace() function is deprecated and throws a 
warning.
I would like to use the preg_replace() function as an alternative of ereg_replace() function but... 
can't undestand the \n#[^\n]*\n expression.


$sql = ereg_replace(\n#[^\n]*\n, , $sql);

Any help for tranlation or alternative ?
Thanks

--
m a r k u s

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



[PHP] Upgrading to PHP5.2.x

2009-08-11 Thread Alberto García Gómez
Dear Fellows:

I want ot upgrade my PHP from 5.1.x to 5.2.x. I want to do using rpm, but any 
time that I going to upgrade the rpm request me more dependencies.

How can I configure my rpm (or other command) to automaticly satisfy my 
dependencies.



Saludos Fraternales
_
Atte.
Alberto García Gómez M:.M:.
Administrador de Redes/Webmaster
IPI Carlos Marx, Matanzas. Cuba.

[PHP] Re: Upgrading to PHP5.2.x

2009-08-11 Thread Shawn McKenzie
Alberto García Gómez wrote:
 Dear Fellows:
 
 I want ot upgrade my PHP from 5.1.x to 5.2.x. I want to do using rpm, but any 
 time that I going to upgrade the rpm request me more dependencies.
 
 How can I configure my rpm (or other command) to automaticly satisfy my 
 dependencies.
 
 
 
 Saludos Fraternales
 _
 Atte.
 Alberto García Gómez M:.M:.
 Administrador de Redes/Webmaster
 IPI Carlos Marx, Matanzas. Cuba.

Depends upon what package manager you're using and the OS.  I don't
think that the rpm package manager will resolve/install needed
dependencies, but there are others.  If you're using fedora/redhat then
you can try yum or there is also an apt for fc/rh.

-- 
Thanks!
-Shawn
http://www.spidean.com

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



Re: [PHP] ereg_replace to preg_replace translation

2009-08-11 Thread Shawn McKenzie
m a r k u s wrote:
 Hi all,
 
 I see that from PHP 5.3.0 ereg_replace() function is deprecated and
 throws a warning.
 I would like to use the preg_replace() function as an alternative of
 ereg_replace() function but... can't undestand the \n#[^\n]*\n
 expression.
 
 $sql = ereg_replace(\n#[^\n]*\n, , $sql);
 
 Any help for tranlation or alternative ?
 Thanks
 
 -- 
 m a r k u s

Here's a good regex tutorial:  http://www.regular-expressions.info/

But to answer your question, \n#[^\n]*\n means the match must:

start with a newline(\n) followed by a pound sign (#) followed by 0 or
more characters (*) that are not a newline(^\n) all the way up to
another newline (\n).

To translate to preg I think all you need to do is give it delimiters,
but that may not be necessary, not sure. |\n#[^\n]*\n|

-- 
Thanks!
-Shawn
http://www.spidean.com

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



Re: [PHP] Embedding foreach loops

2009-08-11 Thread sono-io


On Aug 11, 2009, at 12:13 AM, hessi...@hessiess.com wrote:

Do *NOT* get into the habit of outputting your HTML using echo or  
print

statements, it becomes unmaintainable very quickly, use a templating
language, ether with a framework(recomended) or standalone.


	This sounds interesting.  Could you expound on this a little more and  
perhaps list a couple of the templates you mention?


Thanks,
Frank

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



RE: [PHP] ereg_replace to preg_replace translation

2009-08-11 Thread Ford, Mike
 -Original Message-
 From: m a r k u s [mailto:queribus2...@hotmail.com]
 Sent: 11 August 2009 15:34
 
 I see that from PHP 5.3.0 ereg_replace() function is deprecated and
 throws a warning.
 I would like to use the preg_replace() function as an alternative of
 ereg_replace() function but...
 can't undestand the \n#[^\n]*\n expression.
 
 $sql = ereg_replace(\n#[^\n]*\n, , $sql);

Generally the only change you need to make for transition from ereg to preg 
(for simple expressions, anyway) is the addition of pattern delimiters. So the 
above becomes, for example:

  $sql = preg_replace(|\n#[^\n]*\n|, , $sql);

Although I would argue that those \ characters should be escaped (and should 
have been even for ereg), so the more correct version of this is:

  $sql = preg_replace(|\\n#[^\\n]*\\n|, , $sql);


Cheers!

Mike
 -- 
Mike Ford,
Electronic Information Developer, Libraries and Learning Innovation,  
Leeds Metropolitan University, C507, Civic Quarter Campus, 
Woodhouse Lane, LEEDS,  LS1 3HE,  United Kingdom 
Email: m.f...@leedsmet.ac.uk 
Tel: +44 113 812 4730





To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

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



[PHP] Class Problems

2009-08-11 Thread Ashley Sheridan
Hey all,

Is there any reason why this shouldn't work correctly on a server
running PHP 4.4.7:

?php
class testClass
{
private $foo = 'bar';
}

print 'wtf';
?

I would at the very least expect to see the 'wtf' printed out. I've got
a whole class I've written that works fine in PHP 5, but on PHP 4
server, it does nothing with even this simple example.

Any ideas?

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


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



Re: [PHP] Class Problems

2009-08-11 Thread la...@garfieldtech.com
The private keyword was added in PHP 5.  PHP 4 doesn't have visibility 
identifiers.  In PHP 4 you have to use var, which is then always public.


Or you could just use PHP 5 instead of a dead language. :-)

Ashley Sheridan wrote:

Hey all,

Is there any reason why this shouldn't work correctly on a server
running PHP 4.4.7:

?php
class testClass
{
private $foo = 'bar';
}

print 'wtf';
?

I would at the very least expect to see the 'wtf' printed out. I've got
a whole class I've written that works fine in PHP 5, but on PHP 4
server, it does nothing with even this simple example.

Any ideas?

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




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



[PHP] Re: Upgrading to PHP5.2.x

2009-08-11 Thread Colin Guthrie
'Twas brillig, and Alberto García Gómez at 11/08/09 16:05 did gyre and 
gimble:

Dear Fellows:

I want ot upgrade my PHP from 5.1.x to 5.2.x. I want to do using rpm, but any 
time that I going to upgrade the rpm request me more dependencies.

How can I configure my rpm (or other command) to automaticly satisfy my 
dependencies.


This sounds very much like you are mixing and matching different sources 
of RPMs.


Linux distributions are not like Windows machines where you can just 
install any given application, they are an integrated set of 
interdependant packages.


It is not at all recommended (read: a very bad idea) to install e.g. 
RPMs build for one OS version (e.g. RHEL 5.x) on an older version (e.g. 
RHEL 4.x). Doing so can cause numerous problems due to compiler 
changes/optimisations and small ABI breakages that are incompatible with 
the dynamic libraries used etc.


Even if you do pull in all the dependancies when installing a RHEL5 
version of PHP on RHEL4 (just an example), it will not necessarily work 
for the above reasons.


Similarly, if you do run into problems you will not get any support 
(paid or otherwise) for such a setup.



So please don't undertake this upgrade without fully appreciating what 
is going on. If you really want to install the RHEL5 version on RHEL4 
(again just a random example of a distro), you should download the 
source rpms and rebuild them on RHEL4. You may have to rebuild quite a 
few dependant packages to get a fully working system.


HTHs

Col.

--

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
  Mandriva Linux Contributor [http://www.mandriva.com/]
  PulseAudio Hacker [http://www.pulseaudio.org/]
  Trac Hacker [http://trac.edgewall.org/]


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



[PHP] Re: Class Problems

2009-08-11 Thread Ollisso
On Tue, 11 Aug 2009 18:35:35 +0300, Ashley Sheridan  
a...@ashleysheridan.co.uk wrote:



Hey all,

Is there any reason why this shouldn't work correctly on a server
running PHP 4.4.7:

?php
class testClass
{
private $foo = 'bar';
}

print 'wtf';
?

I would at the very least expect to see the 'wtf' printed out. I've got
a whole class I've written that works fine in PHP 5, but on PHP 4
server, it does nothing with even this simple example.

Any ideas?


PHP4 does not support  classes that much.
Especially private/public keywords.

PS: you should enable display_errors and set error_reporting(E_ALL), then  
you will see error here.





--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/

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



Re: [PHP] Class Problems

2009-08-11 Thread Ashley Sheridan
On Tue, 2009-08-11 at 10:40 -0500, la...@garfieldtech.com wrote:
 The private keyword was added in PHP 5.  PHP 4 doesn't have visibility 
 identifiers.  In PHP 4 you have to use var, which is then always public.
 
 Or you could just use PHP 5 instead of a dead language. :-)
 
 Ashley Sheridan wrote:
  Hey all,
  
  Is there any reason why this shouldn't work correctly on a server
  running PHP 4.4.7:
  
  ?php
  class testClass
  {
  private $foo = 'bar';
  }
  
  print 'wtf';
  ?
  
  I would at the very least expect to see the 'wtf' printed out. I've got
  a whole class I've written that works fine in PHP 5, but on PHP 4
  server, it does nothing with even this simple example.
  
  Any ideas?
  
  Thanks,
  Ash
  http://www.ashleysheridan.co.uk
  
  
 
Ah, I was looking up in the documentation, but seem to have missed that.
Just changed the code, and it's working again! The public/private thing
will only really be an issue if someone other than me is using this
script, which is unlikely just at the moment, but ah well!

And I really would use a PHP 5 server given the choice. I've tried
speaking to the hosting company a few times, but they brush me off!

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


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



[PHP] Single quoted strings (was: ereg_replace to preg_replace translation)

2009-08-11 Thread Martin Scotta
On Tue, Aug 11, 2009 at 12:21 PM, Ford, Mike m.f...@leedsmet.ac.uk wrote:

  -Original Message-
  From: m a r k u s [mailto:queribus2...@hotmail.com]
  Sent: 11 August 2009 15:34
 
  I see that from PHP 5.3.0 ereg_replace() function is deprecated and
  throws a warning.
  I would like to use the preg_replace() function as an alternative of
  ereg_replace() function but...
  can't undestand the \n#[^\n]*\n expression.
 
  $sql = ereg_replace(\n#[^\n]*\n, , $sql);

 Generally the only change you need to make for transition from ereg to preg
 (for simple expressions, anyway) is the addition of pattern delimiters. So
 the above becomes, for example:

  $sql = preg_replace(|\n#[^\n]*\n|, , $sql);

 Although I would argue that those \ characters should be escaped (and
 should have been even for ereg), so the more correct version of this is:

  $sql = preg_replace(|\\n#[^\\n]*\\n|, , $sql);


 Cheers!

 Mike
  --
 Mike Ford,
 Electronic Information Developer, Libraries and Learning Innovation,
 Leeds Metropolitan University, C507, Civic Quarter Campus,
 Woodhouse Lane, LEEDS,  LS1 3HE,  United Kingdom
 Email: m.f...@leedsmet.ac.uk
 Tel: +44 113 812 4730





 To view the terms under which this email is distributed, please go to
 http://disclaimer.leedsmet.ac.uk/email.htm

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


You can use a single quote string (instead of escape the \n)
The result is the same, but is more legible.

$sql = preg_replace('|\n#[^\n]*\n|', '', $sql);

Personally I try to not use double quoted.
PHP parses single quoted very much faster.

# for this
echo Hi, $name, wellcome $home;

# I use
echo 'Hi, ', $name, ', wellcome ', $home;

# or
printf( 'Hi, %s, wellcome %s', $name, $home );


And of course, this is a matter of taste!

-- 
Martin Scotta


Re: [PHP] Class Problems

2009-08-11 Thread Aschwin Wesselius

Ashley Sheridan wrote:

And I really would use a PHP 5 server given the choice. I've tried
speaking to the hosting company a few times, but they brush me off!
  

Hi Ashley,

And how is their SLA then? Do you take full responsibility in case of a 
security breach? PHP 4 is way long ago and there are plenty hosting 
companies that do have PHP 5 and have a clear security/update policy.


You, yes YOU, are their client paying their sandwich. If you are not 
serviced properly, they have to eat one less. Now, go on and brush them 
off..


Kind regards,

Aschwin Wesselius

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



Re: [PHP] Class Problems

2009-08-11 Thread Ashley Sheridan
On Tue, 2009-08-11 at 17:57 +0200, Aschwin Wesselius wrote:
 Ashley Sheridan wrote:
  And I really would use a PHP 5 server given the choice. I've tried
  speaking to the hosting company a few times, but they brush me off!

 Hi Ashley,
 
 And how is their SLA then? Do you take full responsibility in case of a 
 security breach? PHP 4 is way long ago and there are plenty hosting 
 companies that do have PHP 5 and have a clear security/update policy.
 
 You, yes YOU, are their client paying their sandwich. If you are not 
 serviced properly, they have to eat one less. Now, go on and brush them 
 off..
 
 Kind regards,
 
 Aschwin Wesselius
 
My last email to them said that if they don't do something soon, then
I'm going elsewhere, so I'll see if that spurs them on. I'm not into
naming and shaming, but if they don't get back to me on this at all,
then I feel a blog rant coming on!

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


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



Re: [PHP] Class Problems

2009-08-11 Thread la...@garfieldtech.com

Ashley Sheridan wrote:

On Tue, 2009-08-11 at 17:57 +0200, Aschwin Wesselius wrote:

Ashley Sheridan wrote:

And I really would use a PHP 5 server given the choice. I've tried
speaking to the hosting company a few times, but they brush me off!
  

Hi Ashley,

And how is their SLA then? Do you take full responsibility in case of a 
security breach? PHP 4 is way long ago and there are plenty hosting 
companies that do have PHP 5 and have a clear security/update policy.


You, yes YOU, are their client paying their sandwich. If you are not 
serviced properly, they have to eat one less. Now, go on and brush them 
off..


Kind regards,

Aschwin Wesselius


My last email to them said that if they don't do something soon, then
I'm going elsewhere, so I'll see if that spurs them on. I'm not into
naming and shaming, but if they don't get back to me on this at all,
then I feel a blog rant coming on!

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


http://gophp5.org/hosts

Over 200 web hosts that have been committed to PHP 5.2 for at least 1.5 
years, in most cases over two years.  I am not affiliated with any of 
them directly.


--Larry Garfield

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



[PHP] Image Headers break when image is out of bounds

2009-08-11 Thread Ashley Sheridan
I've got a bit of a weird one here. I'm using PHP to output an image.
This works fine when I output as a file, but when I try to feed it
directly to the browser it fills the screen with random characters.

I know I've got the headers right, as it works some of the time. The
only thing I can spot when it does fail is that some of the image
drawing commands are essentially drawing off the edge of the image area.
I've checked the error logs, and the only errors/notices I can find
today are a bug in phpMyAdmin and a missing favicon file, nothing to do
with this script.

Has anybody ever noticed a similar problem?

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


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



Re: [PHP] Image Headers break when image is out of bounds

2009-08-11 Thread Ashley Sheridan
On Tue, 2009-08-11 at 19:02 +0100, Ashley Sheridan wrote:
 I've got a bit of a weird one here. I'm using PHP to output an image.
 This works fine when I output as a file, but when I try to feed it
 directly to the browser it fills the screen with random characters.
 
 I know I've got the headers right, as it works some of the time. The
 only thing I can spot when it does fail is that some of the image
 drawing commands are essentially drawing off the edge of the image area.
 I've checked the error logs, and the only errors/notices I can find
 today are a bug in phpMyAdmin and a missing favicon file, nothing to do
 with this script.
 
 Has anybody ever noticed a similar problem?
 
 Thanks,
 Ash
 http://www.ashleysheridan.co.uk
 
 
Oh. I should note that there has been no headers sent already, as I put
the image output part inside of a if(!headers_sent()) block. The headers
I'm using for the PNG image are:

header(Content-Type: image/png);
header(Pragma: no-cache);
header(Expires: 0);

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


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



Re: [PHP] how to say inverse your value (to a boolean)?

2009-08-11 Thread Ben Dunlap
 # before was $styles = array( 'even', 'odd' );
 # after new requirements it is...
 $styles = array( 'white', 'white', 'gray' );
 foreach($items as $item)
 {
 printf( 'li class=%s%s/li', current( $styles ), $item );

 next( $styles ) or  reset( $styles );
 }


+5000. I think is by far the most readable and flexible solution suggested.
I also like it because it's PHPish -- it uses the features of the language
that were made-to-order for this problem.

Ben


Re: [PHP] Image Headers break when image is out of bounds

2009-08-11 Thread Adam Shannon
On Tue, Aug 11, 2009 at 1:08 PM, Ashley Sheridan
a...@ashleysheridan.co.ukwrote:

 On Tue, 2009-08-11 at 19:02 +0100, Ashley Sheridan wrote:
  I've got a bit of a weird one here. I'm using PHP to output an image.
  This works fine when I output as a file, but when I try to feed it
  directly to the browser it fills the screen with random characters.
 
  I know I've got the headers right, as it works some of the time. The
  only thing I can spot when it does fail is that some of the image
  drawing commands are essentially drawing off the edge of the image area.
  I've checked the error logs, and the only errors/notices I can find
  today are a bug in phpMyAdmin and a missing favicon file, nothing to do
  with this script.
 
  Has anybody ever noticed a similar problem?
 
  Thanks,
  Ash
  http://www.ashleysheridan.co.uk
 
 
 Oh. I should note that there has been no headers sent already, as I put
 the image output part inside of a if(!headers_sent()) block. The headers
 I'm using for the PNG image are:

 header(Content-Type: image/png);
 header(Pragma: no-cache);
 header(Expires: 0);

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


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


Take the if (!headers_sent()) out and always send the headers.

-- 
- Adam Shannon ( http://ashannon.us )


Re: [PHP] Embedding foreach loops

2009-08-11 Thread Ben Dunlap
 statements, it becomes unmaintainable very quickly, use a templating
 language, ether with a framework(recomended) or standalone.


But he /is/ using a templating language... PHP. ;-)

Ben


Re: [PHP] Single quoted strings (was: ereg_replace to preg_replace translation)

2009-08-11 Thread Ben Dunlap

 Personally I try to not use double quoted.
 PHP parses single quoted very much faster.

 # for this
 echo Hi, $name, wellcome $home;

 # I use
 echo 'Hi, ', $name, ', wellcome ', $home;


I'm not sure if this was true in older versions of PHP, but it's not so much
any more, and I wonder if it was ever worth the loss of readability.

Interesting discussion about this on the Google Group Make the Web Faster.
The focal points of the discussion are an article by a lead Google engineer,
and then a point-by-point refutation by a PHP core developer. Here's the
refutation:

http://groups.google.com/group/make-the-web-faster/browse_thread/thread/ddfbe82dd80408cc

Ben


Re: [PHP] Image Headers break when image is out of bounds

2009-08-11 Thread Ashley Sheridan
On Tue, 2009-08-11 at 13:29 -0500, Adam Shannon wrote:
 On Tue, Aug 11, 2009 at 1:08 PM, Ashley Sheridan
 a...@ashleysheridan.co.ukwrote:
 
  On Tue, 2009-08-11 at 19:02 +0100, Ashley Sheridan wrote:
   I've got a bit of a weird one here. I'm using PHP to output an image.
   This works fine when I output as a file, but when I try to feed it
   directly to the browser it fills the screen with random characters.
  
   I know I've got the headers right, as it works some of the time. The
   only thing I can spot when it does fail is that some of the image
   drawing commands are essentially drawing off the edge of the image area.
   I've checked the error logs, and the only errors/notices I can find
   today are a bug in phpMyAdmin and a missing favicon file, nothing to do
   with this script.
  
   Has anybody ever noticed a similar problem?
  
   Thanks,
   Ash
   http://www.ashleysheridan.co.uk
  
  
  Oh. I should note that there has been no headers sent already, as I put
  the image output part inside of a if(!headers_sent()) block. The headers
  I'm using for the PNG image are:
 
  header(Content-Type: image/png);
  header(Pragma: no-cache);
  header(Expires: 0);
 
  Thanks,
  Ash
  http://www.ashleysheridan.co.uk
 
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 Take the if (!headers_sent()) out and always send the headers.
 
@Adam
The headers_sent() wasa  test to ensure that no other data was creeping
into the headers before I wanted it to. Keeping it in does no harm, as
it is basically saying, if there are no headers that have been sent,
send the correct ones for the image.

@Martin
The image is being produced by PHP. The command I'm using to output the
image is image_png(), and my OS is correctly reporting a PNG image
(Linux will use the extension as a hint, but gets the filetype from the
contents). Also, for further clarification, the junk output I'm getting
has the letters PNG in the first few characters, so I'm pretty sure this
is a PNG image yes!

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


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



Re: [PHP] Image Headers break when image is out of bounds

2009-08-11 Thread Ben Dunlap
 @Adam
 The headers_sent() wasa  test to ensure that no other data was creeping
 into the headers before I wanted it to. Keeping it in does no harm, as
 it is basically saying, if there are no headers that have been sent,
 send the correct ones for the image.


But if there are headers that have been sent, it sounds like they would not
have been the correct ones. Which I think would cause exactly the problem
you're describing.

Ben


Re: [PHP] Image Headers break when image is out of bounds

2009-08-11 Thread Ben Dunlap
On Tue, Aug 11, 2009 at 11:52 AM, Ben Dunlap bdun...@agentintellect.comwrote:


 @Adam
 The headers_sent() wasa  test to ensure that no other data was creeping
 into the headers before I wanted it to. Keeping it in does no harm, as
 it is basically saying, if there are no headers that have been sent,
 send the correct ones for the image.


 But if there are headers that have been sent, it sounds like they would not
 have been the correct ones. Which I think would cause exactly the problem
 you're describing.

 Ben

 Oops, looked back at your earlier post and it sounds like you only send the
image inside the if(!headers_sent()) block. Never mind, pls disregard my
earlier noise.

Ben


Re: [PHP] how to say inverse your value (to a boolean)?

2009-08-11 Thread Robert Cummings

Ben Dunlap wrote:

# before was $styles = array( 'even', 'odd' );
# after new requirements it is...
$styles = array( 'white', 'white', 'gray' );
foreach($items as $item)
{
printf( 'li class=%s%s/li', current( $styles ), $item );

next( $styles ) or  reset( $styles );
}



+5000. I think is by far the most readable and flexible solution suggested.
I also like it because it's PHPish -- it uses the features of the language
that were made-to-order for this problem.


Actually it's the wrong way to do it.

Change the class names to alternate1 and alternate2 (or something 
else meaningful without being tied to a definition). That way when you 
set the colour for style white to green it doesn't result in 
confusion. Seriously though... this is nomenclature 101.


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

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



Re: [PHP] Image Headers break when image is out of bounds

2009-08-11 Thread Ashley Sheridan
On Tue, 2009-08-11 at 11:54 -0700, Ben Dunlap wrote:
 On Tue, Aug 11, 2009 at 11:52 AM, Ben Dunlap
 bdun...@agentintellect.com wrote:
 
 @Adam
 
 The headers_sent() wasa  test to ensure that no other
 data was creeping
 into the headers before I wanted it to. Keeping it in
 does no harm, as
 it is basically saying, if there are no headers that
 have been sent,
 send the correct ones for the image.
 
 But if there are headers that have been sent, it sounds like
 they would not have been the correct ones. Which I think would
 cause exactly the problem you're describing.
 
 Ben
 
 
 Oops, looked back at your earlier post and it sounds like you only
 send the image inside the if(!headers_sent()) block. Never mind, pls
 disregard my earlier noise.
 
 Ben

Well, this will teach me to pay more attention. Turns out, I was
attempting to output the image before the headers! It was a red herring
that the image was displaying correctly when  the drawing commands were
all inside of the image area. It's probably more of a feature of Fx to
try and recognise the content it's been sent if it can?


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


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



Re: [PHP] Embedding foreach loops

2009-08-11 Thread Robert Cummings



Ben Dunlap wrote:

statements, it becomes unmaintainable very quickly, use a templating
language, ether with a framework(recomended) or standalone.



But he /is/ using a templating language... PHP. ;-)


Keep telling yourself that... and be sure to pat your own back.

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

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



Re: [PHP] Embedding foreach loops

2009-08-11 Thread hessiess

 On Aug 11, 2009, at 12:13 AM, hessi...@hessiess.com wrote:

 Do *NOT* get into the habit of outputting your HTML using echo or
 print
 statements, it becomes unmaintainable very quickly, use a templating
 language, ether with a framework(recomended) or standalone.

 This sounds interesting.  Could you expound on this a little
more and
 perhaps list a couple of the templates you mention?

 Thanks,
 Frank


There are a number of options for templating in PHP such as smarty, Dwoo
and PHP itself, though the syntax can be rather messy. Personally I just
use a simple find and replace macro system to expand custom short-hand
code into the more verbose PHP, then run it through exec and capture the
result to a variable with output buffering, the class folows:

?php
class view
{
var $str;

/*++
* Load in template file and expand macros into PHP
++*/
function __CONSTRUCT($tplname)
{
$fh = fopen($tplname, 'r');
$this-str = fread($fh, filesize($tplname));
fclose($fh);

$this-expand_macros();
}

/*++
 * Run the template and return a variable
++*/
public function parse_to_variable($array = array())
{
extract($array);

ob_start();
eval($this-str);
$result = ob_get_contents();
ob_end_clean();
return $result;
}

/*++
* Expand macros into PHP
++*/
private function expand_macros()
{
// Expand if macro
$this-str = str_replace(if, ?php if, $this-str);
$this-str = str_replace(eif~, ?php endif;?, $this-str);

// Expand loop macro
$this-str = str_replace(loop, ?php foreach, $this-str);
$this-str = str_replace(eloop~, ?php endforeach;?,
$this-str);

// Expand display macro
$this-str = str_replace(dsp, ?php echo, $this-str);

// Expand end tag macro
$this-str = str_replace(~, ?, $this-str);

// Add PHP close tag to exit PHP mode
$this-str = ? . $this-str;
}
}


This loads template files like the folowing:
form enctype=multipart/form-data action=dsp $upload_url ~
method=post
pinput type=hidden name=MAX_FILE_SIZE value=900 //p
pUpload new file, max size dsp $max ~:/p
p
input name=uploaded_file type=file /
input type=submit value=Send File /
/p
/form

table
tr
th width=180pxFilename/th
th width=60pxLink/th
th width=90pxSize (KB)/th
th width=50pxDelete/th
tr

loop ($files as $file): ~

tr
tddsp $file['Name'] ~/td
tda href=dsp $file['Path'] ~Link/a/td
tddsp $file['Size'] / 1000 ~/td
tda href=dsp $file['d_url'] ~X/a/td
tr
eloop~
/table

---
And it can be used like this

$dialogue = new view(template/file_display.tpl);
$dialogue = $dialogue - parse_to_variable(array(
'upload_url' = $upload_url,
'max' = $max_size,
'files' = $files));

the $dialogue var now contains the compiled template, ready for displaying
or integrating into another template.


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



Re: [PHP] how to say inverse your value (to a boolean)?

2009-08-11 Thread Ben Dunlap
 # before was $styles = array( 'even', 'odd' );
 # after new requirements it is...
 $styles = array( 'white', 'white', 'gray' );
 foreach($items as $item)
 {
 printf( 'li class=%s%s/li', current( $styles ), $item );

 next( $styles ) or  reset( $styles );
 }


  +5000. I think is by far the most readable and flexible solution
 suggested.
 I also like it because it's PHPish -- it uses the features of the language
 that were made-to-order for this problem.


 Actually it's the wrong way to do it.

 Change the class names to alternate1 and alternate2 (or something else
 meaningful without being tied to a definition). That way when you set the
 colour for style white to green it doesn't result in confusion.
 Seriously though... this is nomenclature 101.


Good point, and thanks for the presentation-vs-content reality check. I'll
downgrade my vote to a more sober +4990, in consideration of the class names
in $styles.

Ben


Re: [PHP] Embedding foreach loops

2009-08-11 Thread Ben Dunlap
 statements, it becomes unmaintainable very quickly, use a templating
 language, ether with a framework(recomended) or standalone.



 But he /is/ using a templating language... PHP. ;-)


 Keep telling yourself that... and be sure to pat your own back.


I'm sure there are plenty of situations that call for a more focused
templating system than the one that PHP already is. And there are plenty
that don't.

From the earlier content of this thread, I suspect the problem the OP is
currently working on falls into the latter camp. Didn't mean to bash
templating systems.

This is probably flame-war tinder, so I'll try to tread more delicately in
the future. Next you know we'll be on the ternary operator and which is
better, Mac or Windows. ;-)

Ben


Re: [PHP] how to say inverse your value (to a boolean)?

2009-08-11 Thread John Butler

What a lot of good ideas spawned from the OP!
I am learning many things,.. while also actually working (paying  
bills), so I regularly have to just go with what I know well.


Anyway, I already have the forearch { loop (for other reasons it is  
necessary), and I only needed one color to alternate with the default  
white..  so I used this:


 forearch { ...
$tableRowBGcolorBoolCounter = !$tableRowBGcolorBoolCounter; //-boolean  
on and off


(which then sticks in one CSS class or another for that tr.

thanks for everyone's feedback.
-John

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



[PHP] Calendar Problem

2009-08-11 Thread tedd

Hi gang:

I want to show the dates for all Fridays +-30 days from a specific date.

For example, given today's date (8/11/2009) the Fridays that fall 
+-30 days are July 17, July 24, July 31, Aug 7, Aug 14, Aug 21, Aug 
28, and Sept 4.


I'm curious, how would you guys solve this?

Cheers,

tedd
--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] Embedding foreach loops

2009-08-11 Thread tedd

At 12:44 PM -0700 8/11/09, Ben Dunlap wrote:

This is probably flame-war tinder, so I'll try to tread more delicately in
the future. Next you know we'll be on the ternary operator and which is
better, Mac or Windows. ;-)

Ben


That was won long ago, it's Mac. :-)

Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] Embedding foreach loops

2009-08-11 Thread Eddie Drapkin
On Tue, Aug 11, 2009 at 3:56 PM, teddtedd.sperl...@gmail.com wrote:
 At 12:44 PM -0700 8/11/09, Ben Dunlap wrote:

 This is probably flame-war tinder, so I'll try to tread more delicately in
 the future. Next you know we'll be on the ternary operator and which is
 better, Mac or Windows. ;-)

 Ben

 That was won long ago, it's Mac. :-)

 Cheers,

 tedd

 --
 ---
 http://sperling.com  http://ancientstones.com  http://earthstones.com

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



If by Mac you mean Linux, you're entirely correct.

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



Re: [PHP] how to say inverse your value (to a boolean)?

2009-08-11 Thread tedd

At 1:53 PM -0600 8/11/09, John Butler wrote:

What a lot of good ideas spawned from the OP!
I am learning many things,.. while also actually working (paying 
bills), so I regularly have to just go with what I know well.


Anyway, I already have the forearch { loop (for other reasons it is 
necessary), and I only needed one color to alternate with the 
default white..  so I used this:


 forearch { ...
$tableRowBGcolorBoolCounter = !$tableRowBGcolorBoolCounter; 
//-boolean on and off


(which then sticks in one CSS class or another for that tr.

thanks for everyone's feedback.
-John


Yeah, but forearch ain't going to work.

Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] Embedding foreach loops

2009-08-11 Thread John Butler

Allen, you off and running again?


Sure am, thanks, on to the next set of issues. Seems like  
programming is always moving on from one error to the next :)


Currently, I am having trouble with echo and php line-returns.

It works on one part of the code, but not on another (instead,  
prints it to html).


For example:

[code]

$show[show_01][price] * $show_01_qty = $Total_show_01;
 echo \ntr\n\t;
 echo tda.$show[show_01][price]./td/n/ttd*/td/n/ttdb. 
$show_01_qty./td/n/ttd=/td\n\ttdc.$Total_show_01./td;

 echo \n/tr;

[/code]

outputs this html

[code]

tr
   tda/td/n/ttd*/td/n/ttdb/td/n/ttd=/td
   tdc/td
/tr

[/code]
Additionally, it won't display the variables, as you can see, even  
though they will echo out further above in the document. Odd...



well you escape a newline char with this slash:
\
and not this one:
/
notice you were not consistent with your use of them.
as for the array not being parsed inside your echo statement -  I  
don't see the issue by looking now.  Are you saying the EXACT same  
code does output the expected value for those array elements higher up  
the script?  Show us the code where it is working and again where it  
is not..  side by side (pasted just after each other in a new post to  
the list).


I assume you are past this next point, but always remember
var_dump($myArray);
is your friend.  Put it just before where you try to echo out some  
part of the array..  check to be sure the value is there is that  
element of the multi-dimensional array the way you think it is.


-John

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



Re: [PHP] Calendar Problem

2009-08-11 Thread Robert Cummings

tedd wrote:

Hi gang:

I want to show the dates for all Fridays +-30 days from a specific date.

For example, given today's date (8/11/2009) the Fridays that fall 
+-30 days are July 17, July 24, July 31, Aug 7, Aug 14, Aug 21, Aug 
28, and Sept 4.


I'm curious, how would you guys solve this?


?php

$fridays = array();
for( $i = -30; $i = 30; $i++ )
{
$mod = $i  0 ? $i : '+'.$i;

$time = strtotime( $mod.' day' );

if( date( 'D', $time ) == 'Fri' )
{
$fridays[] = date( 'Y-m-d', $time );
}
}

print_r( $fridays );

?

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

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



Re: [PHP] how to say inverse your value (to a boolean)?

2009-08-11 Thread John Butler

What a lot of good ideas spawned from the OP!
I am learning many things,.. while also actually working (paying  
bills), so I regularly have to just go with what I know well.


Anyway, I already have the forearch { loop (for other reasons it is  
necessary), and I only needed one color to alternate with the  
default white..  so I used this:


forearch { ...
$tableRowBGcolorBoolCounter = !$tableRowBGcolorBoolCounter; //- 
boolean on and off


(which then sticks in one CSS class or another for that tr.

thanks for everyone's feedback.
-John


Yeah, but forearch ain't going to work.



what do you mean?  I must have neglected to include more of the  
relevant code to show you that it IS working just fine.   I will  
certainly explain more if you ask..  but the whole point of me  
starting the thread was just to be reminded how to inverse a boolean  
var's value.  Tony answered me; I am happy.   I assume you don't want  
me (the newbie) to show how I have it working. (?)



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



Re: [PHP] how to say inverse your value (to a boolean)?

2009-08-11 Thread Robert Cummings

John Butler wrote:

What a lot of good ideas spawned from the OP!
I am learning many things,.. while also actually working (paying  
bills), so I regularly have to just go with what I know well.


Anyway, I already have the forearch { loop (for other reasons it is  
necessary), and I only needed one color to alternate with the  
default white..  so I used this:


forearch { ...
$tableRowBGcolorBoolCounter = !$tableRowBGcolorBoolCounter; //- 
boolean on and off


(which then sticks in one CSS class or another for that tr.

thanks for everyone's feedback.
-John

Yeah, but forearch ain't going to work.



what do you mean?  I must have neglected to include more of the  
relevant code to show you that it IS working just fine.   I will  
certainly explain more if you ask..  but the whole point of me  
starting the thread was just to be reminded how to inverse a boolean  
var's value.  Tony answered me; I am happy.   I assume you don't want  
me (the newbie) to show how I have it working. (?)


He's pointing out a typo... forearch instead of foreach :)

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

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



Re: [PHP] how to say inverse your value (to a boolean)?

2009-08-11 Thread John Butler

He's pointing out a typo... forearch instead of foreach :)


LOL!

I almost always miss the jokes.

Thanks for the smiley face to get my (lighter) attention ;-)

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



Re: [PHP] Embedding foreach loops

2009-08-11 Thread Rick Duval
OK, first guys, I'm sorry to have to do this but I can't get off this list!!!

I've followed the instructions on a couple of occasions (the ones at
the bottom of every email):
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php

Been There, done that. I can't get off the list!!! I use Gmail and I
use an an alias as well, tried them both, still on the list. No reply
from Majordomo.

Yes, I've check my spam filter for a unsubscribe confirmation (if it
sends one which I presume it's supposed to).

Headers tell me that this list is php-general@lists.php.net. Sent
the unsubscribe emails. No replies.

Again. I apologize but have no idea what to do to get off this list!
THis is the only list server I can't seem to get off of.

Help!


On Mon, Aug 10, 2009 at 6:04 PM, John
Butlergovinda.webdnat...@gmail.com wrote:
 I can't seem to get my foreach loops to work, will PHP parse embedded
 loops?

 yes.

 Is this something I need to have in a database to work?

 no, you can do it with the arrays...  but it may be easier to work with over
 the long run if that data was in a db.

 Anyway right after you finish creating the array and it's embedded arrays,
 in your code, then add this:
 var_dump($shows); //--so you can see what you just created.  If it looks
 right, THEN go on bothering to try and parse it with your (embedded)
 foreach's {

 
 John Butler (Govinda)
 govinda.webdnat...@gmail.com




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


 -This message has been scanned for
 viruses and dangerous content byAccurate Anti-Spam Technologies.
 www.AccurateAntiSpam.com



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



Re: [PHP] Embedding foreach loops

2009-08-11 Thread Robert Cummings

Let me be the first to welcome you to the list!!!



Rick Duval wrote:

OK, first guys, I'm sorry to have to do this but I can't get off this list!!!

I've followed the instructions on a couple of occasions (the ones at
the bottom of every email):

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


Been There, done that. I can't get off the list!!! I use Gmail and I
use an an alias as well, tried them both, still on the list. No reply
from Majordomo.

Yes, I've check my spam filter for a unsubscribe confirmation (if it
sends one which I presume it's supposed to).

Headers tell me that this list is php-general@lists.php.net. Sent
the unsubscribe emails. No replies.

Again. I apologize but have no idea what to do to get off this list!
THis is the only list server I can't seem to get off of.

Help!


On Mon, Aug 10, 2009 at 6:04 PM, John
Butlergovinda.webdnat...@gmail.com wrote:

I can't seem to get my foreach loops to work, will PHP parse embedded
loops?

yes.


Is this something I need to have in a database to work?

no, you can do it with the arrays...  but it may be easier to work with over
the long run if that data was in a db.

Anyway right after you finish creating the array and it's embedded arrays,
in your code, then add this:
var_dump($shows); //--so you can see what you just created.  If it looks
right, THEN go on bothering to try and parse it with your (embedded)
foreach's {


John Butler (Govinda)
govinda.webdnat...@gmail.com




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


-This message has been scanned for
viruses and dangerous content byAccurate Anti-Spam Technologies.
www.AccurateAntiSpam.com






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

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



[PHP] Re: Calendar Problem

2009-08-11 Thread Shawn McKenzie
tedd wrote:
 Hi gang:
 
 I want to show the dates for all Fridays +-30 days from a specific date.
 
 For example, given today's date (8/11/2009) the Fridays that fall +-30
 days are July 17, July 24, July 31, Aug 7, Aug 14, Aug 21, Aug 28, and
 Sept 4.
 
 I'm curious, how would you guys solve this?
 
 Cheers,
 
 tedd

Lots of ways to skin that cat, here is one:

$date = time(); //or whenever
$start = strtotime('-30 days', $date);
$end = strtotime('+30 days', $date);

$next = $start;
while(($next = strtotime('Next Friday', $next)) = $end) {
echo date(F j, Y, $next).\n;
}

-- 
Thanks!
-Shawn
http://www.spidean.com

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



Re: [PHP] Calendar Problem

2009-08-11 Thread Jim Lucas
Robert Cummings wrote:
 tedd wrote:
 Hi gang:

 I want to show the dates for all Fridays +-30 days from a specific date.

 For example, given today's date (8/11/2009) the Fridays that fall +-30
 days are July 17, July 24, July 31, Aug 7, Aug 14, Aug 21, Aug 28, and
 Sept 4.

 I'm curious, how would you guys solve this?
 
 ?php
 
 $fridays = array();
 for( $i = -30; $i = 30; $i++ )
 {
 $mod = $i  0 ? $i : '+'.$i;

man, please use some parenthesis...

my translation of the above would be the following:

$mod = (($i  0) ? $i : ('+'.$i));

would that be correct?

 
 $time = strtotime( $mod.' day' );
 
 if( date( 'D', $time ) == 'Fri' )
 {
 $fridays[] = date( 'Y-m-d', $time );
 }
 }
 
 print_r( $fridays );
 
 ?
 
 Cheers,
 Rob.



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



Re: [PHP] Calendar Problem

2009-08-11 Thread Robert Cummings



Jim Lucas wrote:

Robert Cummings wrote:

tedd wrote:

Hi gang:

I want to show the dates for all Fridays +-30 days from a specific date.

For example, given today's date (8/11/2009) the Fridays that fall +-30
days are July 17, July 24, July 31, Aug 7, Aug 14, Aug 21, Aug 28, and
Sept 4.

I'm curious, how would you guys solve this?

?php

$fridays = array();
for( $i = -30; $i = 30; $i++ )
{
$mod = $i  0 ? $i : '+'.$i;


man, please use some parenthesis...

my translation of the above would be the following:

$mod = (($i  0) ? $i : ('+'.$i));

would that be correct?


Yes... in a superfluous hold-my-hand sort of way :)

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

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



[PHP] Re: Calendar Problem

2009-08-11 Thread Shawn McKenzie
Shawn McKenzie wrote:
 tedd wrote:
 Hi gang:

 I want to show the dates for all Fridays +-30 days from a specific date.

 For example, given today's date (8/11/2009) the Fridays that fall +-30
 days are July 17, July 24, July 31, Aug 7, Aug 14, Aug 21, Aug 28, and
 Sept 4.

 I'm curious, how would you guys solve this?

 Cheers,

 tedd
 
 Lots of ways to skin that cat, here is one:
 
 $date = time(); //or whenever
 $start = strtotime('-30 days', $date);
 $end = strtotime('+30 days', $date);
 
 $next = $start;
 while(($next = strtotime('Next Friday', $next)) = $end) {
   echo date(F j, Y, $next).\n;
 }
 

I must be bored:

for($next = strtotime('-30 days');
$next = strtotime('+30 days');
$next = strtotime('Next Friday', $next))
{
echo date(F j, Y, $next).\n;
}

-- 
Thanks!
-Shawn
http://www.spidean.com

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



RE: [PHP] how to say inverse your value (to a boolean)?

2009-08-11 Thread Daevid Vincent
 

 -Original Message-
 Daevid Vincent wrote:
  NO! For the love of God and all that is holy, don't do that 
 accumulator / mod hack. 
  That's so 1980's. And why make the CPU do all that math 
 for every row...
  
  Just do this. It's quick and simple:
  
  CSS:
  .dataRow1 { background-color: #DFDFDF; }
  .dataRow2 { background-color: #FF; }
  
  foreach ($foo_array as $foo) {
 ?tr class=?= ($dr = !$dr) ? dataRow1 : dataRow2 
 ?td?= $foo
  ?/td/tr?php
 
 Wow, were to start with all the problems in the above code:
 1.  Short tags?

Nothing wrong with them. Do yourself a test. There is zero speed difference
in a page. It makes your code cleaner and easier to read, plus less
kilobytes you have to pull from the hard drive, therefore faster pages.

http://stackoverflow.com/questions/662891/is-there-a-speed-difference-betwee
n-php-echo-var-and-var

http://cubicspot.blogspot.com/2009/06/maximum-failure-php-6-deprecates-short
.html

Are you sure you're not confused with short_open_tags ie. ? ? -- which I
am fully against (as am I against % % too), although sadly they are lumped
into the same directive, when IMHO they should be separate.

http://us.php.net/manual/en/ini.core.php#ini.short-open-tag

http://www.php.net/~derick/meeting-notes.html#remove-support-for-and-script-
language-php-and-add-php-var

 2.  Not using echo or print.  

?= ? is a fantastic shortcut to the antiquated ?php echo ; ? B.S.
The vast majority of your page is output in little fragments like this, so
why not keep it clean and easy to read. Why would you purposely choose to be
more verbose than you need to be for something as basic as print.

 You actually recommend breaking in/out of php?

Hell yeah I do. THAT is one of the MAIN reasons to use PHP. Otherwise, why
not just render your whole page with a bunch of $html .= 'trtd...';
tags and print $html at the end. Welcome to the year 2000 my friend.

You're probably the same kind of person that does this crap:

if ($foo == true)
{
   echo A;
}
else
{
   echo B;
}

(complete with extra braces and checking for 'true' explicitly, but not
using === in such cases)

Rather than a much cleaner, easier to read/write and more concise:

 ?= ($foo) ? 'A' : 'B' ?


 3.  Using uninitialized variables (I run with the E_ALL crowd)

I'm so happy for you. Do you have a membership card and everything? That's
your own masochistic fault then. I run with the
save-myself-the-headache-and-write-clean-efficient-code crowd.

 4.  Using the tr class='' and not the td class=''...  Hmmm

Maybe you're new to how HTML works, but if you want to highlight a ROW (as
the OP did), then you put the background color on the highest parent that it
applies to. Hey imagine that, there is a TR tag which stands for TABLE ROW
tag. Seems obvious to me. This reduces your page size in kilobytes, makes a
much cleaner HTML rendering to read in source, and is the PROPER way to do
it.

  }
  
  No need to initialize $dr as by default PHP will make it a 
 boolean false,
  then each itteration, it will toggle true/false and 
 substitute the CSS class
  
  -Original Message-
  From: Jim Lucas [mailto:li...@cmsws.com] 
  Sent: Monday, August 10, 2009 4:03 PM
  To: John Butler
  Cc: PHP-General List
  Subject: Re: [PHP] how to say inverse your value (to a boolean)?
 
  John Butler wrote:
  quick Q:
  I have this inside a foreach{}  that I want to alternate 
  between on and
  off so I can alternate the background-color of my tr's.
 
  $tableRowBGcolorBoolCounter != $tableRowBGcolorBoolCounter; 
  //-boolean
  on and off
 
  I am looking thru' docs and books, but can't remember (nor 
  find now) in
  PHP how to say inverse your value (to a boolean).
  ?
 
  TIA! -G
 
 
  ?php
 
  $arr = range(1, 10);
 
  $i = 0;
  foreach ( $arr AS $row ) {
 
 $row_color = ( ( $i++ % 2 ) ? 'green' : 'red');
 
 echo $row_color;
 
  }
 
  ?
 
 
 another (neat|strange)+ way I use the above is like so
 
 style
   .rowColor0 { background: #FF; }
   .rowColor1,
   .rowColor3 { background: #EE; }
   .rowColor2 { background: #DD; }
 /style
 ?php
 
 $arr = range(1, 10);
 
 $i = 0;
 
 foreach ( $arr AS $row ) {
 
   echo 'trtd class=rowColor'.( $i++ % 4 
 ).'''.$row.'/td/tr';
 
 }
 ?
 
 
  -- 
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
  
  
 
 
 -- 
 Jim Lucas
 
 Some men are born to greatness, some achieve greatness,
 and some have greatness thrust upon them.
 
 Twelfth Night, Act II, Scene V
  by William Shakespeare
 


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



Re: [PHP] Calendar Problem

2009-08-11 Thread Paul M Foster
On Tue, Aug 11, 2009 at 03:53:58PM -0400, tedd wrote:

 Hi gang:

 I want to show the dates for all Fridays +-30 days from a specific date.

 For example, given today's date (8/11/2009) the Fridays that fall
 +-30 days are July 17, July 24, July 31, Aug 7, Aug 14, Aug 21, Aug
 28, and Sept 4.

 I'm curious, how would you guys solve this?

Convert to julian days, then add or subtract days as desired. Then
convert back to gregorian.

Paul

-- 
Paul M. Foster

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



[PHP] is there any way to get realpath cache hit ratio of php?

2009-08-11 Thread Peter Wang
hi,

Is there any way to get realpath cache hit ratio of php?


realpath_cache_size integer

Determines the size of the realpath cache to be used by PHP. This
value should be increased on systems where PHP opens many files, to
reflect the quantity of the file operations performed.

realpath_cache_ttl integer

Duration of time (in seconds) for which to cache realpath information
for a given file or directory. For systems with rarely changing files,
consider increasing the value.

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