Re: [PHP] Howdy (new in here)

2011-02-15 Thread Tamara Temple


On Feb 15, 2011, at 4:17 PM, Donovan Brooke wrote:


[snip]

This is what I show my students:

http://rebel.lcc.edu/sperlt/citw229/brace-styles.php

Cheers,

tedd



I didn't know there were names for bracing styles... but


Neither did I -- just the K&R style was the only name I recognized. (I  
still have a first edition!)



However, I think on my next project, I will use "Whitesmith's Style".


I would be more inclined to try other styles if my editor of choice,  
TextMate, were to easily support them; as it is now, TextMate  
automatically un-indents the line when you type a closing } on an open  
line, and automatically indents on an open line after a opening { --  
so, what to do? I don't really want to dive into programming my  
editor's functions (which I could do with TextMate) as that is really  
getting into non-productive tweaking.


The issue I had at times with the K&R style was locating the the  
matching (open or closed) brace.. as they were not on the same

character column.


I never really found this to be a problem as long as I kept the  
various branches short enough. I was unlucky enough to find someone  
who coded a function that went on for 30 pages one (this was in C, not  
PHP) and *that* was hard to untangle. Of course, one of the first  
things I did when I had a spare moment was to chop it up in to  
individual functions



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



Re: [PHP] Finding split points in an article for inserting ads

2011-02-15 Thread Tamara Temple


On Feb 15, 2011, at 4:32 PM, Brian Dunning wrote:


Yes, thanks, what I'm looking for is how to do that.

On Feb 15, 2011, at 1:38 PM, Simon J Welsh wrote:

Assuming you're only using  tags, count the number of opening  
 tags, divide by three. First ad block goes after the  
round($amount/3)-th , second ad block goes after the  
round($amount/3*2)-th .

---
Simon Welsh


Dear list,

I want to extend the original question to a discussion about the  
relative merits of doing this within PHP vs. doing it afterwards in  
JavaScript. I can see arguments for both sides, so I would like get  
opinions from others on this tradeoff.




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



Re: [PHP] Rate my (really) simple template class

2011-02-15 Thread David Hutto
On Mon, Feb 14, 2011 at 9:52 PM, Brian Waters  wrote:
> So I decided to write a template class in order to get myself going on
> learning PHP. Of course I wrote the simplest thing possible:
>
> class Template
> {
>        protected $template;
>        protected $vars;
>
>        public function __construct($template)
>        {
>                $this->template = $template;
>        }
>
>        public function __set($name, $value)
>        {
>                $this->vars[$name] = $value;
>        }
>
>        public function __get($name)
>        {
>                return $this->vars[$name];
>        }
>
>        public function __toString()
>        {
>                ob_start();
>                eval('?>' . $this->template);
>                return ob_get_clean();
>        }
> }
>
> Which you can use, quite simply like this:
>
> $tpl = new Template(file_get_contents('index.tpl.php'));
>
> $tpl->title = 'Here\'s the title';
> $tpl->text = 'Blah blah blah...';
>
> echo $tpl;
>
> I have a few questions though.
>
> - First, I'm storing the template as an actual string, instead of just
> a path to a template file, which means I'm using eval() instead of
> require() in my __toString(). My thinking was that this would avoid
> reading the template file twice in the case that __toString() gets
> called multiple times. But will PHP handle this automagically if I do
> in fact decide to store a path to a file, and call require() instead?
>
> - Secondly, I noticed that in the constructor, it's not necessary to
> initialize $vars to an empty array, and I haven't done so. I guess PHP
> automatically initializes it the first time I set one of its elements
> to a value. Is this okay, or is there a better way in the name of best
> practices?
>
> - Finally, I'd like to be able to limit what things can be accessed
> from the scope of the template file. As it stands, if you have a
> function named blowUpTheComputer() or a gobal variable called
> $dontTouchThis, a template author can easily cause trouble. They can
> also access any methods and properties of the Template class. How
> would you go about restricting this?
>
> Thanks a lot!
>
> - BW
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Usually template comes after you've mastered the language, and know
what to base the initial template on. So know what you're templating
first. It's like trying to design a debugger for a language you don't
know how to debug. Learn first, and debug,, template later, once you
know what you're templating.


-- 
According to theoretical physics, the division of spatial intervals as
the universe evolves gives rise to the fact that in another timeline,
your interdimensional counterpart received helpful advice from me...so
be eternally pleased for them.

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



Re: [PHP] Rate my (really) simple template class

2011-02-15 Thread Adam Richardson
On Tue, Feb 15, 2011 at 5:02 PM, Brian Waters wrote:

> On Mon, Feb 14, 2011 at 11:49 PM, Paul M Foster 
> wrote:
> > Advice: don't use eval() this way. It's slow and dangerous.
>
> Could you elaborate, or provide a link?
>

Hi Brian,

Here's a dated but still relevant reference:
http://blog.joshuaeichorn.com/archives/2005/08/01/using-eval-in-php/

In
terms of performance, you could toss together some tests to see the
performance hit (using microtime() and a for loop could get you some nice
quick data.) It's a pretty big hit, and to my knowledge, opcode caches don't
cache eval() code, either.

In terms of security, the issue is using user input. If your evaluated code
includes any user input, you'll have to safely guard against a vast array of
potential injections. Not so hard when the user input is limited to numbers
like an age field, just regex it to show it's only numbers.  However,
complex user input becomes very difficult. In the case of your example
template class, evaling a template file that you don't control and that by
it's very nature is contains complex data, would lead to significant
security issues.

I have never chosen to use eval, as PHP comes with many, many powerful
options for solving problems. However, it's nice to know it's there if I
wanted to use it :)

In the case of your template class, you have several options:

   - Use placeholders other than PHP and merely perform string replaces
   (e.g., "{title}", "{text}", etc.).  This is a bit slower, but limits PHP in
   markup.
   - Change the sequence of your calls. You could create the template
   object, set the variables, then include the appropriate template file. See
   answer 2 by meouw in the link below:

http://stackoverflow.com/questions/529713/php-define-scope-for-included-file

Anyways, just 2 quick ideas.

Happy PHP coding,

Adam

-- 
Nephtali:  A simple, flexible, fast, and security-focused PHP framework
http://nephtaliproject.com


Re: [PHP] Rate my (really) simple template class

2011-02-15 Thread Paul M Foster
On Tue, Feb 15, 2011 at 05:02:51PM -0500, Brian Waters wrote:

> On Mon, Feb 14, 2011 at 11:49 PM, Paul M Foster 
> wrote:
> > Advice: don't use eval() this way. It's slow and dangerous.
> 
> Could you elaborate, or provide a link?

A year or two on this list. The comments in the php.net article on
eval(). Experience with other languages which have similar constructs.
See also Appendix B on Functions in *Essential PHP Security*, a thin but
important book to have. The eval() function is the first one the author
cautions against, and explains why.

I wouldn't use eval() unless I constructed the input for it myself and
was fairly sure I could trust what I constructed. But that's just me.

> 
> > ...read in the file and pass it to you on the stack, which is
> > really an abuse of the stack if you can avoid it.
> 
> Interesting. I'm used to statically-typed languages. Normally I never
> would have passed a large structure like that on the stack. But then
> again, in those languages, large structures are usually passed by
> reference, by default. In C, the only way to pass a string or array by
> value is to wrap it in a struct, and in Java, objects are passed by
> reference (if I recall correctly).

C strings are peculiar animals, as K & R point out. By default, function
parameters in PHP are passed by value. You can pass them by reference,
but it's the exception rather than the rule.

Paul

-- 
Paul M. Foster
http://noferblatz.com


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



[PHP] Re: PHP arguments getting lost in call!?

2011-02-15 Thread Florin Jurcovici
Hi.

> I had no idea you were using Xdebug. When you said Zend Studio i assumed
> you were using the standard Zend debugger. My bad.
>
> Been trying to get Xdebug working in combination with Zend Studio 8. The
> two seem to talk to each other. But Zend Studio doesn't display any
> data, no breakpoints, etc
>
> i compiled from source since i am using Zend Server. No luck. So back to
> the Zend Debugger for now.

I switched to another combination right now. Since I also use Spring's
Tool Suite for other stuff, I just installed the PDT inside it. Xdebug
happily shows variables and properly hits breakpoints with this
configuration.

Nevertheless, after installing the updated package I mentioned in my
previous post, I was able to properly use the debugger in Zend Studio
too. However, since I don't use Zend Server, there's not really a
point in me using Zend Studio. I was just trying it out, hoping to
find something that regular Eclipse distros with PDT installed won't
give me - something else than the integration with Zend Server. Zend
Server might be OK, but since I have to deploy on Apache + mod_php, I
can't afford to develop and test exclusively on Zend Server, so why
not go with the target platform from the very beginning?

br,

flj

-- 
Fine counsel is confusing, but example is always clear. (Edgar A.
Guest, The Light of Faith)




-- 
Fine counsel is confusing, but example is always clear. (Edgar A.
Guest, The Light of Faith)

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



Re: [PHP] Howdy (new in here)

2011-02-15 Thread Micky Hulse
On Tue, Feb 15, 2011 at 2:00 PM, David Harkness
 wrote:
> I use K&R. I started with it just as shown but as monitors increased in size
> I stopped cuddling the else so it's now on its own line, aligning the if,
> elseif, and else nicely. One of the developers at my company uses the
> truly abominable Horstmann style which makes moving code around a serious

K&R here, unless existing guidelines are in place... CodeIgniter
framework and ExpressionEngine wants folks to use Allman.

I use a programming lang called Objectscript at work, and it will give
an error if there is not space between the "if" and the first "("...
For example:

if(...) <-- errors out.

I have had to learn to put a space in there:

if (...)

So I don't forget, I do this for everything now... I actually kinda
like the breathing room now.

Speaking of spaces, I am not a fan of putting spaces around the argument:

if ( foo == baz ) {

I definitely prefer this:

if (foo == baz) {

More on spaces: I am so glad that most PHP folks I know use tabs for
indentation and not spaces! Oops, did I just go there? Oh no I didn't!

Good thread! Thanks for that link Tedd!

Cheers,
Micky

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



Re: [PHP] Custom function

2011-02-15 Thread Simon J Welsh
On 16/02/2011, at 1:21 PM, Mark Kelly wrote:

> In this way almost any value in $z will trigger the conditional code, 
> including 0 or an empty string. The exceptions are FALSE and NULL. If you 
> explicitly need to react to a NULL value, use is_null() to detect it. 

http://nz.php.net/boolean#language.types.boolean.casting

As $z is converted to a boolean and exists, that works just the same way as 
!empty().
---
Simon Welsh
Admin of http://simon.geek.nz/

Who said Microsoft never created a bug-free program? The blue screen never, 
ever crashes!

http://www.thinkgeek.com/brain/gimme.cgi?wid=81d520e5e


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



Re: [PHP] Custom function

2011-02-15 Thread Andre Polykanine
Hello Mark,

Hm... will

if ($z)

evaluate to true if $z==0?
I thought no...

Actually, we can use

if (isset($z))

-- 
With best regards from Ukraine,
Andre
Skype: Francophile
My blog: http://oire.org/menelion (mostly in Russian)
Twitter: http://twitter.com/m_elensule
Facebook: http://facebook.com/menelion

 Original message 
From: Mark Kelly 
To: php-general@lists.php.net
Date created: , 2:21:36 AM
Subject: [PHP] Custom function


  
Hi.

On Tuesday 15 Feb 2011 at 23:41 Andre Polykanine wrote:

> Give it a default (possible empty) value:
>
> function MyFunction($x, $y, $z="") {
> // function goes here
> if (!empty($z)) {
> // The optional parameter is given
> }
> }

Using an empty string and the empty() function in this way can lead to subtle 
and hard to find bugs - for example if $z = 0, the code will not be executed. 
Note the list of things that are considered empty:

http://uk.php.net/manual/en/function.empty.php

Instead, consider setting the default value for $z to boolean false:

function MyFunction ($x, $y, $z = FALSE) {
  if ($z) {
// do stuff with $z
  }
}

In this way almost any value in $z will trigger the conditional code, 
including 0 or an empty string. The exceptions are FALSE and NULL. If you 
explicitly need to react to a NULL value, use is_null() to detect it. 

Cheers,

Mark

-- 
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] Custom function

2011-02-15 Thread Richard Quadling
On 16 February 2011 00:21, Mark Kelly  wrote:
> Hi.
>
> On Tuesday 15 Feb 2011 at 23:41 Andre Polykanine wrote:
>
>> Give it a default (possible empty) value:
>>
>> function MyFunction($x, $y, $z="") {
>> // function goes here
>> if (!empty($z)) {
>> // The optional parameter is given
>> }
>> }
>
> Using an empty string and the empty() function in this way can lead to subtle
> and hard to find bugs - for example if $z = 0, the code will not be executed.
> Note the list of things that are considered empty:
>
> http://uk.php.net/manual/en/function.empty.php
>
> Instead, consider setting the default value for $z to boolean false:
>
> function MyFunction ($x, $y, $z = FALSE) {
>  if ($z) {
>    // do stuff with $z
>  }
> }
>
> In this way almost any value in $z will trigger the conditional code,
> including 0 or an empty string. The exceptions are FALSE and NULL. If you
> explicitly need to react to a NULL value, use is_null() to detect it.
>
> Cheers,
>
> Mark

You also have the option of variable arguments.

function foo($x, $y) // 2 mandatory arguments
 {
 print_r(func_get_args()); // Show all arguments.
 }

func_get_args() will return an array of arguments to the function. All
of them, not just the declared ones.



-- 
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY

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



Re: [PHP] Custom function

2011-02-15 Thread Mark Kelly
Hi.

On Tuesday 15 Feb 2011 at 23:41 Andre Polykanine wrote:

> Give it a default (possible empty) value:
>
> function MyFunction($x, $y, $z="") {
> // function goes here
> if (!empty($z)) {
> // The optional parameter is given
> }
> }

Using an empty string and the empty() function in this way can lead to subtle 
and hard to find bugs - for example if $z = 0, the code will not be executed. 
Note the list of things that are considered empty:

http://uk.php.net/manual/en/function.empty.php

Instead, consider setting the default value for $z to boolean false:

function MyFunction ($x, $y, $z = FALSE) {
  if ($z) {
// do stuff with $z
  }
}

In this way almost any value in $z will trigger the conditional code, 
including 0 or an empty string. The exceptions are FALSE and NULL. If you 
explicitly need to react to a NULL value, use is_null() to detect it. 

Cheers,

Mark

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



Re: [PHP] Finding split points in an article for inserting ads

2011-02-15 Thread David Robley
Brian Dunning wrote:

> Yes, thanks, what I'm looking for is how to do that.
> 
> On Feb 15, 2011, at 1:38 PM, Simon J Welsh wrote:
> 
>> Assuming you're only using  tags, count the number of opening 
>> tags, divide by three. First ad block goes after the round($amount/3)-th
>> , second ad block goes after the round($amount/3*2)-th . ---
>> Simon Welsh

Try substr_count ??


Cheers
-- 
David Robley

Sure, it's clean laundry. The cat's sitting on it, isn't he?
Today is Boomtime, the 47th day of Chaos in the YOLD 3177. 


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



Re: [PHP] Howdy (new in here)

2011-02-15 Thread Richard Quadling
On 15 February 2011 21:08, Steve Staples  wrote:
> Your bracing style is WRONG.  Whitesmiths Style sucks... and Allman
> Style is the best way to do it.


It's not Friday.


-- 
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY

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



Re: [PHP] Howdy (new in here)

2011-02-15 Thread Richard Quadling
On 15 February 2011 20:42, tedd  wrote:
> At 12:52 PM -0600 2/15/11, Nicholas Kell wrote:
>>
>> On Feb 15, 2011, at 11:52 AM, tedd wrote:
>>
>>  > I guess that we run in different worlds. Most of the PHP programmers I
>> know are very good.
>>>
>>
>> I have to agree with you, tedd. Most of the PHP devs that I know are also
>> quite good. But, the fact that both you and I know mostly good devs is not
>> going to change the perceived reputation of PHP harboring lousy developers.
>>
>> I also believe that the rep that PHP has, is in part to blame that PHP is
>> a first (and sometimes only) language for a lot of people. That, mixed with
>> the publishing rate of code, makes for some lousy code to be seen by all.
>
> I have yet to meet a programmer who I could not learn from. Sometimes it's
> how NOT to do something.  :-)
>
> Cheers,
>
> tedd

And it isn't always about programming. Talking to clients and
understanding what they need (not just what they say they want as
quite often, they don't know). Understanding the requirements of the
business. Basically, the programming is often the easy part.

Richard.

-- 
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY

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



Re: [PHP] Custom function

2011-02-15 Thread Andre Polykanine
Hello Ron,

Give it a default (possible empty) value:

function MyFunction($x, $y, $z="") {
// function goes here
if (!empty($z)) {
// The optional parameter is given
}
}

-- 
With best regards from Ukraine,
Andre
Skype: Francophile
My blog: http://oire.org/menelion (mostly in Russian)
Twitter: http://twitter.com/m_elensule
Facebook: http://facebook.com/menelion

 Original message 
From: Ron Piggott 
To: php-general@lists.php.net
Date created: , 1:32:16 AM
Subject: [PHP] Custom function


  
Is there a way to make an optional flag in a custom function --- 2 parameters 
required, 1 optional?  Ron

The Verse of the Day
“Encouragement from God’s Word”
http://www.TheVerseOfTheDay.info


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



Re: [PHP] Howdy (new in here)

2011-02-15 Thread Andre Polykanine
Hello David,

As   for   me,   I  use  K&R style, also. I find it the most readable,
accessible and maintainable.

-- 
With best regards from Ukraine,
Andre
Skype: Francophile
My blog: http://oire.org/menelion (mostly in Russian)
Twitter: http://twitter.com/m_elensule
Facebook: http://facebook.com/menelion

 Original message 
From: David Harkness 
To: sstap...@mnsi.net
Date created: , 12:00:52 AM
Subject: [PHP] Howdy (new in here)


  
On Tue, Feb 15, 2011 at 1:08 PM, Steve Staples  wrote:

> My personal bracing style is the Allman Style.
>

I use K&R. I started with it just as shown but as monitors increased in size
I stopped cuddling the else so it's now on its own line, aligning the if,
elseif, and else nicely. One of the developers at my company uses the
truly abominable Horstmann style which makes moving code around a serious
PITA. :(

David


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



Re: [PHP] Finding split points in an article for inserting ads

2011-02-15 Thread Brian Dunning
Yes, thanks, what I'm looking for is how to do that.

On Feb 15, 2011, at 1:38 PM, Simon J Welsh wrote:

> Assuming you're only using  tags, count the number of opening  tags, 
> divide by three. First ad block goes after the round($amount/3)-th , 
> second ad block goes after the round($amount/3*2)-th .
> ---
> Simon Welsh


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



Re: [PHP] Howdy (new in here)

2011-02-15 Thread Donovan Brooke

[snip]

This is what I show my students:

http://rebel.lcc.edu/sperlt/citw229/brace-styles.php

Cheers,

tedd



I didn't know there were names for bracing styles... but

I used the K&R Style on my last project, which I would call the Larry 
Ullman style since that is where I took it from.


However, I think on my next project, I will use "Whitesmith's Style".

The issue I had at times with the K&R style was locating the the 
matching (open or closed) brace.. as they were not on the same

character column.

Donovan



--
D Brooke

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



RE: [PHP] Howdy (new in here)

2011-02-15 Thread Jay Blanchard
[snip] Allman Style is the best way to do it. [/snip]

Only if you're playing guitar Junior. 

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



Re: [PHP] Jquery

2011-02-15 Thread David Harkness
I see firebug-lite-debug.js but not jquery.js. Does firebug include jquery?

David


Re: [PHP] Howdy (new in here)

2011-02-15 Thread Robert Cummings

On 11-02-15 04:59 PM, Brian Waters wrote:

On Tue, Feb 15, 2011 at 4:50 PM, Robert Cummings  wrote:


I started with K&R and quickly migrated to Allman style. The advantage I see
with Allman is that the braces form a visual pocket into which the
associated code gets placed :)


What about K&R for control structures, and Allman for function and
class definitions? That style is quite common.


I find a homogenous style to be most aesthetic :) Additionally, the 
pocket visualization still applies.


Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] Howdy (new in here)

2011-02-15 Thread Mujtaba Arshad
@tedd

I was interested about the reasons why people perceive php as a poor
language. I came across the following stackoverflow thread:
http://stackoverflow.com/questions/309300/defend-php-convince-me-it-isnt-horrible

The guy answering him immediately after brought up some very good rebuttals,
however, there are some really fundamental things that people have come to
expect from programming languages that php doesn't offer and this is
probably why people have issues with it.
Two in particular, that people might have issues with, were brought up:
1. method/function name insensitivity
2. inconsistent naming of built in and library functions

However, since this is an open-source project behind some of the biggest
internet based businesses, I am personally quite fond of it. I have no
issues with the language as the above two points can easily be countered
with a good IDE or a little experience.

Finally, I would like to say, if you are going to look for it, you can find
faults with any and all programming languages. It comes down to preference,
that is why you have people in the industry coding things with Java instead
of C++, or vice versa, even though the other might be better for the
application.

On Tue, Feb 15, 2011 at 4:08 PM, Steve Staples  wrote:

> On Tue, 2011-02-15 at 15:54 -0500, tedd wrote:
> > At 2:20 PM -0500 2/15/11, Mujtaba Arshad wrote:
> > >I would say all languages have their 'lousy developers', however, since
> very
> > >few schools focus on teaching the 'proper coding style' for PHP it leads
> to
> > >people learning from a variety of resources available online, and this
> leads
> > >to them receiving mixed messages from the tutorials and allowing people
> the
> > >ability to choose the method they prefer. Since there is very little
> > >syntactic consistency among the code produced by developers, it leads to
> the
> > >perception that the developers are 'lousy'.
> >
> > I don't know if I buy that or not -- I didn't learn programming in
> school.
> >
> > I learned by using rocks instead of ones. It was a few years later
> > that we created the concept of using the absence of rocks as zeros
> > and were finally able to build things other than pyramids.
> >
> > Style became a matter of choice -- it's what makes sense to you and
> > that usually works.
> >
> > For example, while it's true that Rob and I disagree on brace style,
> > there are many different types to choose from.
> >
> > This is what I show my students:
> >
> > http://rebel.lcc.edu/sperlt/citw229/brace-styles.php
> >
> > Cheers,
> >
> > tedd
> >
> > --
> > ---
> > http://sperling.com/
> >
>
> Tedd:
>
> Your bracing style is WRONG.  Whitesmiths Style sucks... and Allman
> Style is the best way to do it.
>
> :)
>
>
> My personal bracing style is the Allman Style... I've been doing it that
> way forever, it just made sense to me (even before I knew there was that
> style name... which was about 3 minutes ago).   everything lined up nice
> and neat.
>
> Steve
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Mujtaba


Re: [PHP] Rate my (really) simple template class

2011-02-15 Thread Brian Waters
On Mon, Feb 14, 2011 at 11:49 PM, Paul M Foster  wrote:
> Advice: don't use eval() this way. It's slow and dangerous.

Could you elaborate, or provide a link?

> ...read in the file and pass it to you on the stack, which is
> really an abuse of the stack if you can avoid it.

Interesting. I'm used to statically-typed languages. Normally I never
would have passed a large structure like that on the stack. But then
again, in those languages, large structures are usually passed by
reference, by default. In C, the only way to pass a string or array by
value is to wrap it in a struct, and in Java, objects are passed by
reference (if I recall correctly).

Guess that's something to get used to.

- BW

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



Re: [PHP] Howdy (new in here)

2011-02-15 Thread David Harkness
On Tue, Feb 15, 2011 at 1:08 PM, Steve Staples  wrote:

> My personal bracing style is the Allman Style.
>

I use K&R. I started with it just as shown but as monitors increased in size
I stopped cuddling the else so it's now on its own line, aligning the if,
elseif, and else nicely. One of the developers at my company uses the
truly abominable Horstmann style which makes moving code around a serious
PITA. :(

David


Re: [PHP] Howdy (new in here)

2011-02-15 Thread Robert Cummings

On 11-02-15 04:08 PM, Steve Staples wrote:

Tedd:

Your bracing style is WRONG.  Whitesmiths Style sucks... and Allman
Style is the best way to do it.

:)


My personal bracing style is the Allman Style... I've been doing it that
way forever, it just made sense to me (even before I knew there was that
style name... which was about 3 minutes ago).   everything lined up nice
and neat.

Steve


I started with K&R and quickly migrated to Allman style. The advantage I 
see with Allman is that the braces form a visual pocket into which the 
associated code gets placed :)


Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] Finding split points in an article for inserting ads

2011-02-15 Thread Robert Cummings

On 11-02-15 04:03 PM, Brian Dunning wrote:

Hey all -

I've got long articles, the HTML for which comes out of MySQL. Works great. I 
want to split it up so that I can insert ad blocks at various points within it. 
The articles are all pretty long but they're of variable length. I want to chop 
them up into three close-to-equal (doesn't have to be) chunks of paragraphs, 
thus:

Here's the original article
Here's the original article
Here's the original article
Here's the original article
Here's the original article

Would become:

Here's the original article
Here's the original article

Here's the original article
Here's the original article

Here's the original article

Any suggestions? Thanks.


I came across the following recently which I used for a project:

http://simplehtmldom.sourceforge.net/

It allows accessing HTML tags via jquery like selectors. It may help you 
to easily get at the spots you want. If your content is very uniform 
then it may not be as efficient as a quick explode and traversal.


Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] Finding split points in an article for inserting ads

2011-02-15 Thread Simon J Welsh
On 16/02/2011, at 10:03 AM, Brian Dunning wrote:

> Hey all -
> 
> I've got long articles, the HTML for which comes out of MySQL. Works great. I 
> want to split it up so that I can insert ad blocks at various points within 
> it. The articles are all pretty long but they're of variable length. I want 
> to chop them up into three close-to-equal (doesn't have to be) chunks of 
> paragraphs, thus:
> 
> Here's the original article
> Here's the original article
> Here's the original article
> Here's the original article
> Here's the original article
> 
> Would become:
> 
> Here's the original article
> Here's the original article
> 
> Here's the original article
> Here's the original article
> 
> Here's the original article
> 
> Any suggestions? Thanks.

Assuming you're only using  tags, count the number of opening  tags, 
divide by three. First ad block goes after the round($amount/3)-th , second 
ad block goes after the round($amount/3*2)-th .
---
Simon Welsh
Admin of http://simon.geek.nz/

Who said Microsoft never created a bug-free program? The blue screen never, 
ever crashes!

http://www.thinkgeek.com/brain/gimme.cgi?wid=81d520e5e


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



Re: [PHP] Howdy (new in here)

2011-02-15 Thread Steve Staples
On Tue, 2011-02-15 at 15:54 -0500, tedd wrote:
> At 2:20 PM -0500 2/15/11, Mujtaba Arshad wrote:
> >I would say all languages have their 'lousy developers', however, since very
> >few schools focus on teaching the 'proper coding style' for PHP it leads to
> >people learning from a variety of resources available online, and this leads
> >to them receiving mixed messages from the tutorials and allowing people the
> >ability to choose the method they prefer. Since there is very little
> >syntactic consistency among the code produced by developers, it leads to the
> >perception that the developers are 'lousy'.
> 
> I don't know if I buy that or not -- I didn't learn programming in school.
> 
> I learned by using rocks instead of ones. It was a few years later 
> that we created the concept of using the absence of rocks as zeros 
> and were finally able to build things other than pyramids.
> 
> Style became a matter of choice -- it's what makes sense to you and 
> that usually works.
> 
> For example, while it's true that Rob and I disagree on brace style, 
> there are many different types to choose from.
> 
> This is what I show my students:
> 
> http://rebel.lcc.edu/sperlt/citw229/brace-styles.php
> 
> Cheers,
> 
> tedd
> 
> -- 
> ---
> http://sperling.com/
> 

Tedd:

Your bracing style is WRONG.  Whitesmiths Style sucks... and Allman
Style is the best way to do it.

:)


My personal bracing style is the Allman Style... I've been doing it that
way forever, it just made sense to me (even before I knew there was that
style name... which was about 3 minutes ago).   everything lined up nice
and neat.

Steve



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



[PHP] Re: PHP -- using without installing

2011-02-15 Thread Michelle Konzack
Hello Steve Staples,

Am 2011-02-14 12:32:51, hacktest Du folgendes herunter:
> Is there such a thing?  or will I have to have a pre-req of "php and
> php-cgi must be installed on linux" disclaimer?

If you are a OVER-GEEK, youc can compile the "php"  and  "php-cli"  100%
static, which I have done some years agao with "php4" du  to  a  special
requirement

But believe it you executable will be 20 or more MByte because you  need
libc6 and other things to be compiled into!  :-D

Thanks, Greetings and nice Day/Evening
Michelle Konzack

-- 
# Debian GNU/Linux Consultant ##
   Development of Intranet and Embedded Systems with Debian GNU/Linux

itsystems@tdnet France EURL   itsystems@tdnet UG (limited liability)
Owner Michelle KonzackOwner Michelle Konzack

Apt. 917 (homeoffice)
50, rue de Soultz Kinzigstraße 17
67100 Strasbourg/France   77694 Kehl/Germany
Tel: +33-6-61925193 mobil Tel: +49-177-9351947 mobil
Tel: +33-9-52705884 fix

  
 

Jabber linux4miche...@jabber.ccc.de
ICQ#328449886

Linux-User #280138 with the Linux Counter, http://counter.li.org/


signature.pgp
Description: Digital signature


[PHP] Finding split points in an article for inserting ads

2011-02-15 Thread Brian Dunning
Hey all -

I've got long articles, the HTML for which comes out of MySQL. Works great. I 
want to split it up so that I can insert ad blocks at various points within it. 
The articles are all pretty long but they're of variable length. I want to chop 
them up into three close-to-equal (doesn't have to be) chunks of paragraphs, 
thus:

Here's the original article
Here's the original article
Here's the original article
Here's the original article
Here's the original article

Would become:

Here's the original article
Here's the original article

Here's the original article
Here's the original article

Here's the original article

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



Re: [PHP] Howdy (new in here)

2011-02-15 Thread Brian Waters
On Tue, Feb 15, 2011 at 3:37 PM, tedd  wrote:
> So, I took a *weekend* and programmed about 90 percent of application in
> FutureBasic. I then created a shell application and forwarded it to the
> client.
>
> After receiving the application, the client said "Yes, this is exactly what
> I want -- except I want it in C++".

Of course, that's a ridiculous reason to choose one language over
another. But to augment what you're saying, sometimes certain
languages are chosen because of the availability of libraries and
tools, and, more importantly, because of the availability of skilled
programmers. That's especially important if a client has to expand and
modify a solution in the future.

- BW

PS, Once again, tedd, apologies for backchanneling you...

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



Re: [PHP] Howdy (new in here)

2011-02-15 Thread tedd

At 2:20 PM -0500 2/15/11, Mujtaba Arshad wrote:

I would say all languages have their 'lousy developers', however, since very
few schools focus on teaching the 'proper coding style' for PHP it leads to
people learning from a variety of resources available online, and this leads
to them receiving mixed messages from the tutorials and allowing people the
ability to choose the method they prefer. Since there is very little
syntactic consistency among the code produced by developers, it leads to the
perception that the developers are 'lousy'.


I don't know if I buy that or not -- I didn't learn programming in school.

I learned by using rocks instead of ones. It was a few years later 
that we created the concept of using the absence of rocks as zeros 
and were finally able to build things other than pyramids.


Style became a matter of choice -- it's what makes sense to you and 
that usually works.


For example, while it's true that Rob and I disagree on brace style, 
there are many different types to choose from.


This is what I show my students:

http://rebel.lcc.edu/sperlt/citw229/brace-styles.php

Cheers,

tedd

--
---
http://sperling.com/

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



Re: [PHP] Howdy (new in here)

2011-02-15 Thread tedd

At 12:52 PM -0600 2/15/11, Nicholas Kell wrote:

On Feb 15, 2011, at 11:52 AM, tedd wrote:

 > I guess that we run in different worlds. Most of the PHP 
programmers I know are very good.




I have to agree with you, tedd. Most of the PHP devs that I know are 
also quite good. But, the fact that both you and I know mostly good 
devs is not going to change the perceived reputation of PHP 
harboring lousy developers.


I also believe that the rep that PHP has, is in part to blame that 
PHP is a first (and sometimes only) language for a lot of people. 
That, mixed with the publishing rate of code, makes for some lousy 
code to be seen by all.


I have yet to meet a programmer who I could not learn from. Sometimes 
it's how NOT to do something.  :-)


Cheers,

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

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



Re: [PHP] Howdy (new in here)

2011-02-15 Thread tedd

At 2:03 PM -0500 2/15/11, Brian Waters wrote:

On Tue, Feb 15, 2011 at 12:52 PM, tedd  wrote:

 > I guess that we run in different worlds. Most of the PHP programmers I know

 are very good.


I didn't mean to suggest anything. Nor do I necessarily subscribe to
the idea (that PHP has some lousy developers). It's just something
I've heard bouncing around - probably on those noisy internet forums.

- BW


- BW:

I think what you may be finding is there is an element within the 
programming industry that if you are to be considered a "true" 
developer you must program in [insert what language you use] and on 
[insert what platform you use].


Realize that we program in an open source language competing with a 
closed M$ environment -- and that generates a lot of biased 
self-interested rhetoric. Not all, but enough non-PHP programmers 
bad-mouth PHP because they want the perceptions of "true" programmers 
to be what they are.


I remember one time when I was hired to do a Macintosh application 
where the client insisted on using Metrowerks Code Warrior C++. After 
three months working with two other developers on what I thought was 
a very simple project, I found that we had not moved very far at all. 
People were arguing about double inheritance and other such tech 
stuff.


So, I took a *weekend* and programmed about 90 percent of application 
in FutureBasic. I then created a shell application and forwarded it 
to the client.


After receiving the application, the client said "Yes, this is 
exactly what I want -- except I want it in C++".


When I asked "Why? The application works and I can finish it up in a 
week!" He replied he had friends who worked at Metrowerks and if he 
told them his application had been created in FutureBasic, they would 
laugh at him.


Shortly after I quit the project.

Quite often perceptions are stronger than reality.

Cheers,

tedd

--
---
http://sperling.com/

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



Re: [PHP] Displaying Results

2011-02-15 Thread Peter Lind
On 15 February 2011 20:28, Ethan Rosenberg  wrote:
> Dear List -
>
>  I have a form.  In one field, the customer types the name of a product.
>  The first seven(7) results of the MySQL query that the entry generates
> should be displayed as a clickable drop down list.
>
> How do I do it?

Ask google you should
Plenty of advice you'll find
we won't do your homework

Regards
Peter

-- 

WWW: plphp.dk / plind.dk
LinkedIn: plind
BeWelcome/Couchsurfing: Fake51
Twitter: kafe15


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



[PHP] Displaying Results

2011-02-15 Thread Ethan Rosenberg

Dear List -

 I have a form.  In one field, the customer types the name of a 
product.  The first seven(7) results of the MySQL query that the 
entry generates should be displayed as a clickable drop down list.


How do I do it?

Thanks.

Ethan

MySQL 5.1  PHP 5.3.3-6  Linux [Debian (sid)] 




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



Re: [PHP] Howdy (new in here)

2011-02-15 Thread Nicholas Kell

On Feb 15, 2011, at 1:20 PM, Mujtaba Arshad wrote:

> I would say all languages have their 'lousy developers', however, since very
> few schools focus on teaching the 'proper coding style' for PHP it leads to
> people learning from a variety of resources available online, and this leads
> to them receiving mixed messages from the tutorials and allowing people the
> ability to choose the method they prefer. Since there is very little
> syntactic consistency among the code produced by developers, it leads to the
> perception that the developers are 'lousy'.
> 

+1, I fully agree.


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



Re: [PHP] Howdy (new in here)

2011-02-15 Thread Mujtaba Arshad
I would say all languages have their 'lousy developers', however, since very
few schools focus on teaching the 'proper coding style' for PHP it leads to
people learning from a variety of resources available online, and this leads
to them receiving mixed messages from the tutorials and allowing people the
ability to choose the method they prefer. Since there is very little
syntactic consistency among the code produced by developers, it leads to the
perception that the developers are 'lousy'.

On Tue, Feb 15, 2011 at 2:03 PM, Brian Waters wrote:

> On Tue, Feb 15, 2011 at 12:52 PM, tedd  wrote:
> > At 11:37 AM -0600 2/15/11, Nicholas Kell wrote:
> >>
> >> On Feb 15, 2011, at 10:51 AM, tedd wrote:
> >>  > At 8:26 PM -0500 2/14/11, Brian Waters wrote:
> >>  >> (if that's OK). I know that PHP sometimes has a reputation for
> having
> >>  >> (some) lousy developers, and I'd like to avoid becoming one of those
> >>  >
> >>  > We don't agree that PHP has a reputation of having some lousy
> >> developers -- because that's simply not true.
> >>
> >> Humm I seem to agree with the OP. But, that being said, unlike most
> >> language fanboys PHP'ers usually fully admit it.
> >
> >
> > I guess that we run in different worlds. Most of the PHP programmers I
> know
> > are very good.
>
> I didn't mean to suggest anything. Nor do I necessarily subscribe to
> the idea (that PHP has some lousy developers). It's just something
> I've heard bouncing around - probably on those noisy internet forums.
>
> - BW
>
> P.S:
>
> On Tue, Feb 15, 2011 at 11:51 AM, tedd  wrote:
> > PS: We seldom point out spelling errors, but it's good to review what you
> > post. Remember, what you post will be public for generations to come.
>
> I'm aware that I misspelled "viciously" in my original post but was
> too lazy to rectify the situation.
>
> P.P.S, Apologies for backchanneling tedd there; I'm used to mailing
> lists with a default Reply-To: t...@mailinglist.com header.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Mujtaba


Re: [PHP] Howdy (new in here)

2011-02-15 Thread Brian Waters
On Tue, Feb 15, 2011 at 12:52 PM, tedd  wrote:
> At 11:37 AM -0600 2/15/11, Nicholas Kell wrote:
>>
>> On Feb 15, 2011, at 10:51 AM, tedd wrote:
>>  > At 8:26 PM -0500 2/14/11, Brian Waters wrote:
>>  >> (if that's OK). I know that PHP sometimes has a reputation for having
>>  >> (some) lousy developers, and I'd like to avoid becoming one of those
>>  >
>>  > We don't agree that PHP has a reputation of having some lousy
>> developers -- because that's simply not true.
>>
>> Humm I seem to agree with the OP. But, that being said, unlike most
>> language fanboys PHP'ers usually fully admit it.
>
>
> I guess that we run in different worlds. Most of the PHP programmers I know
> are very good.

I didn't mean to suggest anything. Nor do I necessarily subscribe to
the idea (that PHP has some lousy developers). It's just something
I've heard bouncing around - probably on those noisy internet forums.

- BW

P.S:

On Tue, Feb 15, 2011 at 11:51 AM, tedd  wrote:
> PS: We seldom point out spelling errors, but it's good to review what you
> post. Remember, what you post will be public for generations to come.

I'm aware that I misspelled "viciously" in my original post but was
too lazy to rectify the situation.

P.P.S, Apologies for backchanneling tedd there; I'm used to mailing
lists with a default Reply-To: t...@mailinglist.com header.

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



Re: [PHP] Howdy (new in here)

2011-02-15 Thread Nicholas Kell

On Feb 15, 2011, at 11:52 AM, tedd wrote:

> At 11:37 AM -0600 2/15/11, Nicholas Kell wrote:
>> On Feb 15, 2011, at 10:51 AM, tedd wrote:
>> > At 8:26 PM -0500 2/14/11, Brian Waters wrote:
>> >> (if that's OK). I know that PHP sometimes has a reputation for having
>> >> (some) lousy developers, and I'd like to avoid becoming one of those
>> >
>> > We don't agree that PHP has a reputation of having some lousy developers 
>> > -- because that's simply not true.
>> 
>> Humm I seem to agree with the OP. But, that being said, unlike most 
>> language fanboys PHP'ers usually fully admit it.
> 
> 
> I guess that we run in different worlds. Most of the PHP programmers I know 
> are very good.
> 

I have to agree with you, tedd. Most of the PHP devs that I know are also quite 
good. But, the fact that both you and I know mostly good devs is not going to 
change the perceived reputation of PHP harboring lousy developers.

I also believe that the rep that PHP has, is in part to blame that PHP is a 
first (and sometimes only) language for a lot of people. That, mixed with the 
publishing rate of code, makes for some lousy code to be seen by all.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Mysql 5.5 and PHP Mysql API Version 5.1.41

2011-02-15 Thread Matthias Laug
Hey there,

I've just migrated to Mysql 5.5 from source and it works like a charm. Still 
every now and then (in intervals of approximatly an hour) I get the following 
error:

Error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] [2013] 
Lost connection to MySQL server at 'reading initial communication packet', 
system error: 110' in 
/home/ydadmin/build/lieferando.de/11720/library/Zend/Db/Adapter/Pdo/Abstract.php:129
 Stack trace: #0 
/home/ydadmin/build/lieferando.de/11720/library/Zend/Db/Adapter/Pdo/Abstract.php(129):
 PDO->__construct('mysql:port=6664...', '#', '#', Array) #1 
/home/ydadmin/build/lieferando.de/11720/library/Zend/Db/Adapter/Pdo/Mysql.php(96):
 Zend_Db_Adapter_Pdo_Abstract->_connect() #2 
/home/ydadmin/build/lieferando.de/11720/library/Zend/Db/Adapter/Abstract.php(448):
 Zend_Db_Adapter_Pdo_Mysql->_connect() #3 
/home/ydadmin/build/lieferando.de/11720/library/Zend/Db/Adapter/Pdo/Abstract.php(238):
 Zend_Db_Adapter_Abstract->query('SET NAMES 'utf8...', Array) #4 
/home/ydadmin/build/lieferando.de/11720/application/Bootstrap.php(99): 
Zend_Db_Adapter_Pdo_Abstract->query('SET NAMES 'utf8...') #5 
/home/ydadmin/build/lieferando.de/11720/library/Zend/App in 
/home/ydadmin/build/lieferando.de/11720/library/Zend/Db/Adapter/Pdo/Abstract.php
 on line 144

It is like any queue is running full and this is the result, but actually no 
clue. My first guess is the API Version of the mysql client I am using with the 
precompiled php binaries (Ubuntu 10.10 Server, PHP 5.3.2-1ubuntu4.7 with 
Suhosin-Patch (cli) (built: Jan 12 2011 18:36:55))

Does anyone else have the same problems?

Thanks for any help,
Matthias
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Howdy (new in here)

2011-02-15 Thread tedd

At 11:37 AM -0600 2/15/11, Nicholas Kell wrote:

On Feb 15, 2011, at 10:51 AM, tedd wrote:
 > At 8:26 PM -0500 2/14/11, Brian Waters wrote:
 >> (if that's OK). I know that PHP sometimes has a reputation for having
 >> (some) lousy developers, and I'd like to avoid becoming one of those
 >
 > We don't agree that PHP has a reputation of having some lousy 
developers -- because that's simply not true.


Humm I seem to agree with the OP. But, that being said, unlike 
most language fanboys PHP'ers usually fully admit it.



I guess that we run in different worlds. Most of the PHP programmers 
I know are very good.


Cheers,

tedd

--
---
http://sperling.com/

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



Re: [PHP] Howdy (new in here)

2011-02-15 Thread tedd
Welcome to the list, Brian. I'm fairly new to PHP and the list 
myself, and I've found it to be a great resource. Another is 
stackoverflow.com, especially for "How do 
I do X?" type questions. I often find someone else has already 
provided an answer.


On Tue, Feb 15, 2011 at 8:51 AM, tedd 
<tedd.sperl...@gmail.com> wrote:


PS: We seldom point out spelling errors.
---
http://sperling.com/


I've been meaning to tell you for a while . . . your URL is misspelled.

Oh wait, it's not Friday. My apologies. :)

David


David:

No, that's German for Sparrow -- and it's spelled correctly. Besides, 
that's my logo.


In any event, I'll take up your comments with my ancestors some day.

Cheers,

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

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



Re: [PHP] Howdy (new in here)

2011-02-15 Thread Nicholas Kell

On Feb 15, 2011, at 10:51 AM, tedd wrote:

> At 8:26 PM -0500 2/14/11, Brian Waters wrote:
>> Hi everyone! I'm just starting out with PHP so I'm looking for a good
>> place to ask some questions, have my code critiqued (read: visciously
>> ripped apart), and generally BS about PHP and programming in general
>> (if that's OK). I know that PHP sometimes has a reputation for having
>> (some) lousy developers, and I'd like to avoid becoming one of those
>> people. To that end, I've subscribed here because I've always found
>> mailing lists to have much higher-quality discourse than the average
>> online foum.
>> 
>> Looking forward to participating!
>> 
>> - BW
> 
> -BW:
> 
> 
[/snip]
> 
> We don't agree that PHP has a reputation of having some lousy developers -- 
> because that's simply not true.
> 


Humm I seem to agree with the OP. But, that being said, unlike most 
language fanboys PHP'ers usually fully admit it.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] using BOTH GET and POST in the same page.

2011-02-15 Thread tedd

At 4:32 PM -0500 2/14/11, Paul M Foster wrote:


Understood. It sounded like you were saying you could only get back POST
or GET values from a page, which isn't true. The form itself, yes, can
only have one or the other method attribute.


What it sounded like was:


What others have not addressed is that the form used to send
variables will send only GET OR POST method variables, but not both
at the same time.


I still stand by that statement. A form can only send variables 
through the method stated in the form.


The "action" value of the form is not data provided by a POST-method 
form -- it simply uses the address provided by the coder. If you want 
to add GET data to the action value, then that's your call, but the 
POST method form will do nothing to the action value data. However, a 
GET-method form will change the action value.


Try this as an experiment. Use a GET form with the action value 
containing get type data (?id=1234) and see what happens to that data.


If you do, then you'll have a better idea of what you can/can't do with a form.

Cheers,

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

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



[PHP] Howdy (new in here)

2011-02-15 Thread Daniel Brown
Back to the list for Kirk ;-P

-- Forwarded message --
From: Kirk Bailey 
Date: Tue, Feb 15, 2011 at 12:09
Subject: Re: [PHP] Howdy (new in here)
To: Daniel Brown 




On 2/15/2011 10:03 AM, Daniel Brown wrote:
>
> On Mon, Feb 14, 2011 at 20:26, Brian Waters  wrote:
>>
>> Hi everyone! I'm just starting out with PHP so I'm looking for a good
>> place to ask some questions, have my code critiqued (read: visciously
>> ripped apart),

Lovingly and gently uncompiled, critiqued, and altered?
>>
>>  and generally BS about PHP and programming in general
>> (if that's OK).

BS makes the grass grow green.
>>
>>  I know that PHP sometimes has a reputation for having
>> (some) lousy developers,

That's me! :-D
>>
>> and I'd like to avoid becoming one of those
>> people. To that end, I've subscribed here because I've always found
>> mailing lists to have much higher-quality discourse than the average
>> online foum.

It's the best one I have found since I tripped over the python TUTOR list.
This list has a pleasant intelligent community willing to help and to
share methods.
>>
>> Looking forward to participating!
>
>     Welcome aboard, Bri.
>
>> P.S, The rules page on the web
>> (http://us2.php.net/reST/php-src/README.MAILINGLIST_RULES) is
>> currently broken, but this one works:
>> http://us2.php.net/reST/php-src/trunk_README.MAILINGLIST_RULES. Just a
>> heads up to whoever is in charge of that.
>
>     Duly-noted.  Thank you, sir.
>

--
end

Very Truly yours,
                - Kirk Bailey,
                  Largo Florida

                      kniht
                     +-+
                     | BOX |
                     +-+
                      think




-- 

Network Infrastructure Manager
Documentation, Webmaster Teams
http://www.php.net/

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



Re: [PHP] Howdy (new in here)

2011-02-15 Thread David Harkness
Welcome to the list, Brian. I'm fairly new to PHP and the list myself, and
I've found it to be a great resource. Another is stackoverflow.com,
especially for "How do I do X?" type questions. I often find someone else
has already provided an answer.

On Tue, Feb 15, 2011 at 8:51 AM, tedd  wrote:

> PS: We seldom point out spelling errors.
> ---
> http://sperling.com/


I've been meaning to tell you for a while . . . your URL is misspelled.

Oh wait, it's not Friday. My apologies. :)

David


[PHP] Re:[PHP] code quest

2011-02-15 Thread Kirk Bailey
Frankly, while that modulo looks like something worthy of learning, 
for my immediate time critical need I went with a quicker method, 
which is working. The complete script is below. It simply counts 
cells and resets the row when a number is exceeded.

# The next several lines declare an array of directories which are 
NOT to be listed!#

$excludes[] = 'attachments'; #20
$excludes[] = 'data';
$excludes[] = 'include';
$excludes[] = 'resources';
$excludes[] = 'stats';
$excludes[] = '_private';
$excludes[] = '_vti_bin';
$excludes[] = '_vti_cnf';
$excludes[] = '_vti_log';
$excludes[] = '_vti_pvt';
$excludes[] = '_vti_txt'; #30
$excludes[] = '_vxi_txt';
$excludes[] = 'css';
$excludes[] = 'img';
$excludes[] = 'images';
$excludes[] = 'js';
$excludes[] = 'cgi';
$excludes[] = 'cgi-bin';
$excludes[] = 'ssfm';
$ls = scandir(dirname(__FILE__));
$counter=0; #40
echo 'bgcolor="F0F0F0">';
foreach ($ls as $d) {  if (is_dir($d) && 
!preg_match('/^\./',basename($d)) &&!in_array(basename($d),$excludes))

 {
  ++$counter ;
  echo ''.$d.'href="'.$d.'">';
  echo 'border="5">';

  include($d."/desc.txt");
  echo '';
  if ($counter > 3)
{
echo ''; #50
$counter=0;
}
  };
};
echo '';
?>

--
end

Very Truly yours,
 - Kirk Bailey,
   Largo Florida

   kniht
  +-+
  | BOX |
  +-+
   think


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



Re: [PHP] Howdy (new in here)

2011-02-15 Thread tedd

At 8:26 PM -0500 2/14/11, Brian Waters wrote:

Hi everyone! I'm just starting out with PHP so I'm looking for a good
place to ask some questions, have my code critiqued (read: visciously
ripped apart), and generally BS about PHP and programming in general
(if that's OK). I know that PHP sometimes has a reputation for having
(some) lousy developers, and I'd like to avoid becoming one of those
people. To that end, I've subscribed here because I've always found
mailing lists to have much higher-quality discourse than the average
online foum.

Looking forward to participating!

- BW


-BW:

Welcome to the list.  A few points:

We seldom "viciously rip apart" code.

We won't write code for you -- unless it's interesting to us.

We don't usually critique code -- because usually there's too much 
code presented when people try to go that route.


We don't agree that PHP has a reputation of having some lousy 
developers -- because that's simply not true.


We (or at least I do) agree that mailing lists have higher-quality 
discourse than other mediums (i.e., forums, books, web sites) -- 
because what is published on this list is immediately reviewed by 
very smart people using their experience and current technology to 
backup their position.


So after all is said, what we do is to give you our best guess at 
what needs to be addressed in the problem you present.


Cheers,

tedd

PS: We seldom point out spelling errors, but it's good to review what 
you post. Remember, what you post will be public for generations to 
come.

--
---
http://sperling.com/

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



Re: [PHP] Howdy (new in here)

2011-02-15 Thread Daniel Brown
On Mon, Feb 14, 2011 at 20:26, Brian Waters  wrote:
> Hi everyone! I'm just starting out with PHP so I'm looking for a good
> place to ask some questions, have my code critiqued (read: visciously
> ripped apart), and generally BS about PHP and programming in general
> (if that's OK). I know that PHP sometimes has a reputation for having
> (some) lousy developers, and I'd like to avoid becoming one of those
> people. To that end, I've subscribed here because I've always found
> mailing lists to have much higher-quality discourse than the average
> online foum.
>
> Looking forward to participating!

Welcome aboard, Bri.

> P.S, The rules page on the web
> (http://us2.php.net/reST/php-src/README.MAILINGLIST_RULES) is
> currently broken, but this one works:
> http://us2.php.net/reST/php-src/trunk_README.MAILINGLIST_RULES. Just a
> heads up to whoever is in charge of that.

Duly-noted.  Thank you, sir.

-- 

Network Infrastructure Manager
Documentation, Webmaster Teams
http://www.php.net/

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



Re: [PHP] 2 submit buttons.

2011-02-15 Thread Steve Staples
On Tue, 2011-02-15 at 08:07 -0500, Floyd Resler wrote:
> On Feb 14, 2011, at 5:24 PM, Paul M Foster wrote:
> 
> > On Mon, Feb 14, 2011 at 05:15:11PM -0500, Floyd Resler wrote:
> > 
> >> 
> >> On Feb 14, 2011, at 4:18 PM, Paul M Foster wrote:
> >> 
> >>> On Mon, Feb 14, 2011 at 03:35:02PM -0400, Paul Halliday wrote:
> >>> 
>  I have 2 buttons on a page:
>  
>  if (isset($_POST['botton1'])) {dothing1();} if
>  (isset($_POST['button2'])) {dothing2();}
>  
>  They both work as intended when I click on them. If however I click
>  within a text box and hit enter, they both fire.
>  
>  Is there a way to stop this?
> >>> 
> >>> Check your code. My experience has been that forms with multiple
> >>> submits will fire the *first* submit in the form when you hit Enter
> >>> in a text field or whatever. I just tested this and found it to be
> >>> true.
> >>> 
> >>> Now, I'm doing this in Firefox on Linux. I suppose there could be
> >>> differences among browsers, but I suspect that the specs for HTML
> >>> mandate the behavior I describe.
> >>> 
> >>> Paul
> >>> 
> >> 
> >> If you don't mind using a little JavaScript you can test for which
> >> button should fire when enter is pressed.  How I would do it is to
> >> first add a hidden field and call it "buttonClicked".  Now, in the
> >> text field where you would like a button to fire if enter is pressed,
> >> at this to the tag: onkeyup="checkKey(this,event)".  For the
> >> JavaScript portion of it, do this:
> > 
> > Yeah, but you don't even have to go that far. Just put a print_r($_POST)
> > at the beginning of the file, and you'll see which button gets pressed.
> > It will show up in the POST array.
> > 
> > Paul
> > 
> > -- 
> 
> Yeah, except that the original question was about controlling which button 
> fires when the enter key is pressed. :)
> 
> Thanks!
> Floyd
> 
> 

I think if you have more than 1 submit button, then you need to disable
the "enter to submit" functionality.  This would force people/users to
click on either of the submit buttons...

Or better yet, if you have a "default" submit button, have a hidden text
value with your default submit value, and then on the submit "onclick"
event of the other submit button, replace the text value of the hidden
field to something else.   Then finally in your postback check, check
the value of the hidden field to determine what you're going to do.

Personally, I do a combination of both.  I disable the ability to submit
on key press, and require you to submit via my submit methods, and
onclick of the submit button sets a value to the hidden text field, and
then do a switch() case:... on that hidden value.   But that is my way
of doing it (which will prolly get ripped apart by someone here, which
is good/constructive criticism for me)

steve


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



Re: [PHP] 2 submit buttons.

2011-02-15 Thread Floyd Resler

On Feb 14, 2011, at 5:24 PM, Paul M Foster wrote:

> On Mon, Feb 14, 2011 at 05:15:11PM -0500, Floyd Resler wrote:
> 
>> 
>> On Feb 14, 2011, at 4:18 PM, Paul M Foster wrote:
>> 
>>> On Mon, Feb 14, 2011 at 03:35:02PM -0400, Paul Halliday wrote:
>>> 
 I have 2 buttons on a page:
 
 if (isset($_POST['botton1'])) {dothing1();} if
 (isset($_POST['button2'])) {dothing2();}
 
 They both work as intended when I click on them. If however I click
 within a text box and hit enter, they both fire.
 
 Is there a way to stop this?
>>> 
>>> Check your code. My experience has been that forms with multiple
>>> submits will fire the *first* submit in the form when you hit Enter
>>> in a text field or whatever. I just tested this and found it to be
>>> true.
>>> 
>>> Now, I'm doing this in Firefox on Linux. I suppose there could be
>>> differences among browsers, but I suspect that the specs for HTML
>>> mandate the behavior I describe.
>>> 
>>> Paul
>>> 
>> 
>> If you don't mind using a little JavaScript you can test for which
>> button should fire when enter is pressed.  How I would do it is to
>> first add a hidden field and call it "buttonClicked".  Now, in the
>> text field where you would like a button to fire if enter is pressed,
>> at this to the tag: onkeyup="checkKey(this,event)".  For the
>> JavaScript portion of it, do this:
> 
> Yeah, but you don't even have to go that far. Just put a print_r($_POST)
> at the beginning of the file, and you'll see which button gets pressed.
> It will show up in the POST array.
> 
> Paul
> 
> -- 

Yeah, except that the original question was about controlling which button 
fires when the enter key is pressed. :)

Thanks!
Floyd


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



Re: [PHP] Correct file permissions for a website

2011-02-15 Thread Camilo Sperberg
On Tue, Feb 15, 2011 at 08:35, Ashim Kapoor  wrote:

> Dear All,
>
> The book PHP and MySQL bible says that the php directory should be world
> executable  ? I remember posting a different question earlier to this list
> and one person suggesting this and another person replying that that was
> incorrect.
>
> Could someone clear the smoke on this one ?
>
> Many thanks,
> Ashim.
>

I would say that depends on your server configuration. If you have suPHP,
the user executing PHP will be yourself, so 744 isn't needed and you can
just leave 700. (Or less, configuration files are usually 400, just read
access).

If the user is Apache (and Apache is in the same group you are), he will
need to read your files, so you should at least have 740 and also he will
need execution rights on the directory which will result in 750. If apache
isn't in the same group you are (most probably scenario) you will need 755.
Strictly speaking, it should be 705.

Greetings.

-- 
Mailed by:
UnReAl4U - unreal4u
ICQ #: 54472056
www1: http://www.chw.net/
www2: http://unreal4u.com/


[PHP] Correct file permissions for a website

2011-02-15 Thread Ashim Kapoor
Dear All,

The book PHP and MySQL bible says that the php directory should be world
executable  ? I remember posting a different question earlier to this list
and one person suggesting this and another person replying that that was
incorrect.

Could someone clear the smoke on this one ?

Many thanks,
Ashim.