Re: [PHP] Friday morning brain farts....

2007-08-13 Thread tedd

At 12:10 PM +0200 8/13/07, Tijnema wrote:

On 8/13/07, tedd <[EMAIL PROTECTED]> wrote:
But, if I see this:
 >

 if(!isset($argv[1],$argv[2],$argv[3])))

 My first thought is "Is this OR or AND"? And my second thought is "If
 this is OR, then what's AND?"

 Being dyslexic I'm easily confused that way (seriously, that's the
 reason I never use an else-if).

 Cheers,

 tedd


Well, actually,
if(!isset($argv[1],$argv[2],$argv[3])))
is AND.
As it is the same as this:
if( ! ( isset($argv[1]) && isset($argv[2]) && isset($argv[3]) ) )
Which most of us write
if (!isset($argv[1]) || !isset($argv[2]) || !isset($argv[3]))

All three have the same result ;)


Could be for most of you, but that would still be a stumbling block 
for me. However, I can always find a way that works.


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] Friday morning brain farts....

2007-08-13 Thread Tijnema
On 8/13/07, tedd <[EMAIL PROTECTED]> wrote:
> At 4:54 PM +0200 8/11/07, Tijnema wrote:
> >On 8/11/07, tedd <[EMAIL PROTECTED]> wrote:
> >>  At 7:21 PM +0200 8/10/07, Tijnema wrote:
> >>  >On 8/10/07, Robert Cummings <[EMAIL PROTECTED]> wrote:
> >>  >
> >  > >  > if( !isset( $argv[1] ) || !isset( $argv[2] ) || !isset( $argv[3] ) )
> >>  >
> >  > >if(!isset($argv[1],$argv[2],$argv[3])) // Bit shorter ;)
> >>
> >>  But a bit harder to recognize IMO. :-)
> >>
> >>  Cheers,
> >>
> >>  tedd
> >>  --
> >
> >But less confusing :)
>
> Perhaps for you boy wonder, but for us old farts (or at least me)
> it's a bit more confusing.
>
> I'm going to show my ignorance now -- if I see this:
>
> if( !isset( $argv[1] ) || !isset( $argv[2] ) || !isset( $argv[3] ) )
>
> or this
>
> if( !isset( $argv[1] ) && !isset( $argv[2] ) && !isset( $argv[3] ) )
>
> Then I understand what that means.
>
> But, if I see this:
>
> if(!isset($argv[1],$argv[2],$argv[3])))
>
> My first thought is "Is this OR or AND"? And my second thought is "If
> this is OR, then what's AND?"
>
> Being dyslexic I'm easily confused that way (seriously, that's the
> reason I never use an else-if).
>
> Cheers,
>
> tedd

Well, actually,
if(!isset($argv[1],$argv[2],$argv[3])))
is AND.
As it is the same as this:
if( ! ( isset($argv[1]) && isset($argv[2]) && isset($argv[3]) ) )
Which most of us write
if (!isset($argv[1]) || !isset($argv[2]) || !isset($argv[3]))

All three have the same result ;)

Tijnema
-- 
Vote for PHP Color Coding in Gmail! -> http://gpcc.tijnema.info

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



Re: [PHP] Friday morning brain farts....

2007-08-12 Thread tedd

At 4:54 PM +0200 8/11/07, Tijnema wrote:

On 8/11/07, tedd <[EMAIL PROTECTED]> wrote:

 At 7:21 PM +0200 8/10/07, Tijnema wrote:
 >On 8/10/07, Robert Cummings <[EMAIL PROTECTED]> wrote:
 >

 > >  > if( !isset( $argv[1] ) || !isset( $argv[2] ) || !isset( $argv[3] ) )

 >

 > >if(!isset($argv[1],$argv[2],$argv[3])) // Bit shorter ;)


 But a bit harder to recognize IMO. :-)

 Cheers,

 tedd
 --


But less confusing :)


Perhaps for you boy wonder, but for us old farts (or at least me) 
it's a bit more confusing.


I'm going to show my ignorance now -- if I see this:

if( !isset( $argv[1] ) || !isset( $argv[2] ) || !isset( $argv[3] ) )

or this

if( !isset( $argv[1] ) && !isset( $argv[2] ) && !isset( $argv[3] ) )

Then I understand what that means.

But, if I see this:

if(!isset($argv[1],$argv[2],$argv[3])))

My first thought is "Is this OR or AND"? And my second thought is "If 
this is OR, then what's AND?"


Being dyslexic I'm easily confused that way (seriously, that's the 
reason I never use an else-if).


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] Friday morning brain farts....

2007-08-11 Thread Tijnema
On 8/11/07, tedd <[EMAIL PROTECTED]> wrote:
> At 7:21 PM +0200 8/10/07, Tijnema wrote:
> >On 8/10/07, Robert Cummings <[EMAIL PROTECTED]> wrote:
> >
> >  > if( !isset( $argv[1] ) || !isset( $argv[2] ) || !isset( $argv[3] ) )
> >
> >if(!isset($argv[1],$argv[2],$argv[3])) // Bit shorter ;)
>
> But a bit harder to recognize IMO. :-)
>
> Cheers,
>
> tedd
> --

But less confusing :)

When I started PHP, I stumbled over this pice of code:
if(!isset($get['a']) && !isset($get['b']) && !isset($get['c']))

if I had used this:
if(!isset($get['a'],$get['b'],$get['c']))
it would have been correct :)

After looking at it for about an hour (LOL), I figured out I needed to
change it to:
if(!isset($get['a']) || !isset($get['b']) || !isset($get['c']))

Tijnema

-- 
Vote for PHP Color Coding in Gmail! -> http://gpcc.tijnema.info

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



Re: [PHP] Friday morning brain farts....

2007-08-11 Thread tedd

At 7:21 PM +0200 8/10/07, Tijnema wrote:

On 8/10/07, Robert Cummings <[EMAIL PROTECTED]> wrote:

 > if( !isset( $argv[1] ) || !isset( $argv[2] ) || !isset( $argv[3] ) )

if(!isset($argv[1],$argv[2],$argv[3])) // Bit shorter ;)


But a bit harder to recognize IMO. :-)

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] Friday morning brain farts....

2007-08-11 Thread tedd

At 11:00 AM -0400 8/10/07, Robert Cummings wrote:

On Fri, 2007-08-10 at 10:43 -0400, Jason Pruim wrote:

 Hi All :)

 Hope you're not getting sick of my questions as of late, but I keep 
 getting closer and closer and thank you all who have helped me in the 
 past! "The only reason I can see this far is I am standing on the 
 shoulders of giants" don't know who said that but I like it :)


http://en.wikipedia.org/wiki/Stand_on_the_shoulders_of_giants

Cheers,
Rob.


Yeah, but when I do that I always fall 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] Friday morning brain farts....

2007-08-10 Thread Richard Lynch
On Fri, August 10, 2007 10:43 am, Robert Cummings wrote:
> On Fri, 2007-08-10 at 11:40 -0400, Daniel Brown wrote:
>> On 8/10/07, Stut <[EMAIL PROTECTED]> wrote:
>> > If PHP thinks something might be wrong it will tell you. Why on
>> earth
>> > would you want to ignore it? You think you're smarter than PHP?
>> Really?
>>
>> Okay, Stut, let's not make Friday the official "Flame Dan Brown"
>> holiday this week.  I vote that it should be later in the year.
>>
>> However, it should also be noted that my development is never
>> done
>> on a production server attached to the Internet, for one; and on my
>> development machine, E_NOTICE is always enabled.  I just fail to see
>> the benefit in alerting visitors to the site that there may have
>> been
>> something overlooked at some point.
>
> Why would it alert visitors? You don't have display errors set to on
> for
> a production server do you? *EK*. Send it to a log file. The
> reason it's good to enable notices on a production server is because
> your visitors are like a horde of testers, they'll probably hit every
> nook and cranny of your code that you might have missed during
> testing.

There are a few billion Google pages that show that way too many web
developers have display_errors "ON".

I'd STILL say they're better off with E_NOTICE!

If they're not bright enough to set things up with errors going to log
files, they're DEFINITELY not bright enough to write code without
E_NOTICE turned on. :-)

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] Friday morning brain farts....

2007-08-10 Thread Richard Lynch
On Fri, August 10, 2007 10:18 am, Daniel Brown wrote:
> So you're all going to tell me that you have E_NOTICE set to
> report on your sites?

Damn right I do!

That's the FIRST thing I change on any new development site, anywhere,
anytime.

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] Friday morning brain farts....

2007-08-10 Thread Richard Lynch
On Fri, August 10, 2007 10:00 am, Daniel Brown wrote:
> It's safe to ignore the `Undefined index` notices.  That will just
> appear if a variable is referenced without first being instantiated or
> defined.  No biggie, just put this at the head of your code:
>
> ini_set("error_reporting",E_ALL & ~E_NOTICE);

PLEASE DO NOT DO THIS!!!

Ignoring Undefined index notices will, sooner or later, waste your
time because you'll be trying to find a bug CAUSED by a typo that is
blatantly obvious if you pay attention -- but you'll waste days, maybe
weeks, trying to figure out what went wrong where.

Not to mention that there are a lot of OTHER E_NOTICE messages that
are more serious than "Undefined index"

Fixing your code is always a better option than ignoring error
messages about your code.

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] Friday morning brain farts....

2007-08-10 Thread Richard Lynch
On Fri, August 10, 2007 9:43 am, Jason Pruim wrote:
> I want to be able to sort that info so my sql query looks like:
> "Select * from current order by '$order';" and $order is populated by
> a GET when they click on a link: "Sort
> by last name"  Now... the whole PHP page is being included in
> a .shtml page to actually display it and make it look purrdee :)

You probably don't want to slap the '$order' into your query for two
reasons:
#1. If $order comes directly from the GET (or POST or COOKIE) data,
then it's untrusted, and should be filtered to be SURE it's not Evil.
#2. Assuming you want to order by some kind of column name, you don't
want the apostrophes on it.

> How do I get it to resort the info and include the new sort on the
> page?
>
> I'm not sure if this has anything to do with it but:
>
> $order = $_GET['order']; <--Line 6
>
> [Fri Aug 10 10:42:04 2007] [error] PHP Notice:  Undefined index:
> order in /Volumes/RAIDer/webserver/Documents/tests/legion/index.php
> on line 6

//default to lastname order:
$order = isset($_GET['order']) ? $_GET['order'] : 'lastname';

> Any help will be greatly appreciated.. And if it solves the problem
> I'll name some of my kids* after you!

I'd be happier if you spent some time reading this:
http://phpsec.org

and then filtered your $order so that you KNOW it's valid:

switch($order){
  case 'lastname':
  case 'firstname':
  case 'age':
  case 'gender':
//pass through valid $order
  break;
  default:
error_log("Attempted hack of order: $order");
die("Invalid Sort Option");
  break;
}

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] Friday morning brain farts....

2007-08-10 Thread Robert Cummings
On Fri, 2007-08-10 at 19:49 +0200, Tijnema wrote:
> On 8/10/07, Robert Cummings <[EMAIL PROTECTED]> wrote:
> >
> > I always forget about file_get_contents() because its counterpart
> > file_put_contents() for some ungodly reason didn't appear until PHP 5.
> 
> Forget PHP4 and life becomes a lot easier :)

Tell that to some of my clients that have large codebases in PHP4 and
don't want to spend to have it updated to PHP5 when it works perfectly
fine as it is. I don't blame them either.

Cheers,
Rob.
-- 
...
SwarmBuy.com - http://www.swarmbuy.com

Leveraging the buying power of the masses!
...

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



Re: [PHP] Friday morning brain farts....

2007-08-10 Thread Robert Cummings
On Fri, 2007-08-10 at 19:21 +0200, Tijnema wrote:
> On 8/10/07, Robert Cummings <[EMAIL PROTECTED]> wrote:
> > On Fri, 2007-08-10 at 11:48 -0400, Daniel Brown wrote:
> > > On 8/10/07, Stut <[EMAIL PROTECTED]> wrote:
> > > >  I get an email from each
> > > > server containing the contents of the error log from the previous day
> > > > and my first task each day is to go through that and track down any
> > > > issues that usage has highlighted.
> > >
> > > That's actually a good point there that I can take away from this.
> > >  I actually don't have anything set to send me a log of code issues,
> > > only when an error is caused (and, of course, anything server-related,
> > > but that's a different point entirely).
> >
> > Simple enough... put the following in a file, and add a cron job.
> >
> > #!/usr/bin/php -qC
> >  >
> > if( !isset( $argv[1] ) || !isset( $argv[2] ) || !isset( $argv[3] ) )
> 
> if(!isset($argv[1],$argv[2],$argv[3])) // Bit shorter ;)

Quite true.

> > {
> >echo "Usage: {$argv[0]}   \n";
> >exit( 1 );
> > }
> >
> > $subject = $argv[1];
> > $email   = $argv[2];
> > $path= $argv[3];
> >
> > $content = implode( '', file( $path ) );
> 
> $content = file_get_contents($path); // Safe to require PHP 4 >= 4.3.0 right?

I always forget about file_get_contents() because its counterpart
file_put_contents() for some ungodly reason didn't appear until PHP 5.

> > if( trim( $content ) === '' )
> > {
> >$content = 'NO ERRORS TODAY!!!';
> > }
> >
> > mail( $email, $subject, $content );
> >
> > ?>
> >

Cheers,
Rob.
-- 
...
SwarmBuy.com - http://www.swarmbuy.com

Leveraging the buying power of the masses!
...

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



Re: [PHP] Friday morning brain farts....

2007-08-10 Thread Tijnema
On 8/10/07, Robert Cummings <[EMAIL PROTECTED]> wrote:
> On Fri, 2007-08-10 at 19:21 +0200, Tijnema wrote:
> > On 8/10/07, Robert Cummings <[EMAIL PROTECTED]> wrote:
> > > On Fri, 2007-08-10 at 11:48 -0400, Daniel Brown wrote:
> > > > On 8/10/07, Stut <[EMAIL PROTECTED]> wrote:
> > > > >  I get an email from each
> > > > > server containing the contents of the error log from the previous day
> > > > > and my first task each day is to go through that and track down any
> > > > > issues that usage has highlighted.
> > > >
> > > > That's actually a good point there that I can take away from this.
> > > >  I actually don't have anything set to send me a log of code issues,
> > > > only when an error is caused (and, of course, anything server-related,
> > > > but that's a different point entirely).
> > >
> > > Simple enough... put the following in a file, and add a cron job.
> > >
> > > #!/usr/bin/php -qC
> > >  > >
> > > if( !isset( $argv[1] ) || !isset( $argv[2] ) || !isset( $argv[3] ) )
> >
> > if(!isset($argv[1],$argv[2],$argv[3])) // Bit shorter ;)
>
> Quite true.
>
> > > {
> > >echo "Usage: {$argv[0]}   \n";
> > >exit( 1 );
> > > }
> > >
> > > $subject = $argv[1];
> > > $email   = $argv[2];
> > > $path= $argv[3];
> > >
> > > $content = implode( '', file( $path ) );
> >
> > $content = file_get_contents($path); // Safe to require PHP 4 >= 4.3.0 
> > right?
>
> I always forget about file_get_contents() because its counterpart
> file_put_contents() for some ungodly reason didn't appear until PHP 5.

Forget PHP4 and life becomes a lot easier :)

Tijnema
-- 
Vote for PHP Color Coding in Gmail! -> http://gpcc.tijnema.info

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



Re: [PHP] Friday morning brain farts....

2007-08-10 Thread Tijnema
On 8/10/07, Robert Cummings <[EMAIL PROTECTED]> wrote:
> On Fri, 2007-08-10 at 11:48 -0400, Daniel Brown wrote:
> > On 8/10/07, Stut <[EMAIL PROTECTED]> wrote:
> > >  I get an email from each
> > > server containing the contents of the error log from the previous day
> > > and my first task each day is to go through that and track down any
> > > issues that usage has highlighted.
> >
> > That's actually a good point there that I can take away from this.
> >  I actually don't have anything set to send me a log of code issues,
> > only when an error is caused (and, of course, anything server-related,
> > but that's a different point entirely).
>
> Simple enough... put the following in a file, and add a cron job.
>
> #!/usr/bin/php -qC
> 
> if( !isset( $argv[1] ) || !isset( $argv[2] ) || !isset( $argv[3] ) )

if(!isset($argv[1],$argv[2],$argv[3])) // Bit shorter ;)

> {
>echo "Usage: {$argv[0]}   \n";
>exit( 1 );
> }
>
> $subject = $argv[1];
> $email   = $argv[2];
> $path= $argv[3];
>
> $content = implode( '', file( $path ) );

$content = file_get_contents($path); // Safe to require PHP 4 >= 4.3.0 right?

>
> if( trim( $content ) === '' )
> {
>$content = 'NO ERRORS TODAY!!!';
> }
>
> mail( $email, $subject, $content );
>
> ?>
>
> Cheers,
> Rob.
> --

And have a nice day!

Tijnema
-- 
Vote for PHP Color Coding in Gmail! -> http://gpcc.tijnema.info

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



Re: [PHP] Friday morning brain farts....

2007-08-10 Thread Daniel Brown
On 8/10/07, Robert Cummings <[EMAIL PROTECTED]> wrote:
> On Fri, 2007-08-10 at 17:39 +0100, Stut wrote:
> > Robert Cummings wrote:
> > > On Fri, 2007-08-10 at 11:48 -0400, Daniel Brown wrote:
> > >> On 8/10/07, Stut <[EMAIL PROTECTED]> wrote:
> > >>>  I get an email from each
> > >>> server containing the contents of the error log from the previous day
> > >>> and my first task each day is to go through that and track down any
> > >>> issues that usage has highlighted.
> > >> That's actually a good point there that I can take away from this.
> > >>  I actually don't have anything set to send me a log of code issues,
> > >> only when an error is caused (and, of course, anything server-related,
> > >> but that's a different point entirely).
> > >
> > > Simple enough... put the following in a file, and add a cron job.
> > >
> > > #!/usr/bin/php -qC
> > >  > >
> > > if( !isset( $argv[1] ) || !isset( $argv[2] ) || !isset( $argv[3] ) )
> > > {
> > > echo "Usage: {$argv[0]}   \n";
> > > exit( 1 );
> > > }
> > >
> > > $subject = $argv[1];
> > > $email   = $argv[2];
> > > $path= $argv[3];
> > >
> > > $content = implode( '', file( $path ) );
> > >
> > > if( trim( $content ) === '' )
> > > {
> > > $content = 'NO ERRORS TODAY!!!';
> > > }
> > >
> > > mail( $email, $subject, $content );
> > >
> > > ?>
> >
> > I used to have something similar to this until someone uploaded a script
> > that started writing to the error log like mad. Overnight my poor little
> > script tried to load a 240meg log file into memory and email it to me. I
> > now use a simple bash script that pipes the log to the mail command -
> > much safer.
> >
> > Should probably say that it also renames the log file, graceful's
> > Apache, zips the old log and moves it to an archive file server. Rob's
> > script above, used without something that starts a new log will result
> > in ever-increasing emails.
>
> Oh yeah, that's true-- totally forgot to wipe the error log. I just
> whipped the above up :) I have something else on the server without
> command line params that I wrote ages ago :) As for a huge file, unless
> you set PHPs memory high it should just bail with a fatal memory
> exhaustion error. A better script would gzip the log file and attach it
> to an email.
>
> Cheers,
> Rob.
> --
> ...
> SwarmBuy.com - http://www.swarmbuy.com
>
> Leveraging the buying power of the masses!
> ...
>

Wouldn't it even be a worthwhile idea to simply include the first
$n lines of the daily log in an email?  That's how I have my logs
emailed to me for the server things.  I receive the first 300 lines of
the file, and if there's more than that (which, for server logs, there
always are, because I monitor everything), then I know to either hop
on the server and `vim` the log or download it and read it.

In any case, rotating and archiving would be a requirement.
Depending on the log, mine generally rotate daily or once every three
days, with backups being maintained for at least 30 days.

-- 
Daniel P. Brown
[office] (570-) 587-7080 Ext. 272
[mobile] (570-) 766-8107

Hey, PHP-General list
50% off for life on web hosting plans $10/mo. or more at
http://www.pilotpig.net/.
Use the coupon code phpgeneralaug07
Register domains for about $0.01 more than what it costs me at
http://domains.pilotpig.net/.

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



Re: [PHP] Friday morning brain farts....

2007-08-10 Thread Michael Preslar
Here's what I use to watch my apache logs.. Looks for php errors,
notices, and warnings, seg faults, etc.. Grabs the stats for the prior
hour and spits them to stdout.. Pipe that to mutt or sendmail and
youve got an hourly cron.. Check the command line options for other
good stuff.. Only catch: This is written in perl..

http://www.michaelpreslar.com/hour_errorlog.pl.txt

> Should probably say that it also renames the log file, graceful's
> Apache, zips the old log and moves it to an archive file server. Rob's
> script above, used without something that starts a new log will result
> in ever-increasing emails.

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



Re: [PHP] Friday morning brain farts....

2007-08-10 Thread Robert Cummings
On Fri, 2007-08-10 at 17:39 +0100, Stut wrote:
> Robert Cummings wrote:
> > On Fri, 2007-08-10 at 11:48 -0400, Daniel Brown wrote:
> >> On 8/10/07, Stut <[EMAIL PROTECTED]> wrote:
> >>>  I get an email from each
> >>> server containing the contents of the error log from the previous day
> >>> and my first task each day is to go through that and track down any
> >>> issues that usage has highlighted.
> >> That's actually a good point there that I can take away from this.
> >>  I actually don't have anything set to send me a log of code issues,
> >> only when an error is caused (and, of course, anything server-related,
> >> but that's a different point entirely).
> > 
> > Simple enough... put the following in a file, and add a cron job.
> > 
> > #!/usr/bin/php -qC
> >  > 
> > if( !isset( $argv[1] ) || !isset( $argv[2] ) || !isset( $argv[3] ) )
> > {
> > echo "Usage: {$argv[0]}   \n";
> > exit( 1 );
> > }
> > 
> > $subject = $argv[1];
> > $email   = $argv[2];
> > $path= $argv[3];
> > 
> > $content = implode( '', file( $path ) );
> > 
> > if( trim( $content ) === '' )
> > {
> > $content = 'NO ERRORS TODAY!!!';
> > }
> > 
> > mail( $email, $subject, $content );
> > 
> > ?>
> 
> I used to have something similar to this until someone uploaded a script 
> that started writing to the error log like mad. Overnight my poor little 
> script tried to load a 240meg log file into memory and email it to me. I 
> now use a simple bash script that pipes the log to the mail command - 
> much safer.
> 
> Should probably say that it also renames the log file, graceful's 
> Apache, zips the old log and moves it to an archive file server. Rob's 
> script above, used without something that starts a new log will result 
> in ever-increasing emails.

Oh yeah, that's true-- totally forgot to wipe the error log. I just
whipped the above up :) I have something else on the server without
command line params that I wrote ages ago :) As for a huge file, unless
you set PHPs memory high it should just bail with a fatal memory
exhaustion error. A better script would gzip the log file and attach it
to an email.

Cheers,
Rob.
-- 
...
SwarmBuy.com - http://www.swarmbuy.com

Leveraging the buying power of the masses!
...

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



Re: [PHP] Friday morning brain farts....

2007-08-10 Thread Stut

Robert Cummings wrote:

On Fri, 2007-08-10 at 11:48 -0400, Daniel Brown wrote:

On 8/10/07, Stut <[EMAIL PROTECTED]> wrote:

 I get an email from each
server containing the contents of the error log from the previous day
and my first task each day is to go through that and track down any
issues that usage has highlighted.

That's actually a good point there that I can take away from this.
 I actually don't have anything set to send me a log of code issues,
only when an error is caused (and, of course, anything server-related,
but that's a different point entirely).


Simple enough... put the following in a file, and add a cron job.

#!/usr/bin/php -qC
  \n";
exit( 1 );
}

$subject = $argv[1];
$email   = $argv[2];
$path= $argv[3];

$content = implode( '', file( $path ) );

if( trim( $content ) === '' )
{
$content = 'NO ERRORS TODAY!!!';
}

mail( $email, $subject, $content );

?>


I used to have something similar to this until someone uploaded a script 
that started writing to the error log like mad. Overnight my poor little 
script tried to load a 240meg log file into memory and email it to me. I 
now use a simple bash script that pipes the log to the mail command - 
much safer.


Should probably say that it also renames the log file, graceful's 
Apache, zips the old log and moves it to an archive file server. Rob's 
script above, used without something that starts a new log will result 
in ever-increasing emails.


-Stut

--
http://stut.net/

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



Re[2]: [PHP] Friday morning brain farts....

2007-08-10 Thread Richard Davey
Hi Stut,

Friday, August 10, 2007, 4:44:14 PM, you wrote:

> On my production servers error_reporting is set to E_ALL,
> display_errors is off and log_errors is on. I get an email from each
> server containing the contents of the error log from the previous
> day and my first task each day is to go through that and track down
> any issues that usage has highlighted.

Snap :)

We do exactly the same here. The PHP log is checked first thing every
morning for notices, fatal errors, etc. The notices are especially
useful to finding out where other devs have forgotten (or incorrectly
named) variables, etc - as a number of people work on the sites each
day.

I wrote a very simple script that parses the log file into a web page
and colour codes each element (red = fatal, green = notice, yellow =
warning). We can also inject developer notes into it (using
error_log() with some set keywords at the start) which appear in blue.

Here's a small grab from an internal development server log:

http://www.corephp.co.uk/images/php_error_log.jpg

Simple, but effective.

Cheers,

Rich
-- 
Zend Certified Engineer
http://www.corephp.co.uk

"Never trust a computer you can't throw out of a window"

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



Re: [PHP] Friday morning brain farts....

2007-08-10 Thread Robert Cummings
On Fri, 2007-08-10 at 11:48 -0400, Daniel Brown wrote:
> On 8/10/07, Stut <[EMAIL PROTECTED]> wrote:
> >  I get an email from each
> > server containing the contents of the error log from the previous day
> > and my first task each day is to go through that and track down any
> > issues that usage has highlighted.
> 
> That's actually a good point there that I can take away from this.
>  I actually don't have anything set to send me a log of code issues,
> only when an error is caused (and, of course, anything server-related,
> but that's a different point entirely).

Simple enough... put the following in a file, and add a cron job.

#!/usr/bin/php -qC
  \n";
exit( 1 );
}

$subject = $argv[1];
$email   = $argv[2];
$path= $argv[3];

$content = implode( '', file( $path ) );

if( trim( $content ) === '' )
{
$content = 'NO ERRORS TODAY!!!';
}

mail( $email, $subject, $content );

?>

Cheers,
Rob.
-- 
...
SwarmBuy.com - http://www.swarmbuy.com

Leveraging the buying power of the masses!
...

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



Re: [PHP] Friday morning brain farts....

2007-08-10 Thread Daniel Brown
On 8/10/07, Stut <[EMAIL PROTECTED]> wrote:
>  I get an email from each
> server containing the contents of the error log from the previous day
> and my first task each day is to go through that and track down any
> issues that usage has highlighted.

That's actually a good point there that I can take away from this.
 I actually don't have anything set to send me a log of code issues,
only when an error is caused (and, of course, anything server-related,
but that's a different point entirely).

-- 
Daniel P. Brown
[office] (570-) 587-7080 Ext. 272
[mobile] (570-) 766-8107

Hey, PHP-General list
50% off for life on web hosting plans $10/mo. or more at
http://www.pilotpig.net/.
Use the coupon code phpgeneralaug07
Register domains for about $0.01 more than what it costs me at
http://domains.pilotpig.net/.

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



Re: [PHP] Friday morning brain farts....

2007-08-10 Thread Daniel Brown
On 8/10/07, Robert Cummings <[EMAIL PROTECTED]> wrote:
> On Fri, 2007-08-10 at 11:40 -0400, Daniel Brown wrote:
> > On 8/10/07, Stut <[EMAIL PROTECTED]> wrote:
> > > If PHP thinks something might be wrong it will tell you. Why on earth
> > > would you want to ignore it? You think you're smarter than PHP? Really?
> >
> > Okay, Stut, let's not make Friday the official "Flame Dan Brown"
> > holiday this week.  I vote that it should be later in the year.
> >
> > However, it should also be noted that my development is never done
> > on a production server attached to the Internet, for one; and on my
> > development machine, E_NOTICE is always enabled.  I just fail to see
> > the benefit in alerting visitors to the site that there may have been
> > something overlooked at some point.
>
> Why would it alert visitors? You don't have display errors set to on for
> a production server do you? *EK*. Send it to a log file. The
> reason it's good to enable notices on a production server is because
> your visitors are like a horde of testers, they'll probably hit every
> nook and cranny of your code that you might have missed during testing.
>
> Cheers,
> Rob.
> --
> ...
> SwarmBuy.com - http://www.swarmbuy.com
>
> Leveraging the buying power of the masses!
> ...
>

Ha!  No, I don't have it set to display anything to the user
except for a custom error-handling message.  The generic, "there
appears to be a problem, we've been notified, blah, blah, blah"

The way I read your point was to say that it should be on display.
 That misunderstanding is my fault.

-- 
Daniel P. Brown
[office] (570-) 587-7080 Ext. 272
[mobile] (570-) 766-8107

Hey, PHP-General list
50% off for life on web hosting plans $10/mo. or more at
http://www.pilotpig.net/.
Use the coupon code phpgeneralaug07
Register domains for about $0.01 more than what it costs me at
http://domains.pilotpig.net/.

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



Re: [PHP] Friday morning brain farts....

2007-08-10 Thread Stut

Daniel Brown wrote:

On 8/10/07, Stut <[EMAIL PROTECTED]> wrote:

If PHP thinks something might be wrong it will tell you. Why on earth
would you want to ignore it? You think you're smarter than PHP? Really?


Okay, Stut, let's not make Friday the official "Flame Dan Brown"
holiday this week.  I vote that it should be later in the year.

However, it should also be noted that my development is never done
on a production server attached to the Internet, for one; and on my
development machine, E_NOTICE is always enabled.  I just fail to see
the benefit in alerting visitors to the site that there may have been
something overlooked at some point.


Whoa there nelly, that's a whole other thing.

I've never said users get to see notices. They never see warnings or 
errors. That's what the display_errors and log_errors options in php.ini 
are for. On my production servers error_reporting is set to E_ALL, 
display_errors is off and log_errors is on. I get an email from each 
server containing the contents of the error log from the previous day 
and my first task each day is to go through that and track down any 
issues that usage has highlighted.


-Stut

--
http://stut.net/

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



Re: [PHP] Friday morning brain farts....

2007-08-10 Thread Robert Cummings
On Fri, 2007-08-10 at 11:40 -0400, Daniel Brown wrote:
> On 8/10/07, Stut <[EMAIL PROTECTED]> wrote:
> > If PHP thinks something might be wrong it will tell you. Why on earth
> > would you want to ignore it? You think you're smarter than PHP? Really?
> 
> Okay, Stut, let's not make Friday the official "Flame Dan Brown"
> holiday this week.  I vote that it should be later in the year.
> 
> However, it should also be noted that my development is never done
> on a production server attached to the Internet, for one; and on my
> development machine, E_NOTICE is always enabled.  I just fail to see
> the benefit in alerting visitors to the site that there may have been
> something overlooked at some point.

Why would it alert visitors? You don't have display errors set to on for
a production server do you? *EK*. Send it to a log file. The
reason it's good to enable notices on a production server is because
your visitors are like a horde of testers, they'll probably hit every
nook and cranny of your code that you might have missed during testing.

Cheers,
Rob.
-- 
...
SwarmBuy.com - http://www.swarmbuy.com

Leveraging the buying power of the masses!
...

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



Re: [PHP] Friday morning brain farts....

2007-08-10 Thread Daniel Brown
On 8/10/07, Stut <[EMAIL PROTECTED]> wrote:
> If PHP thinks something might be wrong it will tell you. Why on earth
> would you want to ignore it? You think you're smarter than PHP? Really?

Okay, Stut, let's not make Friday the official "Flame Dan Brown"
holiday this week.  I vote that it should be later in the year.

However, it should also be noted that my development is never done
on a production server attached to the Internet, for one; and on my
development machine, E_NOTICE is always enabled.  I just fail to see
the benefit in alerting visitors to the site that there may have been
something overlooked at some point.

-- 
Daniel P. Brown
[office] (570-) 587-7080 Ext. 272
[mobile] (570-) 766-8107

Hey, PHP-General list
50% off for life on web hosting plans $10/mo. or more at
http://www.pilotpig.net/.
Use the coupon code phpgeneralaug07
Register domains for about $0.01 more than what it costs me at
http://domains.pilotpig.net/.

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



Re: [PHP] Friday morning brain farts....

2007-08-10 Thread Robert Cummings
On Fri, 2007-08-10 at 11:28 -0400, Daniel Brown wrote:
> On 8/10/07, Robert Cummings <[EMAIL PROTECTED]> wrote:
> > I never disable E_NOTICE or even E_STRICT.
> 
> I'm humbled in the presence of greatness.

Nothing great about it. It's work as usual. When you're developing the
code you see any notices immediately. It takes 10 seconds to fix them
since you're usually working at that specific location in the code
anyways.

Cheers,
Rob.
-- 
...
SwarmBuy.com - http://www.swarmbuy.com

Leveraging the buying power of the masses!
...

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



Re: [PHP] Friday morning brain farts....

2007-08-10 Thread Stut

Daniel Brown wrote:

On 8/10/07, Robert Cummings <[EMAIL PROTECTED]> wrote:

I never disable E_NOTICE or even E_STRICT.


I'm humbled in the presence of greatness.

I do my best to ensure that there are no notices or warnings, but
I still disable E_NOTICE in general, because I know that it's not
going to end the world.


Do your best? If you set out with the goal of not allowing your sites to 
generate notices it's no harder than ignoring them. The benefits far 
outweigh the minimal cost.


I must admin that a couple of sites I've been involved with over the 
years have run with notices ignored, but that's only because they 
consisted of large amounts of code that had been written without any 
regard for them. Of all the sites I've worked on those were some of the 
worst.


If PHP thinks something might be wrong it will tell you. Why on earth 
would you want to ignore it? You think you're smarter than PHP? Really?


-Stut

--
http://stut.net/

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



Re: [PHP] Friday morning brain farts....

2007-08-10 Thread Stut

Daniel Brown wrote:

On 8/10/07, Stut <[EMAIL PROTECTED]> wrote:

Bad Dan *slap*. Ignoring notices may be detrimental to your health
and/or well-being. Better to initialise it with a default if it has not
been set in the request.

if (!isset($_GET['order'])) $_GET['order'] = 'Last';


Ouch!

So you're all going to tell me that you have E_NOTICE set to
report on your sites?  Look, I didn't say it was the Right Way[tm],
but it is safe to ignore.


I do indeed. E_NOTICE can help find certain bugs faster than any other 
method I've found. Turning them off is both lazy and dangerous.


-Stut

--
http://stut.net/

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



Re: [PHP] Friday morning brain farts....

2007-08-10 Thread Daniel Brown
On 8/10/07, Robert Cummings <[EMAIL PROTECTED]> wrote:
> I never disable E_NOTICE or even E_STRICT.

I'm humbled in the presence of greatness.

I do my best to ensure that there are no notices or warnings, but
I still disable E_NOTICE in general, because I know that it's not
going to end the world.

-- 
Daniel P. Brown
[office] (570-) 587-7080 Ext. 272
[mobile] (570-) 766-8107

Hey, PHP-General list
50% off for life on web hosting plans $10/mo. or more at
http://www.pilotpig.net/.
Use the coupon code phpgeneralaug07
Register domains for about $0.01 more than what it costs me at
http://domains.pilotpig.net/.

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



Re: [PHP] Friday morning brain farts....

2007-08-10 Thread Robert Cummings
On Fri, 2007-08-10 at 11:18 -0400, Daniel Brown wrote:
> On 8/10/07, Stut <[EMAIL PROTECTED]> wrote:
> > Bad Dan *slap*. Ignoring notices may be detrimental to your health
> > and/or well-being. Better to initialise it with a default if it has not
> > been set in the request.
> >
> > if (!isset($_GET['order'])) $_GET['order'] = 'Last';
> 
> Ouch!
> 
> So you're all going to tell me that you have E_NOTICE set to
> report on your sites?  Look, I didn't say it was the Right Way[tm],
> but it is safe to ignore.

I never disable E_NOTICE or even E_STRICT.

Cheers,
Rob.
-- 
...
SwarmBuy.com - http://www.swarmbuy.com

Leveraging the buying power of the masses!
...

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



Re: [PHP] Friday morning brain farts....

2007-08-10 Thread Robert Cummings
On Fri, 2007-08-10 at 10:43 -0400, Jason Pruim wrote:
> Hi All :)
> 
> Hope you're not getting sick of my questions as of late, but I keep  
> getting closer and closer and thank you all who have helped me in the  
> past! "The only reason I can see this far is I am standing on the  
> shoulders of giants" don't know who said that but I like it :)

http://en.wikipedia.org/wiki/Stand_on_the_shoulders_of_giants

Cheers,
Rob.
-- 
...
SwarmBuy.com - http://www.swarmbuy.com

Leveraging the buying power of the masses!
...

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



Re[2]: [PHP] Friday morning brain farts....

2007-08-10 Thread Richard Davey
Hi Robert,

Friday, August 10, 2007, 4:13:02 PM, you wrote:

> On Fri, 2007-08-10 at 11:00 -0400, Daniel Brown wrote:
>>
>> Remember to clean that input before you sit down at the table, there, 
>> boy!
>> 
>> It's safe to ignore the `Undefined index` notices.  That will just
>> appear if a variable is referenced without first being instantiated or
>> defined.  No biggie, just put this at the head of your code:
>> 
>> ini_set("error_reporting",E_ALL & ~E_NOTICE);

> I'm in the "that's sloppy and poor style" camp for the above setting.

I've got to agree. A clean E_ALL error log is a good error log.

It's not like it's hard to fix.

Cheers,

Rich
-- 
Zend Certified Engineer
http://www.corephp.co.uk

"Never trust a computer you can't throw out of a window"

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



Re: [PHP] Friday morning brain farts....

2007-08-10 Thread Daniel Brown
On 8/10/07, Stut <[EMAIL PROTECTED]> wrote:
> Bad Dan *slap*. Ignoring notices may be detrimental to your health
> and/or well-being. Better to initialise it with a default if it has not
> been set in the request.
>
> if (!isset($_GET['order'])) $_GET['order'] = 'Last';

Ouch!

So you're all going to tell me that you have E_NOTICE set to
report on your sites?  Look, I didn't say it was the Right Way[tm],
but it is safe to ignore.

-- 
Daniel P. Brown
[office] (570-) 587-7080 Ext. 272
[mobile] (570-) 766-8107

Hey, PHP-General list
50% off for life on web hosting plans $10/mo. or more at
http://www.pilotpig.net/.
Use the coupon code phpgeneralaug07
Register domains for about $0.01 more than what it costs me at
http://domains.pilotpig.net/.

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



Re: [PHP] Friday morning brain farts....

2007-08-10 Thread Stut

Daniel Brown wrote:

On 8/10/07, Jason Pruim <[EMAIL PROTECTED]> wrote:

Hi All :)

Hope you're not getting sick of my questions as of late, but I keep
getting closer and closer and thank you all who have helped me in the
past! "The only reason I can see this far is I am standing on the
shoulders of giants" don't know who said that but I like it :)

Anyway... Onto the question...

I think I'm just going crazy as it's been a busy week for me, but I
can't figure out how to do this. What I am attempting to do is, I
have a webpage(Don't we all?) that calls info to be displayed from a
database,

I want to be able to sort that info so my sql query looks like:
"Select * from current order by '$order';" and $order is populated by
a GET when they click on a link: "Sort
by last name"  Now... the whole PHP page is being included in
a .shtml page to actually display it and make it look purrdee :)

How do I get it to resort the info and include the new sort on the page?

I'm not sure if this has anything to do with it but:

$order = $_GET['order']; <--Line 6

[Fri Aug 10 10:42:04 2007] [error] PHP Notice:  Undefined index:
order in /Volumes/RAIDer/webserver/Documents/tests/legion/index.php
on line 6

Any help will be greatly appreciated.. And if it solves the problem
I'll name some of my kids* after you!



*Subject to approval of the Wife :)

--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424
www.raoset.com
[EMAIL PROTECTED]





Remember to clean that input before you sit down at the table, there, boy!

It's safe to ignore the `Undefined index` notices.  That will just
appear if a variable is referenced without first being instantiated or
defined.  No biggie, just put this at the head of your code:

ini_set("error_reporting",E_ALL & ~E_NOTICE);


Bad Dan *slap*. Ignoring notices may be detrimental to your health 
and/or well-being. Better to initialise it with a default if it has not 
been set in the request.


if (!isset($_GET['order'])) $_GET['order'] = 'Last';

-Stut

--
http://stut.net/

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



Re: [PHP] Friday morning brain farts....

2007-08-10 Thread Daniel Brown
On 8/10/07, Robert Cummings <[EMAIL PROTECTED]> wrote:
> On Fri, 2007-08-10 at 11:00 -0400, Daniel Brown wrote:
> >
> > Remember to clean that input before you sit down at the table, there, 
> > boy!
> >
> > It's safe to ignore the `Undefined index` notices.  That will just
> > appear if a variable is referenced without first being instantiated or
> > defined.  No biggie, just put this at the head of your code:
> >
> > ini_set("error_reporting",E_ALL & ~E_NOTICE);
>
> I'm in the "that's sloppy and poor style" camp for the above setting.
>
> Cheers,
> Rob.
> --
> ...
> SwarmBuy.com - http://www.swarmbuy.com
>
> Leveraging the buying power of the masses!
> ...
>

You belong in a camp, alright ;-P

-- 
Daniel P. Brown
[office] (570-) 587-7080 Ext. 272
[mobile] (570-) 766-8107

Hey, PHP-General list
50% off for life on web hosting plans $10/mo. or more at
http://www.pilotpig.net/.
Use the coupon code phpgeneralaug07
Register domains for about $0.01 more than what it costs me at
http://domains.pilotpig.net/.

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



Re: [PHP] Friday morning brain farts....

2007-08-10 Thread Robert Cummings
On Fri, 2007-08-10 at 11:00 -0400, Daniel Brown wrote:
>
> Remember to clean that input before you sit down at the table, there, boy!
> 
> It's safe to ignore the `Undefined index` notices.  That will just
> appear if a variable is referenced without first being instantiated or
> defined.  No biggie, just put this at the head of your code:
> 
> ini_set("error_reporting",E_ALL & ~E_NOTICE);

I'm in the "that's sloppy and poor style" camp for the above setting.

Cheers,
Rob.
-- 
...
SwarmBuy.com - http://www.swarmbuy.com

Leveraging the buying power of the masses!
...

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



Re: [PHP] Friday morning brain farts....

2007-08-10 Thread Daniel Brown
On 8/10/07, Jason Pruim <[EMAIL PROTECTED]> wrote:
> Hi All :)
>
> Hope you're not getting sick of my questions as of late, but I keep
> getting closer and closer and thank you all who have helped me in the
> past! "The only reason I can see this far is I am standing on the
> shoulders of giants" don't know who said that but I like it :)
>
> Anyway... Onto the question...
>
> I think I'm just going crazy as it's been a busy week for me, but I
> can't figure out how to do this. What I am attempting to do is, I
> have a webpage(Don't we all?) that calls info to be displayed from a
> database,
>
> I want to be able to sort that info so my sql query looks like:
> "Select * from current order by '$order';" and $order is populated by
> a GET when they click on a link: "Sort
> by last name"  Now... the whole PHP page is being included in
> a .shtml page to actually display it and make it look purrdee :)
>
> How do I get it to resort the info and include the new sort on the page?
>
> I'm not sure if this has anything to do with it but:
>
> $order = $_GET['order']; <--Line 6
>
> [Fri Aug 10 10:42:04 2007] [error] PHP Notice:  Undefined index:
> order in /Volumes/RAIDer/webserver/Documents/tests/legion/index.php
> on line 6
>
> Any help will be greatly appreciated.. And if it solves the problem
> I'll name some of my kids* after you!
>
>
>
> *Subject to approval of the Wife :)
>
> --
>
> Jason Pruim
> Raoset Inc.
> Technology Manager
> MQC Specialist
> 3251 132nd ave
> Holland, MI, 49424
> www.raoset.com
> [EMAIL PROTECTED]
>
>
>

Remember to clean that input before you sit down at the table, there, boy!

It's safe to ignore the `Undefined index` notices.  That will just
appear if a variable is referenced without first being instantiated or
defined.  No biggie, just put this at the head of your code:

ini_set("error_reporting",E_ALL & ~E_NOTICE);

-- 
Daniel P. Brown
[office] (570-) 587-7080 Ext. 272
[mobile] (570-) 766-8107

Hey, PHP-General list
50% off for life on web hosting plans $10/mo. or more at
http://www.pilotpig.net/.
Use the coupon code phpgeneralaug07
Register domains for about $0.01 more than what it costs me at
http://domains.pilotpig.net/.

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



Re: [PHP] Friday morning brain farts....

2007-08-10 Thread Paul Novitski

At 8/10/2007 07:43 AM, Jason Pruim wrote:

I want to be able to sort that info so my sql query looks like:
"Select * from current order by '$order';" and $order is populated by
a GET when they click on a link: "Sort
by last name"  Now... the whole PHP page is being included in
a .shtml page to actually display it and make it look purrdee :)

...

$order = $_GET['order']; <--Line 6



Your HTML should read:

Sort by last name

Note double-quotes around the href expression and no quotes around 
the querystring parameter value.


Also, you'll want to check the incoming values to prevent SQL 
injection (q.v.).  If you insert unevaluated input into an SQL query 
you're leaving yourself vulnerable to everything from data exposure 
to data manipulation from outside sources.


Regards,

Paul
__

Paul Novitski
Juniper Webcraft Ltd.
http://juniperwebcraft.com 



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



Re: [PHP] Friday morning brain farts....

2007-08-10 Thread Borokov Smith
if (isset($_GET['order'] && in_array($_GET['order'], array('Last', 
'First', ...))) { $requestedOrder = $_GET['order']; } else { 
$requestedOrder = ; }


Mind the in_array() call. Always sanitize user input.

greetz,

boro


Jason Pruim schreef:

Hi All :)

Hope you're not getting sick of my questions as of late, but I keep 
getting closer and closer and thank you all who have helped me in the 
past! "The only reason I can see this far is I am standing on the 
shoulders of giants" don't know who said that but I like it :)


Anyway... Onto the question...

I think I'm just going crazy as it's been a busy week for me, but I 
can't figure out how to do this. What I am attempting to do is, I have 
a webpage(Don't we all?) that calls info to be displayed from a database,


I want to be able to sort that info so my sql query looks like: 
"Select * from current order by '$order';" and $order is populated by 
a GET when they click on a link: "Sort 
by last name"  Now... the whole PHP page is being included in a 
.shtml page to actually display it and make it look purrdee :)


How do I get it to resort the info and include the new sort on the page?

I'm not sure if this has anything to do with it but:

$order = $_GET['order']; <--Line 6

[Fri Aug 10 10:42:04 2007] [error] PHP Notice:  Undefined index:  
order in /Volumes/RAIDer/webserver/Documents/tests/legion/index.php on 
line 6


Any help will be greatly appreciated.. And if it solves the problem 
I'll name some of my kids* after you!




*Subject to approval of the Wife :)

--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424
www.raoset.com
[EMAIL PROTECTED]





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



[PHP] Friday morning brain farts....

2007-08-10 Thread Jason Pruim

Hi All :)

Hope you're not getting sick of my questions as of late, but I keep  
getting closer and closer and thank you all who have helped me in the  
past! "The only reason I can see this far is I am standing on the  
shoulders of giants" don't know who said that but I like it :)


Anyway... Onto the question...

I think I'm just going crazy as it's been a busy week for me, but I  
can't figure out how to do this. What I am attempting to do is, I  
have a webpage(Don't we all?) that calls info to be displayed from a  
database,


I want to be able to sort that info so my sql query looks like:  
"Select * from current order by '$order';" and $order is populated by  
a GET when they click on a link: "Sort  
by last name"  Now... the whole PHP page is being included in  
a .shtml page to actually display it and make it look purrdee :)


How do I get it to resort the info and include the new sort on the page?

I'm not sure if this has anything to do with it but:

$order = $_GET['order']; <--Line 6

[Fri Aug 10 10:42:04 2007] [error] PHP Notice:  Undefined index:   
order in /Volumes/RAIDer/webserver/Documents/tests/legion/index.php  
on line 6


Any help will be greatly appreciated.. And if it solves the problem  
I'll name some of my kids* after you!




*Subject to approval of the Wife :)

--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424
www.raoset.com
[EMAIL PROTECTED]