php-general Digest 20 Jun 2011 11:17:13 -0000 Issue 7367

Topics (messages 313608 through 313612):

Re: Submit Using An Image Form Processing
        313608 by: Ashley Sheridan
        313609 by: tedd
        313610 by: Jason Pruim
        313611 by: Shawn McKenzie

Re: Doctrine madness!
        313612 by: Ford, Mike

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 ---

tedd <[email protected]> wrote:

>At 6:34 PM -0500 6/18/11, Shawn McKenzie wrote:
>>
>>Get method is for retrieval only.  It is not for anything that has a
>>consequence (insert, update, delete, send email, etc.).  Use only post
>>for those.
>>
>>--
>>Thanks!
>>-Shawn
>
>
>Why?
>
>Cheers,
>
>tedd
>
>--
>-------
>http://sperling.com/
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php

That's just the http spec. It's because browsers and servers know how to 
correctly handle the different types of connections.

Some browsers make multiple connections for get, which is one of the main 
reasons for people having problems with multiple hits on a page being 
registered when only one was expected.

Ashley Sheridan
http://www.ashleysheridan.co.uk
--
Sent from my Android phone with K-9 Mail. Please excuse my brevity.

--- End Message ---
--- Begin Message ---
At 11:54 AM -0400 6/18/11, Ron Piggott wrote:
I am writing a shopping cart using the PayPal API. Shopping cart works. Just adding additional functionality.
From the shopping cart contents I am trying to make it so the user may click on a picture of a trash can to delete the item. I wrote the following line of code:

<INPUT TYPE="image" SRC="http://www.theverseoftheday.info/store-images/trash_can.png"; WIDTH="20" HEIGHT="20" style="float: right;boarder: 0;" alt="Remove Product From Shopping Cart" name="remove_product" value="1" />

But when I have do:

echo $remove_product;

I am not getting anything. Is there a correct way of passing a variable through an image? The value in this above example is the auto_increment value of the product. From this I could remove the item from the shopping cart.
OR

Is there a better way to pass a variable through a graphic? I am hoping for the shopping cart contents to be just 1 form where users will have several options (change quantities, delete specific items). I can't use a hidden field.
Thank you for your help.

Ron

Ron:

You don't need to pass a value. What you need is simply a trigger to do something. As such, you can use lot's of things.

In this case, a button should work.

http://www.htmlcodetutorial.com/forms/_BUTTON.html

However, I would take all the styling (including dimensions) out of it and place those in a css sheet.

Also, what's wrong with a hidden field?

Cheers,

tedd

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

--- End Message ---
--- Begin Message ---
On Jun 18, 2011, at 7:34 PM, Shawn McKenzie wrote:

> On 06/18/2011 11:06 AM, Jason Pruim wrote:
>> 
>> On Jun 18, 2011, at 11:54 AM, "Ron Piggott" <[email protected]> 
>> wrote:
>> 
>>> <INPUT TYPE="image" 
>>> SRC="http://www.theverseoftheday.info/store-images/trash_can.png"; 
>>> WIDTH="20"  HEIGHT="20" style="float: right;boarder: 0;" alt="Remove 
>>> Product From Shopping Cart" name="remove_product" value="1" />
>> 
>> I would wrap the image in a link like so:
>> <a href="mypage.php?id={$autoincrementnum}"><img src="blah"></a>
>> 
>> And then have a get look for that variable:
>> 
>> $id=$_get[id];
>> 
>> If (isset($id)) {
>> 
>> //delete code here
>> }
>> 
>> Check all that before you run it.... I'm writing from my smart phone and 
>> it's all untested. Hopefully it gives you a start though. 
>> 
>> Jason Pruim 
> 
> Get method is for retrieval only.  It is not for anything that has a
> consequence (insert, update, delete, send email, etc.).  Use only post
> for those.

I've actually used $_GET in the way I described because then it doesn't require 
submitting a form to be able to delete something from a list.

with $_POST you would have to submit the form, so you would need to build an 
array of check boxes to store what ones you want to delete, and then go through 
and process the array to remove all the proper items.

But with the $_GET you can process it one at a time. I had a system up and 
working for maintaining a address database for quite awhile and it worked great 
for me.

--- End Message ---
--- Begin Message ---
On 06/19/2011 07:26 AM, tedd wrote:
> At 6:34 PM -0500 6/18/11, Shawn McKenzie wrote:
>>
>> Get method is for retrieval only.  It is not for anything that has a
>> consequence (insert, update, delete, send email, etc.).  Use only post
>> for those.
>>
>> -- 
>> Thanks!
>> -Shawn
> 
> 
> Why?
> 
> Cheers,
> 
> tedd
> 

The convention has been established that the GET and HEAD methods SHOULD
NOT have the significance of taking an action other than retrieval.
These methods ought to be considered "safe". This allows user agents to
represent other methods, such as POST, PUT and DELETE, in a special way,
so that the user is made aware of the fact that a possibly unsafe action
is being requested.

http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html

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

--- End Message ---
--- Begin Message ---
> -----Original Message-----
> From: Nathan Nobbe [mailto:[email protected]]
> Sent: 16 June 2011 17:51

[...]
 
> Here's what's going on, I instantiate a model object for the product
> table
> from my application
> 
> $newRecord = new Product();
> 
> at this point memory usage goes up noticeably.  I don't really care
> though
> because I figure I can delete it, but look at this madness I have
> going
> (which *fails* to free up the memory)
> 
> $newRecord->clearRelated();
> $newRecord->free();
> unset($newRecord);
> gc_collect_cycles();
> 
> after all of this memory consumption is still dramatically higher
> than prior
> to the first call creating the object above.  This I've verified
> through
> memory_get_usage().
> 
> here's the output from the memory_get_usage() calls
> 
> int(166461440) // before new Product()
> int(169345024) // directly after new Product()
> int(169345024) // after madness trying to free memory used by new
> Product()

I know nothing about Doctrine, but after all the unrelated
discussion and your renewed plea for someone to address the issue,
I decided to write conduct some simple tests.

So I wrote a very simple class that basically just hogs some memory
when instantiated, and tried some simple instantiations and
releases.

At each stage, I measured current and peak memory usage, and the
results were:

  Initial
    Usage = 262,144
    Peak  = 262,144

  After single instantiation ($a = new Hog();)
    Usage = 3,932,160
    Peak  = 3,932,160

  After resetting that to NULL ($a = NULL;)
    Usage = 524,288
    Peak  = 3,932,160

  After second single instantiation ($b = new Hog();)
    Usage = 3,932,160
    Peak  = 3,932,160

  After instantiating 3 more
    Usage = 15,728,640
    Peak  = 15,728,640

  After resetting all those to NULL
    Usage = 1,310,720
    Peak  = 15,728,640

  After 4 instantiations again
    Usage = 15,728,640
    Peak  = 15,728,640

This seems to be pretty much what I (and you!) would expect,
indicating that the memory used by objects can be recovered by PHP
when the object is released. This being the case, I would suggest
that something in your script is not freeing things up the way it
should, the prime candidate being the clearRelated() method. Either
that, or you have circular references that the gc_collect_cycles()
function is unable to recover. But, bottom line, I'd say you're
right that it's probably a Doctrine-related issue as the underlying
PHP functionality seems to work reasonably well.

Cheers!

Mike

-- 
Mike Ford,
Electronic Information Developer, Libraries and Learning Innovation,  
Leeds Metropolitan University, 507 Portland Building, City Campus, 
Portland Way, LEEDS,  LS1 3HE,  United Kingdom 
E: [email protected]     T: +44 113 812 4730





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

--- End Message ---

Reply via email to