php-general Digest 6 Jul 2010 08:54:50 -0000 Issue 6832

Topics (messages 306687 through 306701):

Re: HTML in emails
        306687 by: Richard Quadling
        306689 by: tedd
        306693 by: Al
        306694 by: Jonesy

Inner join woes... and sweet tea!
        306688 by: Jason Pruim
        306690 by: Peter Lind
        306691 by: Richard Quadling
        306692 by: Pete Ford
        306695 by: Richard Quadling
        306698 by: Gary
        306700 by: Jason Pruim

Re: form validation and error display
        306696 by: David Mehler
        306697 by: Shreyas Agasthya

Question about the Board
        306699 by: Gary

"php -l" - does it find *anything*?
        306701 by: Gary .

Administrivia:

To subscribe to the digest, e-mail:
        [email protected]

To unsubscribe from the digest, e-mail:
        [email protected]

To post to the list, e-mail:
        [email protected]


----------------------------------------------------------------------
--- Begin Message ---
On 4 July 2010 16:43, Al <[email protected]> wrote:
> What are you folks doing?
>
> Al..........

One of the tasks I had to develop was the sending of authorised work
in a "by job" report.

We receive the work as a fax/email. We log the job in our system.

The client comes to our site and confirms the on-cost billing to the job.

We produce the invoices for their clients.

We produce HTML emails which render just fine in Outlook 2003+,
Outlook Express (we are told they are fine - I've never actually
bothered), GMail (I use it) and Yahoo's email (again we are told it is
OK).

Sure, the plain text part for most normal emails is what is read by
most developers, but this client isn't a developer. So comments like
"eye-candy" is exactly what it is all about.

They use their email tool to read communications. If the
communications are easier to understand, laid out nicely, look like
the secured webpage, then the customer is a happy one.

In producing the HTML, I had to back date my thinking a decade or so.
So, I use <table> and some VERY limited inline styling. Not because I
want to. But because the application with the largest market share for
reading email in my customer base requires me to do so.

Regards,

Richard.

--- End Message ---
--- Begin Message ---
At 11:44 PM +0100 7/4/10, Ashley Sheridan wrote:
On Sun, 2010-07-04 at 17:06 -0400, Paul M Foster wrote:
 > On Sun, Jul 04, 2010 at 11:43:59AM -0400, Al wrote:
-snip-
 > > Seems like, from my preliminary Google searching, I should not waste
 > time with
 > the standard's way and just go straight to sending simple html pages
 > since all
> modern browsers handle it well. And, it appears to be the way web is going.
 >
 > What are you folks doing?
 >
 I use mutt for email, so I only see the text portion. That make me an
 anomaly. However, for example there are various listserv software that
 > will not allow HTML in emails.

-snip-
 >
 > Paul

-snip-

One feature I've seen in some mailing list software is the ability to
track how people prefer their email formatted, so that you only send
HTML emails to those that want them, and text emails to those who prefer
that method. It's the best of both worlds I reckon, and one that is
likely to upset as few people as possible; at the worst they might
receive one email in a format they don't want before they change their
preferences.

Ash

I agree with both Paul and Ash but for a different reason.

Receiving email is much like looking at web sites -- it's data provided from a server to an application to be shown to a user. In the case of web sites, html is provided to a browser and the browser presents the content to the user via the instructions provided by the html and others, such as css and javascript.

Unfortunately, if you've done any web sites at all, you know that not all (less than a score of them) browsers are created equal and while your web site may look great in your browser, it sucks in another. It takes a lot of work to make a web site look consistent on all modern browsers. Here's a little something I wrote about it:

http://sperling.com/four-things-clients-should-know.php

Now throw on to this problem how hundreds of different email applications running under hundreds of different OS's (this includes hand held devices) handle html/css/javascript and you'll have an idea of the size of the problem of how to present data to the user via the user's device.

Sending HTML in email isn't the problem, but receiving and displaying HTML in email IS.

Simply put, there isn't a standard for sending/receiving email and while clients may want a pretty email to be sent to all their customers, they are clueless as to what their customers will actually receive.

Furthermore, there is considerable pressure by clients on developers to create the prefect email. Unfortunately, some developers succumb to the pressure (or they don't know any better) and create a send/receive that works for a special case, namely something sufficient for management to think the problem has been solved but it hasn't -- perhaps that's the reason why Adobe emails look so bad -- management still doesn't understand the problem and their developers either don't know any better, or are afraid to tell management the truth. But proof is in the pudding and while they may think the Emperor's new clothes are magnificent, they aren't.

My advice, send text! If you want the end user to see something, then send a link. But do not send HTML in email until every known browser conforms to W3C standards. At that point, then we can start working on hand-held devices to follow the standards as well. When that is finished, then we can consider sending something other than text in an email.

Cheers,

tedd

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

--- End Message ---
--- Begin Message ---


On 7/4/2010 11:43 AM, Al wrote:
I know this is a bit off-topic; but close enough.

I'm starting to update the email feature of one of my DB applications
and noticed that it appears most of the fancy emails I receive are using
just plain old, simple html pages, with a note about not being able to
see, go here with a link.

It use to be that we specified content-type text/html, etc. and sent
both the plain ASCII and the html with boundaries and so forth.

Seems like, from my preliminary Google searching, I should not waste
time with the standard's way and just go straight to sending simple html
pages since all modern browsers handle it well. And, it appears to be
the way web is going.

What are you folks doing?

Al..........

Thanks everyone. That's a big help.

I'm going to set the application up so simple html code can be sent; but not a complete page with body, etc.

There are two main deficiencies I want to address, links [like rendered in an html page] and attachments. I have a little trouble with some folks who can't seem to deal with "Go here... www.foo.com/bar/xyz.php". They are so accustomed to having html rendered links and attached docs and images.

Al.........



--- End Message ---
--- Begin Message ---
On Sun, 4 Jul 2010 23:12:22 -0400, Paul M Foster wrote:
> On Sun, Jul 04, 2010 at 11:44:29PM +0100, Ashley Sheridan wrote:
>
><snip>
>
>>    It is nice to be able to format emails nicely, but you have to realise
>>    when to restrain yourself. I've been getting loads of emails from Adobe
>>    lately that haven't been formatted well at all, and appear awfully in my
>>    email client (Evolution, which I consider to be a very good client) until
>>    I download all the images they've used as backgrounds. It's situations
>>    like this that give HTML emails an awful name.
>
> Isn't this a popular exploit these days? I don't really watch these
> things since I use Linux and view mail as straight text. But isn't there
> some current exploit where images which can be downloaded as part of an
> email actually contain code which can be used to sniff your system or
> somesuch?

If nothing else, it is useful as a tracking tool.  When the request to 
download the images occurs, it tells the spammer mothership that the 
email _was_ received and *actually* read.  
Ergo, it's a 'live' email addy.

The image URIs are usually encoded with unique-by-email-address text.

Jonesy
-- 
  Marvin L Jones    | jonz          | W3DHJ  | linux
   38.24N  104.55W  |  @ config.com | Jonesy |  OS/2
    * Killfiling google & XXXXbanter.com: jonz.net/ng.htm


--- End Message ---
--- Begin Message ---
Hi everyone,

I'll admit right now that I'm still trying to wrestle with inner joins... Which leaves me with this code right here:

<?PHP

if(isset($_GET['cat'])) {
            $cat = mysql_real_escape_string($_GET['cat']);

        }

        if(isset($cat)) {
$sql = "SELECT * FROM ".$cfgtableContent." INNER JOIN ".$cfgtableCategories." WHERE ".$cfgtableContent.".postCat = ".$cat." ORDER BY ".$cfgtableContent.".postNumber DESC";

        }

?>

Now... I know the problem is probably staring an experienced inner join master in the face and I don't even have to say it... But for those who don't know or you might be searching the archives and want to learn from my blatant misunderstanding of inner joins I'll outline said problem in the following lines.

What I want to achieve: Add navigation by category to my blog. IE: If I want to display just Personal posts click on the "Personal" link and all other posts magically disappear.

What I'm getting now: I have 5 categories in my blog now... I get 5 copies of each post repeated down the site all with a different category...

All the variables are filled in correctly which I have checked with simple echo's. I have also tried removing the escaping of the data with no change so if possible I'd like to leave it in there as is :)

I have also tried switching it from the above to this:

<?PHP

$sql = "SELECT * FROM ".$cfgtableContent." INNER JOIN ".$cfgtableContent." WHERE ".$cfgtableCategories.".postCat = ".$cat." ORDER BY ".$cfgtableContent.".postNumber DESC";

?>

with no change...

Any ideas what I'm missing? :)



--- End Message ---
--- Begin Message ---
On 5 July 2010 15:02, Jason Pruim <[email protected]> wrote:
> Hi everyone,
>
> I'll admit right now that I'm still trying to wrestle with inner joins...
> Which leaves me with this code right here:
>
> <?PHP
>
> if(isset($_GET['cat'])) {
>            $cat = mysql_real_escape_string($_GET['cat']);
>
>        }
>
>        if(isset($cat)) {
>               $sql = "SELECT * FROM ".$cfgtableContent." INNER JOIN
> ".$cfgtableCategories." WHERE ".$cfgtableContent.".postCat = ".$cat." ORDER
> BY ".$cfgtableContent.".postNumber DESC";
>
>        }
>
> ?>
>
> Now... I know the problem is probably staring an experienced inner join
> master in the face and I don't even have to say it... But for those who
> don't know or you might be searching the archives and want to learn from my
> blatant misunderstanding of inner joins I'll outline said problem in the
> following lines.
>
> What I want to achieve: Add navigation by category to my blog. IE: If I want
> to display just Personal posts click on the "Personal" link and all other
> posts magically disappear.
>
> What I'm getting now: I have 5 categories in my blog now... I get 5 copies
> of each post repeated down the site all with a different category...
>
> All the variables are filled in correctly which I have checked with simple
> echo's. I have also tried removing the escaping of the data with no change
> so if possible I'd like to leave it in there as is :)
>
> I have also tried switching it from the above to this:
>
> <?PHP
>
>               $sql = "SELECT * FROM ".$cfgtableContent." INNER JOIN
> ".$cfgtableContent." WHERE ".$cfgtableCategories.".postCat = ".$cat." ORDER
> BY ".$cfgtableContent.".postNumber DESC";
>
> ?>
>
> with no change...
>

There's no join clause in your query, i.e. nothing to tie the two
tables together. That will leave you with a cartesian product, i.e.
for every row in table a you'll get the entire table b joined on. You
need to specify how the tables you're joining together are related.

Something like

SELECT
  a.row
FROM
  a
  JOIN b ON b.a_id = a.id

Regards
Peter

-- 
<hype>
WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
BeWelcome/Couchsurfing: Fake51
Twitter: http://twitter.com/kafe15
</hype>

--- End Message ---
--- Begin Message ---
On 5 July 2010 14:02, Jason Pruim <[email protected]> wrote:
> Hi everyone,
>
> I'll admit right now that I'm still trying to wrestle with inner joins...

It is all about set theory. Imagine two circles, which overlap
(http://en.wikipedia.org/wiki/Venn_diagram#Example as an example).

For that example, simplistically, A contains me and my emu. B contains
my emu and the my deathwatch beetle.


SELECT * FROM A,B WHERE A.id = B.id (My emu)

SELECT * FROM A INNER JOIN B ON A.id = B.id (My emu)

SELECT * FROM A LEFT OUTER JOIN B ON A.id = B.id (Me and My emu)

SELECT * FROM A RIGHT OUTER JOIN B ON A.id = B.id (My emu and my
deathwatch beetle)

SELECT * FROM A FULL OUTER JOIN B ON A.id = B.id

returns in interesting set (essentially all things but 1 column for each table).

Me, null
My emu, my emu
null, My deathwatch beetle.

If you were using ISNULL ...

SELECT ISNULL(A.name, B.name) AS name FROM A FULL OUTER JOIN B ON A.id = B.id

would return all things

Me
My emu
My deathwatch beetle.


And, (I think), finally, an inversion of the inner join.


SELECT ISNULL(A.name, B.name) AS name FROM A FULL OUTER JOIN B ON A.id
= B.id WHERE A.id IS NULL OR B.id IS NULL

returns

Me
My deathwatch beetle.

All things except those 2 legged things that can fly.

I hope that helps.

Regards,

Richard.

P.S. I don't have an emu.

--- End Message ---
--- Begin Message ---
On 05/07/10 14:38, Richard Quadling wrote:
On 5 July 2010 14:02, Jason Pruim<[email protected]>  wrote:
Hi everyone,

I'll admit right now that I'm still trying to wrestle with inner joins...

It is all about set theory. Imagine two circles, which overlap
(http://en.wikipedia.org/wiki/Venn_diagram#Example as an example).

For that example, simplistically, A contains me and my emu. B contains
my emu and the my deathwatch beetle.


SELECT * FROM A,B WHERE A.id = B.id (My emu)

SELECT * FROM A INNER JOIN B ON A.id = B.id (My emu)

SELECT * FROM A LEFT OUTER JOIN B ON A.id = B.id (Me and My emu)

SELECT * FROM A RIGHT OUTER JOIN B ON A.id = B.id (My emu and my
deathwatch beetle)

SELECT * FROM A FULL OUTER JOIN B ON A.id = B.id

returns in interesting set (essentially all things but 1 column for each table).

Me, null
My emu, my emu
null, My deathwatch beetle.

If you were using ISNULL ...

SELECT ISNULL(A.name, B.name) AS name FROM A FULL OUTER JOIN B ON A.id = B.id

would return all things

Me
My emu
My deathwatch beetle.


And, (I think), finally, an inversion of the inner join.


SELECT ISNULL(A.name, B.name) AS name FROM A FULL OUTER JOIN B ON A.id
= B.id WHERE A.id IS NULL OR B.id IS NULL

returns

Me
My deathwatch beetle.

All things except those 2 legged things that can fly.

I hope that helps.

Regards,

Richard.

P.S. I don't have an emu.

Clearly, or you'd know that they can't fly either...
:)

--
Peter Ford, Developer                 phone: 01580 893333 fax: 01580 893399
Justcroft International Ltd.                              www.justcroft.com
Justcroft House, High Street, Staplehurst, Kent   TN12 0AH   United Kingdom
Registered in England and Wales: 2297906
Registered office: Stag Gates House, 63/64 The Avenue, Southampton SO17 1XS

--- End Message ---
--- Begin Message ---
On 5 July 2010 14:48, Pete Ford <[email protected]> wrote:
>> P.S. I don't have an emu.
>
> Clearly, or you'd know that they can't fly either...
> :)

GIGO!!!

--- End Message ---
--- Begin Message ---
"Richard Quadling" <[email protected]> wrote in message 
news:[email protected]...
> On 5 July 2010 14:48, Pete Ford <[email protected]> wrote:
>>> P.S. I don't have an emu.
>>
>> Clearly, or you'd know that they can't fly either...
>> :)
>
> GIGO!!!


Does that mean you do have a deathwatch beetle?

Gary 



__________ Information from ESET Smart Security, version of virus signature 
database 5252 (20100705) __________

The message was checked by ESET Smart Security.

http://www.eset.com





--- End Message ---
--- Begin Message ---

On Jul 5, 2010, at 9:14 AM, Peter Lind wrote:

On 5 July 2010 15:02, Jason Pruim <[email protected]> wrote:
Hi everyone,

I'll admit right now that I'm still trying to wrestle with inner joins...
Which leaves me with this code right here:

<?PHP

if(isset($_GET['cat'])) {
           $cat = mysql_real_escape_string($_GET['cat']);

       }

       if(isset($cat)) {
              $sql = "SELECT * FROM ".$cfgtableContent." INNER JOIN
".$cfgtableCategories." WHERE ".$cfgtableContent.".postCat = ". $cat." ORDER
BY ".$cfgtableContent.".postNumber DESC";

       }

?>

Now... I know the problem is probably staring an experienced inner join master in the face and I don't even have to say it... But for those who don't know or you might be searching the archives and want to learn from my blatant misunderstanding of inner joins I'll outline said problem in the
following lines.

What I want to achieve: Add navigation by category to my blog. IE: If I want to display just Personal posts click on the "Personal" link and all other
posts magically disappear.

What I'm getting now: I have 5 categories in my blog now... I get 5 copies
of each post repeated down the site all with a different category...

All the variables are filled in correctly which I have checked with simple echo's. I have also tried removing the escaping of the data with no change
so if possible I'd like to leave it in there as is :)

I have also tried switching it from the above to this:

<?PHP

              $sql = "SELECT * FROM ".$cfgtableContent." INNER JOIN
".$cfgtableContent." WHERE ".$cfgtableCategories.".postCat = ". $cat." ORDER
BY ".$cfgtableContent.".postNumber DESC";

?>

with no change...


There's no join clause in your query, i.e. nothing to tie the two
tables together. That will leave you with a cartesian product, i.e.
for every row in table a you'll get the entire table b joined on. You
need to specify how the tables you're joining together are related.

Something like

SELECT
 a.row
FROM
 a
 JOIN b ON b.a_id = a.id

Regards
Peter

Hi Peter,

Thanks for point it out... I thought I had it set right but obviously not quite... You were able to put me onto the right path and after playing with the variables I ended up with this:

<?PHP

        if(isset($cat)) {
$sql = "SELECT * FROM ".$cfgtableContent.",". $cfgtableCategories." WHERE ".$cfgtableCategories.".catID = ".$cat." AND ".$cfgtableContent.".postCat = ".$cfgtableCategories.".catID ORDER BY ".$cfgtableContent.".postNumber DESC";
               }

?>

Which works just fine for me! :)

Joins can be some tricky stuff if you don't understand it completely...



--- End Message ---
--- Begin Message ---
Hello Everyone,
Thanks for all the suggestions on my sticky form problem. I've changed
my action attribute to empty "" as per the article on PHP_SELF.
I'm still having an issue getting the form to redisplay. For example,
if i don't fill out the name field how would i get the form to
redisplay with all the rest of the entered values? I've got text
values working, but combo boxes are not. I've got three values i'll
take the type one here, one is zero and it's choice is to select an
option. That's a required field, so if it's skipped zero is given, I
want to indicate that's not valid and redisplay the form. Event is 1
and meeting is 2 or maybe i've got those reversed but it doesn't
matter. So, say I select 2 for meeting or event or whatever, but again
i don't fill in the name field. I want the form to redisplay, but to
have the combo box values filled in.
I'm certain this is conceptual and coding on my part, I'd appreciate
any assistance.
Thanks.
Dave.


On 7/4/10, Paul M Foster <[email protected]> wrote:
> On Sun, Jul 04, 2010 at 01:57:01PM -0400, David Mehler wrote:
>
>> Hello,
>> I've got a form with several required fields of different types. I
>> want to have the php script process it only when all the required
>> fields are present, and to redisplay the form with filled in values on
>> failure so the user won't have to fill out the whole thing again.
>> One of my required fields is a text input field called name. If it's
>> not filled out the form displayed will show this:
>>
>> <input type="text" name="name" id="name" size="50" value="<?php
>> echo($name); ?>" /> <br />
>>
>> Note, I've got $_POST* variable processing before this so am assigning
>> that processing to short variables.
>> If that field is filled out, but another required one is not that form
>> field will fill in the value entered for the name field.
>> This is working for my text input fields, but not for either select
>> boxes or textareas. Here's the textarea also a required field:
>>
>> <textarea name="description" id="description" cols="50" rows="10"
>> value="<?php echo($description); ?>"></textarea>
>
> Textarea fields don't work this way. To display the prior value, you
> have to do this:
>
> <textarea name="description><?php echo $description; ?></textarea>
>
>>
>> What this does, if a user fills out this field, but misses another, it
>> should echo the value of what was originally submitted. It is not
>> doing this. Same for my select boxes, here's one:
>>
>> <select name="type" id="type" value="<?php echo($type); ?>">
>> <option value="0" selected="selected">-- select type --</option>
>> <option value="meeting"> - Meeting - </option>
>> <option value="event"> - Event - </option>
>> </select>
>
> The "value" attribute of a select field won't do this for you. You have
> to actually set up each option with an either/or choice, like this:
>
> <option value="0" <?php if ($type == 'meeting') echo 'selected="selected"';
> ?>> - Meeting - </option>
>
> Since doing this is pretty tedious, I use a function here instead:
>
> function set_selected($fieldname, $value)
> {
>       if ($_POST[$fieldname] == $value)
>               echo 'selected="selected"';
> }
>
> And then
>
> <option value="meeting" <?php set_selected('type', 'meeting');
> ?>>Meeting</option>
>
> HTH,
>
> Paul
>
> --
> Paul M. Foster
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
Ash - Thanks for correcting me [should I say us ;) ]. So, if my understandng
is right, we should use # instead of the superglobal variable.

David - Sorry to have written that. I was not aware of the implications of
the grand old way of doing it. :)

Regards,
Shreyas

On Mon, Jul 5, 2010 at 4:24 AM, Ashley Sheridan 
<[email protected]>wrote:

> On Sun, 2010-07-04 at 18:23 -0400, David Mehler wrote:
>
> > Hello everyone,
> > Thanks for your suggestions.
> > For my variable in the value area of the text input field I enter
> >
> > value="<?php echo $name"; ?>
> >
> > Prior to this I assign the variable $name to:
> >
> > $name = stripslashes($_POST['name']);
> >
> > I hope this is correct.
> > Sticky forms sounds exactly what i'm looking for. I've changed my
> > action attribute to
> >
> > <?php echo $_SERVER['PHP_SELF']; ?>
> >
> > The first thing I do once the page is loaded is check whether or not
> > submit is set, if it is not I display the form, which is in a function
> > call. If submit is set I want to begtin validation, so i'm deciding to
> > merge my two files in to one, I like this better. My question is say
> > for example the name text field is not filled out but all the other
> > required fields are how do I get the form to redisplay itself? I was
> > thinking a location redirect, but this doesn't sound right.
> > Thanks.
> > Dave.
> >
> >
> > On 7/4/10, Paul M Foster <[email protected]> wrote:
> > > On Sun, Jul 04, 2010 at 01:57:01PM -0400, David Mehler wrote:
> > >
> > >> Hello,
> > >> I've got a form with several required fields of different types. I
> > >> want to have the php script process it only when all the required
> > >> fields are present, and to redisplay the form with filled in values on
> > >> failure so the user won't have to fill out the whole thing again.
> > >> One of my required fields is a text input field called name. If it's
> > >> not filled out the form displayed will show this:
> > >>
> > >> <input type="text" name="name" id="name" size="50" value="<?php
> > >> echo($name); ?>" /> <br />
> > >>
> > >> Note, I've got $_POST* variable processing before this so am assigning
> > >> that processing to short variables.
> > >> If that field is filled out, but another required one is not that form
> > >> field will fill in the value entered for the name field.
> > >> This is working for my text input fields, but not for either select
> > >> boxes or textareas. Here's the textarea also a required field:
> > >>
> > >> <textarea name="description" id="description" cols="50" rows="10"
> > >> value="<?php echo($description); ?>"></textarea>
> > >
> > > Textarea fields don't work this way. To display the prior value, you
> > > have to do this:
> > >
> > > <textarea name="description><?php echo $description; ?></textarea>
> > >
> > >>
> > >> What this does, if a user fills out this field, but misses another, it
> > >> should echo the value of what was originally submitted. It is not
> > >> doing this. Same for my select boxes, here's one:
> > >>
> > >> <select name="type" id="type" value="<?php echo($type); ?>">
> > >> <option value="0" selected="selected">-- select type --</option>
> > >> <option value="meeting"> - Meeting - </option>
> > >> <option value="event"> - Event - </option>
> > >> </select>
> > >
> > > The "value" attribute of a select field won't do this for you. You have
> > > to actually set up each option with an either/or choice, like this:
> > >
> > > <option value="0" <?php if ($type == 'meeting') echo
> 'selected="selected"';
> > > ?>> - Meeting - </option>
> > >
> > > Since doing this is pretty tedious, I use a function here instead:
> > >
> > > function set_selected($fieldname, $value)
> > > {
> > >     if ($_POST[$fieldname] == $value)
> > >             echo 'selected="selected"';
> > > }
> > >
> > > And then
> > >
> > > <option value="meeting" <?php set_selected('type', 'meeting');
> > > ?>>Meeting</option>
> > >
> > > HTH,
> > >
> > > Paul
> > >
> > > --
> > > Paul M. Foster
> > >
> > > --
> > > PHP General Mailing List (http://www.php.net/)
> > > To unsubscribe, visit: http://www.php.net/unsub.php
> > >
> > >
> >
>
>
> $_SERVER['PHP_SELF'] is not to be trusted, and shouldn't be used as the
> action of a form like this.
> http://www.mc2design.com/blog/php_self-safe-alternatives explains it all
> better than I can here, so it's worth a read, but it does list safe
> alternatives.
>
> One thing I do when creating sticky select lists is this:
>
> $colours = array('red', 'green', 'blue', 'yellow', 'pink');
>
> echo '<select name="colour">';
> for($i=0; $i<count($colours); $i++)
> {
>    $selected = (isset($_POST['colour']) && $_POST['colour'] ==
> $i)?'selected="selected"':'';
>    echo "<option value=\"$i\" $selected>{$colours[$i]}</option>";
> }
> echo '</select>';
>
> Basically, this uses PHP to not only output the list from an array
> (which itself can be populated from a database maybe) and select the
> right option if it exists in the $_POST array and matches the current
> option in the loop that's being output.
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>
>


-- 
Regards,
Shreyas Agasthya

--- End Message ---
--- Begin Message ---
The last few times I have posted to the board, I recieved an email, which 
has the subject line of ???????? ??? ??? and is written in what appears to 
be greek, then english then seemingly some arabic language.  It tells me 
that it has recieved an email from me that it suspects is spam and it has 
held until I confirm the e-mail (which I DO NOT), then my post appears on 
the board. I dont open the email, I view it (if there is a difference) in 
outlook express.

I dont want to post the email address or content, but it does not reference 
the php.net board.

Anyone else have this happen?

Gary






__________ Information from ESET Smart Security, version of virus signature 
database 5252 (20100705) __________

The message was checked by ESET Smart Security.

http://www.eset.com





--- End Message ---
--- Begin Message ---
Or, alternatively put, is there any way to find the kind of problems in
foo2 & foo3 (below), at "*compile* time"?

,----[ lint-test.php ]
| <?php
|
| error_reporting(E_ALL | E_STRICT);
|
| function foo1()
| {
|     $bar = 'cheese';
|     echo $bar;
| }
|
| function foo2()
| {
|     $bar = 'cheese';
|     echo 'cheese';
| }
|
| function foo3()
| {
| //    $bar = 'cheese';
|     echo $bar;
| }
|
| foo1();
| foo2();
| foo3();
|
| ?>
`----

I only get errors displayed when code happens to pass down the code
path, i.e. at runtime:
,----
| /home/jg/work $ php -l lint-test.php
| No syntax errors detected in lint-test.php
| /home/jg/work $ php lint-test.php
| cheesecheese
| Notice: Undefined variable: bar in
| /home/jg/work/lint-test.php on line 20
|
| Call Stack:
|     1.0000      61488   1. {main}()
|     /home/jg/work/lint-test.php:0
|     1.0000      61680   2. foo3()
|     /home/jg/work/lint-test.php:25
`----

If foo3 never happens to be called when I am doing my testing (for
example if the call is in some "if" branch that is never exercised) then
it only gets found in production, so I would like to find this kind of
thing using a static analyser. The kind of problem in foo2 I could live
with, but would like to find as well, if possible. (Obviously I am using
these two example problems as indicative of the type of things I want to
find, it isn't an exhaustive list!)

BTW, what problems *does* "php -l" pick up? I can't find a description
anywhere.

--- End Message ---

Reply via email to