php-general Digest 18 Jun 2011 23:34:54 -0000 Issue 7365
Topics (messages 313598 through 313605):
Re: Doctrine madness!
313598 by: Nathan Nobbe
Submit Using An Image Form Processing
313599 by: Ron Piggott
313600 by: Jason Pruim
313601 by: Geoff Lane
313602 by: Ashley Sheridan
313605 by: Shawn McKenzie
Re: mysqli_query() returns NULL?
313603 by: Alex
313604 by: Ashley Sheridan
Administrivia:
To subscribe to the digest, e-mail:
php-general-digest-subscr...@lists.php.net
To unsubscribe from the digest, e-mail:
php-general-digest-unsubscr...@lists.php.net
To post to the list, e-mail:
php-gene...@lists.php.net
----------------------------------------------------------------------
--- Begin Message ---
On Fri, Jun 17, 2011 at 1:19 PM, Jim Lucas <li...@cmsws.com> wrote:
> On 6/16/2011 3:15 PM, Nathan Nobbe wrote:
> > what it really amounts to is php is good at doing 1 thing and 1 thing
> only,
> > generating web pages. for anything else, including command line scripts
> > that run for more than 30 seconds, choose an actual programming language
> or
> > be prepared to deal w/ hacky, disgusting workarounds.
> >
>
> Nathan,
>
> I would have to disagree with your statement about using PHP for
> applications
> that take more then 30 seconds or CLI scripts.
>
> I have a daemon (read: scripts) that I wrote using PHP. It listens on a
> few UDP
> sockets and maintains an open connection to mysql. It receives server
> updates
> and other client requests for data. When it receives a client update it
> updates
> a couple tables in mysql. When it receives a request from a server for
> data, it
> goes to mysql gets all needed data, compiles it into the format requested
> and
> sends it down the wire.
>
> This daemon starts when my system starts up. As of this morning it has
> been
> running non stop since Feb 28th (about 108 days). Between then and now it
> has
> received over 35M server updates and over 1.8M client requests. I think it
> gets
> used a bit.
>
> So, to say that doing anything with PHP that takes longer then 30 seconds
> to
> complete will require you to use hacky and disgusting workarounds is false.
>
> I have no hacks nor disgusting workarounds in my scripts. Combined the
> scripts
> total about 200 lines, over half of which is either comments or vertical
> white
> space.
>
> It has been running pretty much non-stop since August 2007 with minimal
> maintenance needed.
Jim,
thanks for your response. This was an exaggeration based on my frustration
with this issue. i've written long running php scripts before, but in
general my experience is long running scripts and daemons are second
class citizens for php by design.
and in fact i do need to employ a hacky workaround in this situation. and
also no one has addressed my actual question! the thread turned into a
debate about the merit of frameworks, which i simply dont have time to
engage in. threads like this are the reason i hardly contribute to the list
anymore.
if youd like to help me determine what the non-disgusting workaround in this
case is, that would be awesome. but until im to the bottom of the real
issue, ill maintain some distain for cli / daemon scripts in php.
-nathan
--- End Message ---
--- Begin Message ---
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
The Verse of the Day
“Encouragement from God’s Word”
http://www.TheVerseOfTheDay.info
--- End Message ---
--- Begin Message ---
On Jun 18, 2011, at 11:54 AM, "Ron Piggott" <ron.pigg...@actsministries.org>
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
--- End Message ---
--- Begin Message ---
On Saturday, June 18, 2011, Ron Piggott wrote:
> 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.
An image causes two variables (name_x and name_y) to be set where
these give the coordinates of the point on the image where the user
clicked. So, the corresponding x and y $_GET or $_POST variables will
be set and using your example, if you had:
<form action='adjust_cart.php' method='post'>
<INPUT TYPE="image"
SRC="http://www.theverseoftheday.info/store-images/trash_can.png"
WIDTH="20" HEIGHT="20" style="float: right;border:0;"
alt="Remove Product From Shopping Cart" name="remove_product" />
</form>
Then in the called script, you could use:
if (isset($_POST['remove_product_x'])){
// do stuff to remove product from cart
}
HTH,
--
Geoff
--- End Message ---
--- Begin Message ---
Geoff Lane <ge...@gjctech.co.uk> wrote:
>On Saturday, June 18, 2011, Ron Piggott wrote:
>
>> 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.
>
>An image causes two variables (name_x and name_y) to be set where
>these give the coordinates of the point on the image where the user
>clicked. So, the corresponding x and y $_GET or $_POST variables will
>be set and using your example, if you had:
>
><form action='adjust_cart.php' method='post'>
><INPUT TYPE="image"
>SRC="http://www.theverseoftheday.info/store-images/trash_can.png"
> WIDTH="20" HEIGHT="20" style="float: right;border:0;"
> alt="Remove Product From Shopping Cart" name="remove_product" />
></form>
>
>Then in the called script, you could use:
>
>if (isset($_POST['remove_product_x'])){
> // do stuff to remove product from cart
>}
>
>HTH,
>
>--
>Geoff
>
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php
What browser did you test your original script on, because IE has "problems"
with image buttons on forms. Better to use a regular submit button and style it.
Don't use links. They might work fine, but search engines follow them, and can
cause pains with scripts that don't take them into consideration.
Ashley Sheridan
http://www.ashleysheridan.co.uk
--
Sent from my Android phone with K-9 Mail. Please excuse my brevity.
--- End Message ---
--- Begin Message ---
On 06/18/2011 11:06 AM, Jason Pruim wrote:
>
> On Jun 18, 2011, at 11:54 AM, "Ron Piggott" <ron.pigg...@actsministries.org>
> 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.
--
Thanks!
-Shawn
http://www.spidean.com
--- End Message ---
--- Begin Message ---
If you were to use the proper object form of it, you'd spot the mistake, as it
will tell you that you are trying to perform an action on a non-object.
It might be a bug, or the developers might not have cared figuring that if you
threw it in an if(!...) it would validate as false anyways. But it.might be a
bug or an oversight. It might actually be falling through some ifs and
returning the result that was instantiated as null, I dunno...
Sent from my Verizon Wireless 4GLTE smartphone
----- Reply message -----
From: "James Colannino" <ja...@colannino.org>
To: <php-gene...@lists.php.net>
Subject: [PHP] mysqli_query() returns NULL?
Date: Fri, Jun 17, 2011 4:40 pm
Hey everyone,
After reading the documentation for mysqli_query(), I was lead to
believe that on any error it would return false. However, through a
stupid mistake, I discovered that when I specify an invalid value for
the database link identifier (in my case, I accidentally passed an
integer), instead of false I get a return value of NULL. Does anyone
know why?
Thanks!
James
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
Alex <niks...@gmail.com> wrote:
>If you were to use the proper object form of it, you'd spot the
>mistake, as it will tell you that you are trying to perform an action
>on a non-object.
>
>It might be a bug, or the developers might not have cared figuring that
>if you threw it in an if(!...) it would validate as false anyways. But
>it.might be a bug or an oversight. It might actually be falling through
>some ifs and returning the result that was instantiated as null, I
>dunno...
>
>Sent from my Verizon Wireless 4GLTE smartphone
>
>----- Reply message -----
>From: "James Colannino" <ja...@colannino.org>
>To: <php-gene...@lists.php.net>
>Subject: [PHP] mysqli_query() returns NULL?
>Date: Fri, Jun 17, 2011 4:40 pm
>
>
>Hey everyone,
>
>After reading the documentation for mysqli_query(), I was lead to
>believe that on any error it would return false. However, through a
>stupid mistake, I discovered that when I specify an invalid value for
>the database link identifier (in my case, I accidentally passed an
>integer), instead of false I get a return value of NULL. Does anyone
>know why?
>
>Thanks!
>
>James
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php
You'll only get an error if there was an error with the query. A query that has
no result is still a valid query, so won't return an error. It's quite common
to check the value of mysql_num_rows() before trying to use the results of the
query.
Ashley Sheridan
http://www.ashleysheridan.co.uk
--
Sent from my Android phone with K-9 Mail. Please excuse my brevity.
--- End Message ---