php-general Digest 11 Mar 2011 18:21:39 -0000 Issue 7221

2011-03-11 Thread php-general-digest-help

php-general Digest 11 Mar 2011 18:21:39 - Issue 7221

Topics (messages 311772 through 311773):

Re: Issue with Quick Email validation
311772 by: NetEmp

Re: [PHP-WEBMASTER] php with htmlspecialchars function
311773 by: Daniel Brown

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


--
---BeginMessage---
Great Going Bob!

Wishing you Lots of Fun ahead!

Cheers

NetEmp

On Fri, Mar 11, 2011 at 12:54 AM, rob...@myself.com wrote:

  Yep, new to programming and starting with php
 -taken classes but don't have the experience yet

 Not asking for complete mail addresses probably work best in most
 companies, but we're so used to typing our complete address that I would
 need to have a control and removal of domain -only to add again for sending
 the mail.

 Yes the first part of this already has a separate account validation, it
 also logs a request into our internal support system.
 Naturally if a external mail address is filled in there will be no request
 created, and I could have stopped the script there.
 This way I can stop use of external mail, while a contractor that not yet
 have a account in our logging system will still be able to send a Email
 request


   At a later stage I might add email validation and even pick up details
 such as phone numbers and titles, but for now this little extra piece was
 sufficient

 Thanks again,
 Bob

  -Original Message-
 From: NetEmp net.ser...@gmail.com
 To: rquadl...@googlemail.com
 Cc: Richard Quadling rquadl...@gmail.com; rob...@myself.com;
 louis.huppenba...@gmail.com; php-gene...@lists.php.net
 Sent: Thu, Mar 10, 2011 3:46 pm
 Subject: Re: [PHP] Issue with Quick Email validation

  Agreed with the method suggested by Richard here, this is surely a safer
 way.

  @Robert - are you a newbie to PHP or also to web programing.. or as a
 matter of fact to programing..

  Just to share that validating user's input is always advisable, esp. in
 the web world. Thus, even if you use the method suggested by Richard, but I
 shall then also advise you to apply proper validations at the input (like
 permissible characters, maximum length allowed etc..)

  Cheers

 On Thu, Mar 10, 2011 at 5:19 PM, Richard Quadling rquadl...@gmail.comwrote:

  On 10 March 2011 11:07,  rob...@myself.com wrote:
  Thank you, that did get me past that part!
 
  Had also to put in else statement to call Email function, without doing
 so the mail was sent even though giving error
 
  Robert
 
 
 
 
 
 
 
  -Original Message-
  From: Louis Huppenbauer louis.huppenba...@gmail.com
  To: rob...@myself.com
  Cc: php-gene...@lists.php.net
  Sent: Thu, Mar 10, 2011 11:38 am
  Subject: Re: [PHP] Issue with Quick Email validation
 
 
  try != instead of ==, that should do the trick.
 
 
 
  2011/3/10  rob...@myself.com:
 
  Hi,
 
  I'm newbie to PHP and this list, possible not a new question so forgive
 me if
 
  it's a repeat
 
  I have a form where I want the submitter Email ID to only be from one
 domain
 
 
 
  Here's the part I'm having issues with
 
 
 
 $domain = explode( @, $who);
 
 if ( $domain[1] == company.com) {
 
 echo $domain[1];
 
 echo(h3Email invalid./h3);
 
 exit;
 
 }
 
 
 
  First Echo is just for me to check
 
  I type in a correct Email ID, say m...@company.com
 
 
 
  The return of this is:
 
 
 
  company.com
 
  Email invalid.
  As far as I can see this if statement should not fall in, what am I
 missing?

  Why bother asking for the entire address? Just ask for the name part
 and display the domain name on the form?

 label for=emailEnter your email address: input type=text
 name=email id=email /@company.com/label

 sort of thing.


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

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



---End Message---
---BeginMessage---
On Fri, Mar 11, 2011 at 13:07, Lisa Nguyen lisa.ngu...@jpl.nasa.gov wrote:
 Hi

 I use one of your example to test the htmlspecialchars :

 ?php
 $new = htmlspecialchars(a href='test'Test/a, ENT_QUOTES);
 echo $new; // lt;a href=#039;test#039;gt;Testlt;/agt;
 ?

 On my browse, it display like below
 a href='test'Test/a

 Instead:
 Test

 Please help me how display on browse only Test, not like view source.

First, this isn't a support channel.  Please view
http://php.net/support for a brief list of available support methods.
The list you want is PHP General (CC'd on this email, and 

php-general Digest 12 Mar 2011 06:21:46 -0000 Issue 7222

2011-03-11 Thread php-general-digest-help

php-general Digest 12 Mar 2011 06:21:46 - Issue 7222

Topics (messages 311774 through 311793):

$_POST variable
311774 by: Danny
311775 by: Daniel Brown
311777 by: Steve Staples
311778 by: richard gray
311779 by: Geoff Lane
311781 by: Shawn McKenzie
311783 by: richard gray
311784 by: Jim Lucas
311785 by: Shawn McKenzie
311788 by: Kirk Bailey

Possible to pinpoint peak memory usage?
311776 by: Daniel Hong
311782 by: David Harkness
311786 by: Daniel Hong

Re: [PHP-WEBMASTER] php with htmlspecialchars function
311780 by: NetEmp

web site link request
311787 by: Kirk Bailey

Zend Framework - getParam() Question
311789 by: Dan Joseph
311790 by: NetEmp
311791 by: Midhun Girish

Re: Check for open file
311792 by: Tommy Pham

Re: Delaying $(document).ready() in jQuery until php script finish
311793 by: Tommy Pham

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


--
---BeginMessage---
Hi guys,

I have a form that has a long list of radio-bottons inside of it. The
radio-buttons are dynamically created via php and MySQL.

Here is an example of one of the radio buttons:

input type=radio name=?php print (radio_.$result_from_mysql) ; ? 
value=0
input type=radio name=?php print (radio_.$result_from_mysql) ; ? 
value=1

Now, when I submit this form to another page for processing, how would I catch
the above radio-button's $_POST name since I do not know the name, only that it
starts with radio_ ?

Thank You

Danny
---End Message---
---BeginMessage---
On Fri, Mar 11, 2011 at 14:28, Danny dannydeb...@gmail.com wrote:
[snip!]

 Now, when I submit this form to another page for processing, how would I 
 catch
 the above radio-button's $_POST name since I do not know the name, only that 
 it
 starts with radio_ ?

One method is a foreach() loop.

?php
foreach ($_POST as $k = $v) {
if (preg_match('/^radio_/Ui',trim($k))) {
echo $k.' is a match, and it\'s value is '.$v.'.br/'.PHP_EOL;
}
}
?

-- 
/Daniel P. Brown
Network Infrastructure Manager
http://www.php.net/
---End Message---
---BeginMessage---
On Fri, 2011-03-11 at 21:28 +0200, Danny wrote:
 Hi guys,
 
 I have a form that has a long list of radio-bottons inside of it. The
 radio-buttons are dynamically created via php and MySQL.
 
 Here is an example of one of the radio buttons:
 
 input type=radio name=?php print (radio_.$result_from_mysql) ; ? 
 value=0
 input type=radio name=?php print (radio_.$result_from_mysql) ; ? 
 value=1
 
 Now, when I submit this form to another page for processing, how would I 
 catch
 the above radio-button's $_POST name since I do not know the name, only that 
 it
 starts with radio_ ?
 
 Thank You
 
 Danny
 

loop thought all the $_POST variables...

foreach($_POST as $key = $val)
{
if(susbtr($key, 0, 7) === radio_)
{
# this is what we're looking for
}
}

crude, but works... I am sure there are many ways to look for it.

Steve

---End Message---
---BeginMessage---

On 11/03/2011 20:28, Danny wrote:

Hi guys,

I have a form that has a long list of radio-bottons inside of it. The
radio-buttons are dynamically created via php and MySQL.

Here is an example of one of the radio buttons:

input type=radio name=?php print (radio_.$result_from_mysql) ; ? 
value=0
input type=radio name=?php print (radio_.$result_from_mysql) ; ? 
value=1

Now, when I submit this form to another page for processing, how would I catch
the above radio-button's $_POST name since I do not know the name, only that it
starts with radio_ ?


foreach ($_POST as $k = $v) {
if (substr($k,0,6) == 'radio_') {
echo 'Name is - ',$k,'br /';
// Do stuff...
}
}

HTH
Rich
---End Message---
---BeginMessage---
Hi Danny,

On Friday, March 11, 2011, 7:28:10 PM, you wrote:

 I have a form that has a long list of radio-bottons inside of it. The
 radio-buttons are dynamically created via php and MySQL.

 Here is an example of one of the radio buttons:

 input type=radio name=?php print (radio_.$result_from_mysql) ; ? 
 value=0
 input type=radio name=?php print (radio_.$result_from_mysql) ; ? 
 value=1

 Now, when I submit this form to another page for processing, how would I 
 catch
 the above radio-button's $_POST name since I do not know the name, only that 
 it

You could use foreach to iterate through the post variables until you
encounter a match:

foreach ($_POST as $key = $value){
if (substr($key, 0, 6) == radio_) {
   $buttonName = $key;
   $buttonValue = 4value;
   break 2;
}
}

I haven't tried the 

[PHP] Re: [PHP-WEBMASTER] php with htmlspecialchars function

2011-03-11 Thread Daniel Brown
On Fri, Mar 11, 2011 at 13:07, Lisa Nguyen lisa.ngu...@jpl.nasa.gov wrote:
 Hi

 I use one of your example to test the htmlspecialchars :

 ?php
 $new = htmlspecialchars(a href='test'Test/a, ENT_QUOTES);
 echo $new; // lt;a href=#039;test#039;gt;Testlt;/agt;
 ?

 On my browse, it display like below
 a href='test'Test/a

 Instead:
 Test

 Please help me how display on browse only Test, not like view source.

First, this isn't a support channel.  Please view
http://php.net/support for a brief list of available support methods.
The list you want is PHP General (CC'd on this email, and you can
subscribe at http://php.net/mailinglists ).

Second, you're using htmlspecialchars(), which is converting the 
and  to lt; and gt; respectively, which will cause the browser to
display it as if it was source (though viewing the source of that
would show you the entities).

Instead, check out strip_tags(), which is likely what you want:

http://php.net/strip_tags

-- 
/Daniel P. Brown
Network Infrastructure Manager
http://www.php.net/

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



[PHP] $_POST variable

2011-03-11 Thread Danny
Hi guys,

I have a form that has a long list of radio-bottons inside of it. The
radio-buttons are dynamically created via php and MySQL.

Here is an example of one of the radio buttons:

input type=radio name=?php print (radio_.$result_from_mysql) ; ? 
value=0
input type=radio name=?php print (radio_.$result_from_mysql) ; ? 
value=1

Now, when I submit this form to another page for processing, how would I catch
the above radio-button's $_POST name since I do not know the name, only that it
starts with radio_ ?

Thank You

Danny

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



Re: [PHP] $_POST variable

2011-03-11 Thread Daniel Brown
On Fri, Mar 11, 2011 at 14:28, Danny dannydeb...@gmail.com wrote:
[snip!]

 Now, when I submit this form to another page for processing, how would I 
 catch
 the above radio-button's $_POST name since I do not know the name, only that 
 it
 starts with radio_ ?

One method is a foreach() loop.

?php
foreach ($_POST as $k = $v) {
if (preg_match('/^radio_/Ui',trim($k))) {
echo $k.' is a match, and it\'s value is '.$v.'.br/'.PHP_EOL;
}
}
?

-- 
/Daniel P. Brown
Network Infrastructure Manager
http://www.php.net/

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



[PHP] Possible to pinpoint peak memory usage?

2011-03-11 Thread Daniel Hong
Hello,

Is it possible to pinpoint the location where the most memory was used? I
log memory_get_peak_usage() in sections of my code where I believe the most
memory would be consumed, but I haven't had luck with getting an accurate
picture. I also log the peak usage at the very end of the code. I can see
memory usage go up in places that I expected it to, but then things are
pretty much flat lined. However, the peak usage at the very end shows a much
higher number, sometimes it could be twice as large.

I'm also tracing with xdebug. At the beginning of the trace memory starts
off low, then it goes up as things are allocated. It also goes back down as
things are deallocated. But never do I see the numbers as high as what PHP
is reporting as the peak. It looks like xdebug traces at every step of
execution, shouldn't the memory usage shown in the trace be the actual usage
for every single step in the code? Why is PHP reporting that peak was much
higher?

Maybe I'm not understanding this stuff correctly?

Thanks,
daniel


Re: [PHP] $_POST variable

2011-03-11 Thread Steve Staples
On Fri, 2011-03-11 at 21:28 +0200, Danny wrote:
 Hi guys,
 
 I have a form that has a long list of radio-bottons inside of it. The
 radio-buttons are dynamically created via php and MySQL.
 
 Here is an example of one of the radio buttons:
 
 input type=radio name=?php print (radio_.$result_from_mysql) ; ? 
 value=0
 input type=radio name=?php print (radio_.$result_from_mysql) ; ? 
 value=1
 
 Now, when I submit this form to another page for processing, how would I 
 catch
 the above radio-button's $_POST name since I do not know the name, only that 
 it
 starts with radio_ ?
 
 Thank You
 
 Danny
 

loop thought all the $_POST variables...

foreach($_POST as $key = $val)
{
if(susbtr($key, 0, 7) === radio_)
{
# this is what we're looking for
}
}

crude, but works... I am sure there are many ways to look for it.

Steve


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



Re: [PHP] $_POST variable

2011-03-11 Thread richard gray

On 11/03/2011 20:28, Danny wrote:

Hi guys,

I have a form that has a long list of radio-bottons inside of it. The
radio-buttons are dynamically created via php and MySQL.

Here is an example of one of the radio buttons:

input type=radio name=?php print (radio_.$result_from_mysql) ; ? 
value=0
input type=radio name=?php print (radio_.$result_from_mysql) ; ? 
value=1

Now, when I submit this form to another page for processing, how would I catch
the above radio-button's $_POST name since I do not know the name, only that it
starts with radio_ ?


foreach ($_POST as $k = $v) {
if (substr($k,0,6) == 'radio_') {
echo 'Name is - ',$k,'br /';
// Do stuff...
}
}

HTH
Rich

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



[PHP] Re: $_POST variable

2011-03-11 Thread Geoff Lane
Hi Danny,

On Friday, March 11, 2011, 7:28:10 PM, you wrote:

 I have a form that has a long list of radio-bottons inside of it. The
 radio-buttons are dynamically created via php and MySQL.

 Here is an example of one of the radio buttons:

 input type=radio name=?php print (radio_.$result_from_mysql) ; ? 
 value=0
 input type=radio name=?php print (radio_.$result_from_mysql) ; ? 
 value=1

 Now, when I submit this form to another page for processing, how would I 
 catch
 the above radio-button's $_POST name since I do not know the name, only that 
 it

You could use foreach to iterate through the post variables until you
encounter a match:

foreach ($_POST as $key = $value){
if (substr($key, 0, 6) == radio_) {
   $buttonName = $key;
   $buttonValue = 4value;
   break 2;
}
}

I haven't tried the above code, but I hope someone will correct my
efforts if I'm wrong.

-- 
Geoff Lane
Cornwall, UK


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



Re: [PHP] Re: [PHP-WEBMASTER] php with htmlspecialchars function

2011-03-11 Thread NetEmp
Well Lisa, that is exactly the way htmlspecialchars is supposed to work.

Here you could also display - Test - without using any function at all,
simply echo a href='test'Test/a; and this should work well.

NetEmp

On Fri, Mar 11, 2011 at 11:51 PM, Daniel Brown danbr...@php.net wrote:

 On Fri, Mar 11, 2011 at 13:07, Lisa Nguyen lisa.ngu...@jpl.nasa.gov
 wrote:
  Hi
 
  I use one of your example to test the htmlspecialchars :
 
  ?php
  $new = htmlspecialchars(a href='test'Test/a, ENT_QUOTES);
  echo $new; // lt;a href=#039;test#039;gt;Testlt;/agt;
  ?
 
  On my browse, it display like below
  a href='test'Test/a
 
  Instead:
  Test
 
  Please help me how display on browse only Test, not like view source.

First, this isn't a support channel.  Please view
 http://php.net/support for a brief list of available support methods.
 The list you want is PHP General (CC'd on this email, and you can
 subscribe at http://php.net/mailinglists ).

Second, you're using htmlspecialchars(), which is converting the 
 and  to lt; and gt; respectively, which will cause the browser to
 display it as if it was source (though viewing the source of that
 would show you the entities).

Instead, check out strip_tags(), which is likely what you want:

http://php.net/strip_tags

 --
 /Daniel P. Brown
 Network Infrastructure Manager
 http://www.php.net/

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




[PHP] Re: $_POST variable

2011-03-11 Thread Shawn McKenzie
On 03/11/2011 01:28 PM, Danny wrote:
 Hi guys,
 
 I have a form that has a long list of radio-bottons inside of it. The
 radio-buttons are dynamically created via php and MySQL.
 
 Here is an example of one of the radio buttons:
 
 input type=radio name=?php print (radio_.$result_from_mysql) ; ? 
 value=0
 input type=radio name=?php print (radio_.$result_from_mysql) ; ? 
 value=1
 
 Now, when I submit this form to another page for processing, how would I 
 catch
 the above radio-button's $_POST name since I do not know the name, only that 
 it
 starts with radio_ ?
 
 Thank You
 
 Danny

The most common and flexible way to do this sort of thing is to use
arrays instead:

input type=radio name=radio[?php echo $result_from_mysql; ?]
value=0
input type=radio name=radio[?php echo $result_from_mysql; ?]
value=1


Then:

foreach($_POST['radio'] as $key = $value) {
   echo radio for $key is $value;
}
-- 
Thanks!
-Shawn
http://www.spidean.com

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



Re: [PHP] Possible to pinpoint peak memory usage?

2011-03-11 Thread David Harkness
On Fri, Mar 11, 2011 at 11:35 AM, Daniel Hong dan...@amagineinc.com wrote:

 Is it possible to pinpoint the location where the most memory was used?


Take a look at XHProf. [1] It will track memory and time of all function
calls. Paul Reinheimer created a GUI [2] to make dealing with the data
easier.

Peace,
David

[1] http://mirror.facebook.net/facebook/xhprof/doc.html
[2]
http://blog.preinheimer.com/index.php?/archives/355-A-GUI-for-XHProf.html


Re: [PHP] Re: $_POST variable

2011-03-11 Thread richard gray

You could use foreach to iterate through the post variables until you

encounter a match:

foreach ($_POST as $key =  $value){
 if (substr($key, 0, 6) == radio_) {
$buttonName = $key;
$buttonValue = 4value;
break 2;
 }
}

I haven't tried the above code, but I hope someone will correct my
efforts if I'm wrong.

given your code example - 'break 2;' -- s/b just 'break;'  ... 'break 
2;' is to exit the outer loop of a nested loop which is not the case here.


Rich

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



Re: [PHP] Re: $_POST variable

2011-03-11 Thread Jim Lucas
On 3/11/2011 12:03 PM, Shawn McKenzie wrote:
 On 03/11/2011 01:28 PM, Danny wrote:
 Hi guys,

 I have a form that has a long list of radio-bottons inside of it. The
 radio-buttons are dynamically created via php and MySQL.

 Here is an example of one of the radio buttons:

 input type=radio name=?php print (radio_.$result_from_mysql) ; ? 
 value=0
 input type=radio name=?php print (radio_.$result_from_mysql) ; ? 
 value=1

 Now, when I submit this form to another page for processing, how would I 
 catch
 the above radio-button's $_POST name since I do not know the name, only that 
 it
 starts with radio_ ?

 Thank You

 Danny
 
 The most common and flexible way to do this sort of thing is to use
 arrays instead:
 
 input type=radio name=radio[?php echo $result_from_mysql; ?]
 value=0
 input type=radio name=radio[?php echo $result_from_mysql; ?]
 value=1
 
 
 Then:
 
 foreach($_POST['radio'] as $key = $value) {
echo radio for $key is $value;
 }

Your example would be good if the OP wanted checkbox'es.  But with radio
buttons, the whole point (most of the time) is to have the form only allow you
to have one of the radio input fields selected at any given time.  How you
showed it, it would not see the uniqueness of the radio button names, and
therefor allow more than one of the radio input fields to be selected at a time.

I would try something like this:

As long as this is correct:

input type=radio name=radio_?php echo $result_from_mysql; ? value=0 
/Zero
input type=radio name=radio_?php echo $result_from_mysql; ? value=1 
/One

Then I would do the following:

foreach ($_POST as $k = $v) {
  if ( strpos(trim($k), 'radio_') === 0 ) {
echo $k.' is a match, and it\'s value is '.$v.'.br/'.PHP_EOL;
  }
}

Jim Lucas

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



Re: [PHP] Re: $_POST variable

2011-03-11 Thread Shawn McKenzie
On 03/11/2011 02:33 PM, Jim Lucas wrote:
 On 3/11/2011 12:03 PM, Shawn McKenzie wrote:
 On 03/11/2011 01:28 PM, Danny wrote:
 Hi guys,

 I have a form that has a long list of radio-bottons inside of it. The
 radio-buttons are dynamically created via php and MySQL.

 Here is an example of one of the radio buttons:

 input type=radio name=?php print (radio_.$result_from_mysql) ; ? 
 value=0
 input type=radio name=?php print (radio_.$result_from_mysql) ; ? 
 value=1

 Now, when I submit this form to another page for processing, how would I 
 catch
 the above radio-button's $_POST name since I do not know the name, only 
 that it
 starts with radio_ ?

 Thank You

 Danny

 The most common and flexible way to do this sort of thing is to use
 arrays instead:

 input type=radio name=radio[?php echo $result_from_mysql; ?]
 value=0
 input type=radio name=radio[?php echo $result_from_mysql; ?]
 value=1


 Then:

 foreach($_POST['radio'] as $key = $value) {
echo radio for $key is $value;
 }
 
 Your example would be good if the OP wanted checkbox'es.  But with radio
 buttons, the whole point (most of the time) is to have the form only allow you
 to have one of the radio input fields selected at any given time.  How you
 showed it, it would not see the uniqueness of the radio button names, and
 therefor allow more than one of the radio input fields to be selected at a 
 time.

One radio button of the same name selected at a time yes.  From the OP's
code of two radios, one with value 0 and one with value 1, I assumed
these were to be a pair with the same name with only one able to be
successful.  This extends to arrays as well:

input type=radio name=radio[] value=0
input type=radio name=radio[] value=1

input type=radio name=radio[555] value=0
input type=radio name=radio[555] value=1

This works as expected, the same as the code I posted.

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

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



Re: [PHP] Possible to pinpoint peak memory usage?

2011-03-11 Thread Daniel Hong
Nice. I will give XHProf a try. Thanks!

-daniel

On Fri, Mar 11, 2011 at 12:04 PM, David Harkness
davi...@highgearmedia.comwrote:

 On Fri, Mar 11, 2011 at 11:35 AM, Daniel Hong dan...@amagineinc.comwrote:

 Is it possible to pinpoint the location where the most memory was used?


 Take a look at XHProf. [1] It will track memory and time of all function
 calls. Paul Reinheimer created a GUI [2] to make dealing with the data
 easier.

 Peace,
 David

 [1] http://mirror.facebook.net/facebook/xhprof/doc.html
 [2]
 http://blog.preinheimer.com/index.php?/archives/355-A-GUI-for-XHProf.html




[PHP] web site link request

2011-03-11 Thread Kirk Bailey
May I have suggestions of websites I would do well to visit to 
improve my php skills? Links please, with a breif description if you 
would be so good.


--
end

Very Truly yours,
 - Kirk Bailey,
   Largo Florida

   kniht
  +-+
  | BOX |
  +-+
   think


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



Re: [PHP] Re: $_POST variable

2011-03-11 Thread Kirk Bailey



On 3/11/2011 2:43 PM, Geoff Lane wrote:

[snip]

You could use foreach to iterate through the post variables until you
encounter a match:

foreach ($_POST as $key =  $value){
 if (substr($key, 0, 6) == radio_) {
$buttonName = $key;
$buttonValue = 4value;
break 2;
 }
}

I haven't tried the above code, but I hope someone will correct my
efforts if I'm wrong.


ok, now I am very new to php, so if i got this wrong be nice.

It APPEARS TO ME that you are setting a variable called buttonName 
to the extracted value stored in $key for each name in the post 
submission, and a variable named buttonValue for the item's value. 
THEM, you do the same thing again to the same destination variables 
for the next name/value pair, and so-on until they list of 
name/value pairs is exhausted. IF this understanding is correct, 
only the LAST name/value pair will emerge from the process intact; 
prior values will be obliterated. Would they not be better to append 
them to a single dimensioned array, which starts life as a null 
array? If I am getting this wrong, please administer wet mackerel 
therapy to my tired head and explain the facts.


--
end

Very Truly yours,
 - Kirk Bailey,
   Largo Florida

   kniht
  +-+
  | BOX |
  +-+
   think


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



[PHP] Zend Framework - getParam() Question

2011-03-11 Thread Dan Joseph
Hi Everyone,

Zend Framework getParam question

I'm trying to get a value from the url...

I know how to grab:

http;//www.website.com/index/user/1

that's the index controller, $this-_getParam('user'); (value = 1)..

What I'd like to be able to grab is just off one thing from the url...
example..  I want to give an article a unique/clean url... so, when I go to:

http://www.website.com/article-clean-url

I can somehow grab that 'article-clean-url' as a value and use it for a
lookup in the database.

I've tried everything and search all over the place.  I can't find the
answer.  Can someone tell me how this is done?  Thanks...

-- 
-Dan Joseph


Re: [PHP] Zend Framework - getParam() Question

2011-03-11 Thread NetEmp
Hi Dan

One method for this is to use URL Rewriting (which can be implemented on
Apache using htaccess).

Through URL Rewriting you can first make the following URL:

http://www.website.com/article-clean-url

http://www.website.com/article-clean-urlto internally behave as the
following:

http://www.website.com/index/user/ http://www.website.com/index/user/11

http://www.website.com/index/user/1and then you can use the same getParam
method to grab the value and carry out further processing.

Hope this helps.

Cheers

NetEmp

On Sat, Mar 12, 2011 at 10:04 AM, Dan Joseph dmjos...@gmail.com wrote:

 Hi Everyone,

 Zend Framework getParam question

 I'm trying to get a value from the url...

 I know how to grab:

 http;//www.website.com/index/user/1

 that's the index controller, $this-_getParam('user'); (value = 1)..

 What I'd like to be able to grab is just off one thing from the url...
 example..  I want to give an article a unique/clean url... so, when I go
 to:

 http://www.website.com/article-clean-url

 I can somehow grab that 'article-clean-url' as a value and use it for a
 lookup in the database.

 I've tried everything and search all over the place.  I can't find the
 answer.  Can someone tell me how this is done?  Thanks...

 --
 -Dan Joseph



Re: [PHP] Zend Framework - getParam() Question

2011-03-11 Thread Midhun Girish
You can also try routing in zend..
http://codeutopia.net/blog/2007/11/16/routing-and-complex-urls-in-zend-framework/

Midhun Girish



On Sat, Mar 12, 2011 at 11:16 AM, NetEmp net.ser...@gmail.com wrote:

 Hi Dan

 One method for this is to use URL Rewriting (which can be implemented on
 Apache using htaccess).

 Through URL Rewriting you can first make the following URL:

 http://www.website.com/article-clean-url

 http://www.website.com/article-clean-urlto internally behave as the
 following:

 http://www.website.com/index/user/ http://www.website.com/index/user/11

 http://www.website.com/index/user/1and then you can use the same
 getParam
 method to grab the value and carry out further processing.

 Hope this helps.

 Cheers

 NetEmp

 On Sat, Mar 12, 2011 at 10:04 AM, Dan Joseph dmjos...@gmail.com wrote:

  Hi Everyone,
 
  Zend Framework getParam question
 
  I'm trying to get a value from the url...
 
  I know how to grab:
 
  http;//www.website.com/index/user/1
 
  that's the index controller, $this-_getParam('user'); (value = 1)..
 
  What I'd like to be able to grab is just off one thing from the url...
  example..  I want to give an article a unique/clean url... so, when I go
  to:
 
  http://www.website.com/article-clean-url
 
  I can somehow grab that 'article-clean-url' as a value and use it for a
  lookup in the database.
 
  I've tried everything and search all over the place.  I can't find the
  answer.  Can someone tell me how this is done?  Thanks...
 
  --
  -Dan Joseph
 



Re: [PHP] Check for open file

2011-03-11 Thread Tommy Pham
On Fri, Mar 4, 2011 at 7:09 AM, Steve Staples sstap...@mnsi.net wrote:


 Depending on the size of the file, wouldn't this fall under the 2gb
 limitation on windows 32bit OS?  I ran into this problem on a project I
 was working on, and ended up switching to Python (but that is a WHOLE
 other conversation)

 just food for thought, since I am not sure of the size of files they are
 dealing with.

 Steve



Jumping in late.  I've been too busy.

Steve,

I think you're probably referring to FAT32 file system.  IIRC, NTFS
doesn't have that low limit. [1]

Regards,
Tommy

[1] http://technet.microsoft.com/en-us/library/cc938937.aspx

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



Re: [PHP] Re: Delaying $(document).ready() in jQuery until php script finish

2011-03-11 Thread Tommy Pham
I think the OP is having both PHP  JS codes mixed and scattered all
over the page.  If chunked-encoding used without any ob*
implementation, then that's the problem he'll experience.

Richard,

I recommend to put the $(document).ready() and any JS scriptlets
within body/body tags at the very bottom of the HTML document just
right before /body.  This would allow the mixed PHP/HTML to finish
without creating problems for your JS code(s).  The other solution is
implement output buffer using ob* functions.

Regards,
Tommy

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



Re: [PHP] Re: Delaying $(document).ready() in jQuery until php script finish

2011-03-11 Thread David Hutto
Although, right now, if I were going to be using all of those
languages in unison(and I am), then I'd go with C, and spit them out
to the browser for lower level control, as well as, to remain familiar
with some of the main languages being used currently.

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



Re: [PHP] Re: Delaying $(document).ready() in jQuery until php script finish

2011-03-11 Thread David Hutto
On Sat, Mar 12, 2011 at 1:21 AM, Tommy Pham tommy...@gmail.com wrote:
 I think the OP is having both PHP  JS codes mixed and scattered all
 over the page.  If chunked-encoding used without any ob*
 implementation, then that's the problem he'll experience.

 Richard,

 I recommend to put the $(document).ready() and any JS scriptlets
 within body/body tags at the very bottom of the HTML document just
 right before /body.  This would allow the mixed PHP/HTML to finish
 without creating problems for your JS code(s).

Why not separate them all, i.e. js, php, html, and if it was in there,
css. If you can use them all, then separating them out should be
*easy*(I still would have to use references for that many languages).
Think of it as an expository writing, with the includes being the main
topics, the content being composed of these higher ideas, and the
conclusion, just closing it out.

Pick the focus, I'd say php, and echo the rest out. Or html, and
include the php, css and js.



 The other solution is
 implement output buffer using ob* functions.

 Regards,
 Tommy

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





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

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



Re: [PHP] Re: Delaying $(document).ready() in jQuery until php script finish

2011-03-11 Thread Tommy Pham
On Fri, Mar 11, 2011 at 10:31 PM, David Hutto smokefl...@gmail.com wrote:
 On Sat, Mar 12, 2011 at 1:21 AM, Tommy Pham tommy...@gmail.com wrote:
 I think the OP is having both PHP  JS codes mixed and scattered all
 over the page.  If chunked-encoding used without any ob*
 implementation, then that's the problem he'll experience.

 Richard,

 I recommend to put the $(document).ready() and any JS scriptlets
 within body/body tags at the very bottom of the HTML document just
 right before /body.  This would allow the mixed PHP/HTML to finish
 without creating problems for your JS code(s).

 Why not separate them all, i.e. js, php, html, and if it was in there,
 css. If you can use them all, then separating them out should be
 *easy*(I still would have to use references for that many languages).
 Think of it as an expository writing, with the includes being the main
 topics, the content being composed of these higher ideas, and the
 conclusion, just closing it out.

 Pick the focus, I'd say php, and echo the rest out. Or html, and
 include the php, css and js.


This would depend on the original application design  code.  The
solution you're proposing is ideal which, for the most part, would
probably require the app redesign/rewrite.  However, if Richard isn't
one of the originator(s) of the app's developers or he's only
experiencing the problem on a very few limited pages, moving the JS
codes to the bottom would be a faster fix.  In the end, it all depends
on his environment and immediate need.



  The other solution is
 implement output buffer using ob* functions.

 Regards,
 Tommy

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





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


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



Re: [PHP] Re: Delaying $(document).ready() in jQuery until php script finish

2011-03-11 Thread Tommy Pham
On Fri, Mar 11, 2011 at 10:34 PM, David Hutto smokefl...@gmail.com wrote:
 Although, right now, if I were going to be using all of those
 languages in unison(and I am), then I'd go with C, and spit them out
 to the browser for lower level control, as well as, to remain familiar
 with some of the main languages being used currently.


But then how portable is your app?

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



Re: [PHP] Re: Delaying $(document).ready() in jQuery until php script finish

2011-03-11 Thread David Hutto
On Sat, Mar 12, 2011 at 2:22 AM, Tommy Pham tommy...@gmail.com wrote:
 On Fri, Mar 11, 2011 at 10:34 PM, David Hutto smokefl...@gmail.com wrote:
 Although, right now, if I were going to be using all of those
 languages in unison(and I am), then I'd go with C, and spit them out
 to the browser for lower level control, as well as, to remain familiar
 with some of the main languages being used currently.


 But then how portable is your app?


I'd have to refer to your reply:

This would depend on the original application design  code.

If the original app is meant for specific hardware, and a specific
company, then portability is null point.

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



Re: [PHP] Re: Delaying $(document).ready() in jQuery until php script finish

2011-03-11 Thread Tommy Pham
On Fri, Mar 11, 2011 at 11:26 PM, David Hutto smokefl...@gmail.com wrote:
 On Sat, Mar 12, 2011 at 2:22 AM, Tommy Pham tommy...@gmail.com wrote:
 On Fri, Mar 11, 2011 at 10:34 PM, David Hutto smokefl...@gmail.com wrote:
 Although, right now, if I were going to be using all of those
 languages in unison(and I am), then I'd go with C, and spit them out
 to the browser for lower level control, as well as, to remain familiar
 with some of the main languages being used currently.


 But then how portable is your app?


 I'd have to refer to your reply:

 This would depend on the original application design  code.

 If the original app is meant for specific hardware, and a specific
 company, then portability is null point.


If that's the case why even bother with PHP?  Why not just do it in C
for pure speed?  I thought one of the major points of PHP is 'develop
anywhere and deploy anywhere'.

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



Re: [PHP] Re: Delaying $(document).ready() in jQuery until php script finish

2011-03-11 Thread David Hutto
On Sat, Mar 12, 2011 at 2:34 AM, Tommy Pham tommy...@gmail.com wrote:
 On Fri, Mar 11, 2011 at 11:26 PM, David Hutto smokefl...@gmail.com wrote:
 On Sat, Mar 12, 2011 at 2:22 AM, Tommy Pham tommy...@gmail.com wrote:
 On Fri, Mar 11, 2011 at 10:34 PM, David Hutto smokefl...@gmail.com wrote:
 Although, right now, if I were going to be using all of those
 languages in unison(and I am), then I'd go with C, and spit them out
 to the browser for lower level control, as well as, to remain familiar
 with some of the main languages being used currently.


 But then how portable is your app?


 I'd have to refer to your reply:

 This would depend on the original application design  code.

 If the original app is meant for specific hardware, and a specific
 company, then portability is null point.


 If that's the case why even bother with PHP?  Why not just do it in C
 for pure speed?

Speed wasn't the point- Multiple technology usage was the point. And
if you're going to poise a browser for multiple intercepts(in terms of
languages), then C *seems* to be the best was to move toward the
displayment of it's descendants.

If it's going to be a multi-language project, then it needs to be
addressed with a multilanguage source to stem from, and C would seem
like the optimum epicenter for propagation of this.


I thought one of the major points of PHP is 'develop


 anywhere and deploy anywhere'.


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