Re: [PHP] Function mktime() documentation question

2012-03-08 Thread Jim Lucas

On 03/08/2012 03:14 PM, Tedd Sperling wrote:

On Mar 8, 2012, at 11:20 AM, Ford, Mike wrote:

-Original Message-
From: Tedd Sperling [mailto:tedd.sperl...@gmail.com]
 From my code, the number of days in a month can be found by using 0
as the first index of the next month -- not the last day of the
previous month.


Huh? The 0th day of next month *is* the last day of the current month,
which gives you the number of days in the current month. QED.
I think it's possible you may be being confuzled by the number of
nexts and previouses floating around. Your mktime call is asking for
the 0th day of next month, i.e. the last day of the previous month of
next month, i.e. the last day of the current month. Which is exactly
what you say works. I think. :)

However, I agree that the description is not very well worded - saying
that days in the requested month are relative to the previous month is
very odd indeed if you ask me -- if they must be relative to anything,
why not the beginning of the relevant month? Actually, with a bit more
thought, I think I'd rewrite it something like this:

The day number relative to the given month. Day numbers 1 to 28, 29,
30 or 31 (depending on the month) refer to the normal days in the
month. Numbers less than 1 refer to days in the previous month, so 0
is the last day of the preceding month, -1 the day before that, etc.
Numbers greater than the actual number of days in the month refer to
days in the following month(s).



Mike:

Very well put.

You say:


Huh? The 0th day of next month *is* the last day of the current month,
which gives you the number of days in the current month.


That IS exactly what I am saying.

But why does anyone have to use the next month to figure out how many days 
there are are in this month? Do you see my point?

It would have been better if one could use:

$what_date = getdate(mktime(0, 0, 0, $this_month, 0, $year));
$days_in_this_month = $what_date['nday']; // note an additional key for 
getdate()

But instead, we have to use:

$next_month = $this_month +1;
$what_date = getdate(mktime(0, 0, 0, $next_month, 0, $year));
$days_in_this_month = $what_date['mday'];

Additionally, there's a perception problem. You say that 0 of the next month 
*is* the last day of the current month -- as such, apparently months overlap in 
your (and Dan's) explanation. Well... I agree with both of you, but my 
objection is having to increase the month value by one to get the number of 
days in the current month.

That's all I was saying.

Side-point: I find it interesting that getdate() has all sorts of neat 
descriptions for the current month (such as, what weekday a numbered day is), 
but lacks how many days are in the month. Doesn't that seem odd?

Cheers,

tedd

_
tedd.sperl...@gmail.com
http://sperling.com


I am surprised that nobody has come up with this one yet.

$what_date = getdate(mktime(0, 0, 0, $this_month, 35, $year));
$days_in_this_month = 35 - $what_date['mday'];



--
Jim Lucas

http://www.cmsws.com/
http://www.cmsws.com/examples/
http://www.bendsource.com/

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



Re: [PHP] Function mktime() documentation question

2012-03-08 Thread Jim Lucas

On 03/08/2012 04:24 PM, Jim Lucas wrote:

On 03/08/2012 03:14 PM, Tedd Sperling wrote:

On Mar 8, 2012, at 11:20 AM, Ford, Mike wrote:

-Original Message-
From: Tedd Sperling [mailto:tedd.sperl...@gmail.com]
From my code, the number of days in a month can be found by using 0
as the first index of the next month -- not the last day of the
previous month.


Huh? The 0th day of next month *is* the last day of the current month,
which gives you the number of days in the current month. QED.
I think it's possible you may be being confuzled by the number of
nexts and previouses floating around. Your mktime call is asking for
the 0th day of next month, i.e. the last day of the previous month of
next month, i.e. the last day of the current month. Which is exactly
what you say works. I think. :)

However, I agree that the description is not very well worded - saying
that days in the requested month are relative to the previous month is
very odd indeed if you ask me -- if they must be relative to anything,
why not the beginning of the relevant month? Actually, with a bit more
thought, I think I'd rewrite it something like this:

The day number relative to the given month. Day numbers 1 to 28, 29,
30 or 31 (depending on the month) refer to the normal days in the
month. Numbers less than 1 refer to days in the previous month, so 0
is the last day of the preceding month, -1 the day before that, etc.
Numbers greater than the actual number of days in the month refer to
days in the following month(s).



Mike:

Very well put.

You say:


Huh? The 0th day of next month *is* the last day of the current month,
which gives you the number of days in the current month.


That IS exactly what I am saying.

But why does anyone have to use the next month to figure out how many
days there are are in this month? Do you see my point?

It would have been better if one could use:

$what_date = getdate(mktime(0, 0, 0, $this_month, 0, $year));
$days_in_this_month = $what_date['nday']; // note an additional key
for getdate()

But instead, we have to use:

$next_month = $this_month +1;
$what_date = getdate(mktime(0, 0, 0, $next_month, 0, $year));
$days_in_this_month = $what_date['mday'];

Additionally, there's a perception problem. You say that 0 of the next
month *is* the last day of the current month -- as such, apparently
months overlap in your (and Dan's) explanation. Well... I agree with
both of you, but my objection is having to increase the month value by
one to get the number of days in the current month.

That's all I was saying.

Side-point: I find it interesting that getdate() has all sorts of neat
descriptions for the current month (such as, what weekday a numbered
day is), but lacks how many days are in the month. Doesn't that seem odd?

Cheers,

tedd

_
tedd.sperl...@gmail.com
http://sperling.com


I am surprised that nobody has come up with this one yet.

$what_date = getdate(mktime(0, 0, 0, $this_month, 35, $year));
$days_in_this_month = 35 - $what_date['mday'];


Even a one liner...

$what_date = getdate(mktime(0,0,0,$this_month,35,$year)-(35 * 86400));


--
Jim Lucas

http://www.cmsws.com/
http://www.cmsws.com/examples/
http://www.bendsource.com/

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



Re: [PHP] Function mktime() documentation question

2012-03-08 Thread Jim Lucas

On 03/08/2012 04:31 PM, Jim Lucas wrote:

On 03/08/2012 04:24 PM, Jim Lucas wrote:

On 03/08/2012 03:14 PM, Tedd Sperling wrote:

On Mar 8, 2012, at 11:20 AM, Ford, Mike wrote:

-Original Message-
From: Tedd Sperling [mailto:tedd.sperl...@gmail.com]
From my code, the number of days in a month can be found by using 0
as the first index of the next month -- not the last day of the
previous month.


Huh? The 0th day of next month *is* the last day of the current month,
which gives you the number of days in the current month. QED.
I think it's possible you may be being confuzled by the number of
nexts and previouses floating around. Your mktime call is asking for
the 0th day of next month, i.e. the last day of the previous month of
next month, i.e. the last day of the current month. Which is exactly
what you say works. I think. :)

However, I agree that the description is not very well worded - saying
that days in the requested month are relative to the previous month is
very odd indeed if you ask me -- if they must be relative to anything,
why not the beginning of the relevant month? Actually, with a bit more
thought, I think I'd rewrite it something like this:

The day number relative to the given month. Day numbers 1 to 28, 29,
30 or 31 (depending on the month) refer to the normal days in the
month. Numbers less than 1 refer to days in the previous month, so 0
is the last day of the preceding month, -1 the day before that, etc.
Numbers greater than the actual number of days in the month refer to
days in the following month(s).



Mike:

Very well put.

You say:


Huh? The 0th day of next month *is* the last day of the current month,
which gives you the number of days in the current month.


That IS exactly what I am saying.

But why does anyone have to use the next month to figure out how many
days there are are in this month? Do you see my point?

It would have been better if one could use:

$what_date = getdate(mktime(0, 0, 0, $this_month, 0, $year));
$days_in_this_month = $what_date['nday']; // note an additional key
for getdate()

But instead, we have to use:

$next_month = $this_month +1;
$what_date = getdate(mktime(0, 0, 0, $next_month, 0, $year));
$days_in_this_month = $what_date['mday'];

Additionally, there's a perception problem. You say that 0 of the next
month *is* the last day of the current month -- as such, apparently
months overlap in your (and Dan's) explanation. Well... I agree with
both of you, but my objection is having to increase the month value by
one to get the number of days in the current month.

That's all I was saying.

Side-point: I find it interesting that getdate() has all sorts of neat
descriptions for the current month (such as, what weekday a numbered
day is), but lacks how many days are in the month. Doesn't that seem
odd?

Cheers,

tedd

_
tedd.sperl...@gmail.com
http://sperling.com


I am surprised that nobody has come up with this one yet.

$what_date = getdate(mktime(0, 0, 0, $this_month, 35, $year));
$days_in_this_month = 35 - $what_date['mday'];


Even a one liner...

$what_date = getdate(mktime(0,0,0,$this_month,35,$year)-(35 * 86400));




Sorry, had my math backwards...

$what_date = getdate((35 * 86400)-mktime(0,0,0,$this_month,35,$year));

--
Jim Lucas

http://www.cmsws.com/
http://www.cmsws.com/examples/
http://www.bendsource.com/

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



Re: [PHP] Function mktime() documentation question

2012-03-08 Thread Jim Lucas

On 03/08/2012 04:44 PM, Jim Lucas wrote:

On 03/08/2012 04:31 PM, Jim Lucas wrote:

On 03/08/2012 04:24 PM, Jim Lucas wrote:

On 03/08/2012 03:14 PM, Tedd Sperling wrote:

On Mar 8, 2012, at 11:20 AM, Ford, Mike wrote:

-Original Message-
From: Tedd Sperling [mailto:tedd.sperl...@gmail.com]
From my code, the number of days in a month can be found by using 0
as the first index of the next month -- not the last day of the
previous month.


Huh? The 0th day of next month *is* the last day of the current month,
which gives you the number of days in the current month. QED.
I think it's possible you may be being confuzled by the number of
nexts and previouses floating around. Your mktime call is asking for
the 0th day of next month, i.e. the last day of the previous month of
next month, i.e. the last day of the current month. Which is exactly
what you say works. I think. :)

However, I agree that the description is not very well worded - saying
that days in the requested month are relative to the previous month is
very odd indeed if you ask me -- if they must be relative to anything,
why not the beginning of the relevant month? Actually, with a bit more
thought, I think I'd rewrite it something like this:

The day number relative to the given month. Day numbers 1 to 28, 29,
30 or 31 (depending on the month) refer to the normal days in the
month. Numbers less than 1 refer to days in the previous month, so 0
is the last day of the preceding month, -1 the day before that, etc.
Numbers greater than the actual number of days in the month refer to
days in the following month(s).



Mike:

Very well put.

You say:


Huh? The 0th day of next month *is* the last day of the current month,
which gives you the number of days in the current month.


That IS exactly what I am saying.

But why does anyone have to use the next month to figure out how many
days there are are in this month? Do you see my point?

It would have been better if one could use:

$what_date = getdate(mktime(0, 0, 0, $this_month, 0, $year));
$days_in_this_month = $what_date['nday']; // note an additional key
for getdate()

But instead, we have to use:

$next_month = $this_month +1;
$what_date = getdate(mktime(0, 0, 0, $next_month, 0, $year));
$days_in_this_month = $what_date['mday'];

Additionally, there's a perception problem. You say that 0 of the next
month *is* the last day of the current month -- as such, apparently
months overlap in your (and Dan's) explanation. Well... I agree with
both of you, but my objection is having to increase the month value by
one to get the number of days in the current month.

That's all I was saying.

Side-point: I find it interesting that getdate() has all sorts of neat
descriptions for the current month (such as, what weekday a numbered
day is), but lacks how many days are in the month. Doesn't that seem
odd?

Cheers,

tedd

_
tedd.sperl...@gmail.com
http://sperling.com


I am surprised that nobody has come up with this one yet.

$what_date = getdate(mktime(0, 0, 0, $this_month, 35, $year));
$days_in_this_month = 35 - $what_date['mday'];


Even a one liner...

$what_date = getdate(mktime(0,0,0,$this_month,35,$year)-(35 * 86400));




Sorry, had my math backwards...

$what_date = getdate((35 * 86400)-mktime(0,0,0,$this_month,35,$year));



Spoke too soon.  Since you have to know the output of getdate() to 
calculate the minus figure... I guess that won't work.  Use the first 
one that I suggested.


--
Jim Lucas

http://www.cmsws.com/
http://www.cmsws.com/examples/
http://www.bendsource.com/

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



Re: [PHP] Converting an unordered list into JSON

2012-03-05 Thread Jim Giner

Jay Blanchard jay.blanch...@sigmaphinothing.org wrote in message 
news:4f54e388.7010...@sigmaphinothing.org...
 On 3/5/2012 9:53 AM, Stuart Dallas wrote:
 On 5 Mar 2012, at 15:50, Jay Blanchard wrote:

 I am off on my next tangent now and I have not really thought about this 
 too much yet but have you seen a method to convert a nested unordered 
 list into JSON using PHP?
 There's a very useful search function for the PHP manual on the PHP site. 
 Typing json into that would have got you to http://php.net/json_encode. 
 If that can't natively handle your variable type then you'll need to 
 massage the data into simple types first.

 Stuart I have RTFM, I was hoping that someone had an example handy. :)

Jay,
Sounds like your tangents are efforts to accomplish things that you know too 
little about and don't want to spend too much time getting acquainted with. 
To borrow from your crude response to Mr. Dallas:  You may have RTFM, now 
try DTFW.  :)



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



[PHP] iphone php

2012-03-05 Thread Jim Giner
An appl that has been working fine for a year now and fine up through last 
week, suddenly is not working on my iphone.  The only differences between 
using it on a pc, ipad or iphone are for font sizes and such (handled by JS) 
so I'm puzzled as to what is going on.  I do the same exact thing on each of 
these 3 devices and the iphone fails.  The specifics are : I'm entering a 
date into an input field and php is supposed to retrieve it and display a 
record that is retrieved using that input.  The iphone for some reason is 
not getting my input (passed via POST) correctly, yet it's the same script 
being run for each device.

Trying not to paranoid, but does anyone think that Apple could have done 
something to my iphone in the last few days? 



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



Re: [PHP] iphone php

2012-03-05 Thread Jim Giner

Stuart Dallas stu...@3ft9.com wrote in message 
news:a42f15bf-48a9-4118-bef5-ebc374fcb...@3ft9.com...
On 5 Mar 2012, at 17:16, Jim Giner wrote:

 An appl that has been working fine for a year now and fine up through last
 week, suddenly is not working on my iphone.  The only differences between
 using it on a pc, ipad or iphone are for font sizes and such (handled by 
 JS)
 so I'm puzzled as to what is going on.  I do the same exact thing on each 
 of
 these 3 devices and the iphone fails.  The specifics are : I'm entering a
 date into an input field and php is supposed to retrieve it and display a
 record that is retrieved using that input.  The iphone for some reason is
 not getting my input (passed via POST) correctly, yet it's the same script
 being run for each device.

 Trying not to paranoid, but does anyone think that Apple could have done
 something to my iphone in the last few days?

Of all the possible things that could have happened in order of likelihood, 
that's sandwiched between aliens having taken over your phone and the ghost 
of Steve Jobs up to mischief!

Have you debugged the code to see what your script is receiving from Safari? 
If not then I respectfully refer you to the advice you recently gave Jay.

-Stuart

Actually, I have been working on it for about 4 hours now.  Very simple 
script (like all of mine) that is working rock solid on 2 out of 3 boxes. 
In the last few mins I re-booted my phone and it is now doing something even 
worse!  As I fill in the date field using the iphone, the chars are showing 
up in the field onscreen.  But - once I close the keyboard (not submit)  - 
the input field reverts to ONLY one character!  This also happens if I hit 
the Next button on the keyboard to advance to the next input field.  And it 
is that character that my php script then receives when I do submit the 
form.  I have no code anywhere that addresses the input fields with JS so 
it's not something that I have 'forgotten' about - it is totally new and 
strange behavior.  And no, google has nothing to say about this (yet). 



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



Re: [PHP] iphone php

2012-03-05 Thread Jim Giner

Jay Blanchard jay.blanch...@sigmaphinothing.org wrote in message 
news:4f54faf8.4030...@sigmaphinothing.org...
 [snip]In the last few mins I re-booted my phone and it is now doing 
 something even worse! [/snip]

 Have you also cleared the cache and the cookies?

 You can also add Firebug to your iPhone - 
 http://www.iphone-my.com/ipad/geting-firebug-iphone-ipad/

No - I didn't go that far, but I can.  More testing has revealed that Safari 
running on my PC also doesn't like to accept the date I'm inputting.  As 
soon as I tab off the field, it changes itself to whatever my first two 
digits were. 



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



Re: [PHP] iphone php

2012-03-05 Thread Jim Giner


- Original Message - 
From: Mari Masuda mari.mas...@stanford.edu

To: Jim Giner jim.gi...@albanyhandball.com
Cc: php-general@lists.php.net
Sent: Monday, March 05, 2012 12:57 PM
Subject: Re: [PHP] iphone  php


On Mar 5, 2012, at 9:52 AM, Jim Giner wrote:



Jay Blanchard jay.blanch...@sigmaphinothing.org wrote in message
news:4f54faf8.4030...@sigmaphinothing.org...

[snip]In the last few mins I re-booted my phone and it is now doing
something even worse! [/snip]

Have you also cleared the cache and the cookies?

You can also add Firebug to your iPhone -
http://www.iphone-my.com/ipad/geting-firebug-iphone-ipad/


No - I didn't go that far, but I can.  More testing has revealed that 
Safari

running on my PC also doesn't like to accept the date I'm inputting.  As
soon as I tab off the field, it changes itself to whatever my first two
digits were.


Do you have a maxlength set by accident?

No.  As I said - this appl is a year old and works fine.  Or did work.  See 
next post for solution.




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



Re: [PHP] iphone php

2012-03-05 Thread Jim Giner

Jim Giner jim.gi...@albanyhandball.com wrote in message 
news:35.42.35539.06df4...@pb1.pair.com...

 Jay Blanchard jay.blanch...@sigmaphinothing.org wrote in message 
 news:4f54faf8.4030...@sigmaphinothing.org...
 [snip]In the last few mins I re-booted my phone and it is now doing 
 something even worse! [/snip]

 Have you also cleared the cache and the cookies?

 You can also add Firebug to your iPhone - 
 http://www.iphone-my.com/ipad/geting-firebug-iphone-ipad/

 No - I didn't go that far, but I can.  More testing has revealed that 
 Safari running on my PC also doesn't like to accept the date I'm 
 inputting.  As soon as I tab off the field, it changes itself to whatever 
 my first two digits were.


Okay - here's the scoop - although this is not the forum for it.

Ipads and Iphones respect an html input tag's type=number attribute in 
order to trigger the device's different keyboard configurations.  This is a 
neat trick that I found on a couple of apple-related sites and has been 
working fine.  I just now removed that from my code that generates the html 
and Voila - problem gone.  Apparently Safari has been modified recently is 
my guess. 



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



Re: [PHP] iphone php

2012-03-05 Thread Jim Giner

Ashley Sheridan a...@ashleysheridan.co.uk wrote in message 
news:caba1578-d923-4fa8-b824-db8f5ffea...@email.android.com...


Jim Giner jim.gi...@albanyhandball.com wrote:


Jim Giner jim.gi...@albanyhandball.com wrote in message
news:35.42.35539.06df4...@pb1.pair.com...

 Jay Blanchard jay.blanch...@sigmaphinothing.org wrote in message
 news:4f54faf8.4030...@sigmaphinothing.org...
 [snip]In the last few mins I re-booted my phone and it is now doing
 something even worse! [/snip]

 Have you also cleared the cache and the cookies?

 You can also add Firebug to your iPhone -
 http://www.iphone-my.com/ipad/geting-firebug-iphone-ipad/

 No - I didn't go that far, but I can.  More testing has revealed that

 Safari running on my PC also doesn't like to accept the date I'm
 inputting.  As soon as I tab off the field, it changes itself to
whatever
 my first two digits were.


Okay - here's the scoop - although this is not the forum for it.

Ipads and Iphones respect an html input tag's type=number attribute
in
order to trigger the device's different keyboard configurations.  This
is a
neat trick that I found on a couple of apple-related sites and has been

working fine.  I just now removed that from my code that generates the
html
and Voila - problem gone.  Apparently Safari has been modified recently
is
my guess.



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

What format was your date in? It was my understanding that only numerical 
characters with a preceeeding sign and decimal point was allowed? I would 
expect a date to be in the form dd/mm/ or dd-mm- (allowing for 
swapping months and days of course) but neither is a valid number.

Thanks,
Ash
http://ashleysheridan.co.uk

My entry is valid - mm/dd/.  Works great on teh ipad, not the iphone 



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



[PHP] Re: iphone php

2012-03-05 Thread Jim Giner
Solution!

Found this post from last Fall.  Didn't experience the problem because my 
appl is a NASCAR one and the season ended before this problem was created, 
apparently by an Apple update on my phone.

Here's a link to the story: 
https://discussions.apple.com/thread/3408352?tstart=0

To summarize - apparently ios 5.0 changed how the number attribute works on 
an input tag.  Now it sees any input using that feature as a purely numeric 
field which in my case causes my date entry to be truncated once the first 
slash was hit.  Now that I'm using my appl with the start of the new season, 
I'm running into it.

Thanks for all the interest and help. 



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



Re: [PHP] iphone php

2012-03-05 Thread Jim Giner

Stuart Dallas stu...@3ft9.com wrote in message 
news:797e930f-368c-43d1-8159-9608b6d53...@3ft9.com...
On 5 Mar 2012, at 18:12, Jim Giner wrote:
 Okay - here's the scoop - although this is not the forum for it.

 Ipads and Iphones respect an html input tag's type=number attribute
 in
 order to trigger the device's different keyboard configurations.  This
 is a
 neat trick that I found on a couple of apple-related sites and has been

 working fine.  I just now removed that from my code that generates the
 html
 and Voila - problem gone.  Apparently Safari has been modified recently
 is
 my guess.



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

 What format was your date in? It was my understanding that only numerical
 characters with a preceeeding sign and decimal point was allowed? I would
 expect a date to be in the form dd/mm/ or dd-mm- (allowing for
 swapping months and days of course) but neither is a valid number.

 Thanks,
 Ash
 http://ashleysheridan.co.uk

 My entry is valid - mm/dd/.  Works great on teh ipad, not the iphone


I might be wrong, but I think Ash was actually asking why the hell a date 
field had that type attribute set to number. That's just messed up!!

-Stuart

-- 
Stuart Dallas
3ft9 Ltd
http://3ft9.com/

Cause it triggers the iphone to pop up a non-alpha keyboard which makes 
entering a data field easier (you don't have to explicitly switch to it with 
a keypress).  The default kyb is an all-alpha one.



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



Re: [PHP] iphone php

2012-03-05 Thread Jim Giner
Marc Guay marc.g...@gmail.com wrote in message 
news:CAL0DAJq0y-iOMvt4Ko+D4Z_t+oo3PT9SYmR+9foa=9q9gsr...@mail.gmail.com...
 And if you change your input type to date, because it's a date, does
 that bring up the numeric keys as well?

actually I have not seen anything that suggests that is a possible option. 
I am about to test something that I just received from Apple tho..



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



Re: [PHP] iphone php

2012-03-05 Thread Jim Giner
Robert Williams rewilli...@thesba.com wrote in message 
news:cb7a5dd7.828c6%rewilli...@thesba.com...
On 3/5/12 11:58, Jim Giner jim.gi...@albanyhandball.com wrote:


Marc Guay marc.g...@gmail.com wrote in message
news:CAL0DAJq0y-iOMvt4Ko+D4Z_t+oo3PT9SYmR+9foa=9q9gsr...@mail.gmail.com...
 And if you change your input type to date, because it's a date, does
 that bring up the numeric keys as well?

actually I have not seen anything that suggests that is a possible
option.
I am about to test something that I just received from Apple tho..

Yep, it's in there, as part of HTML 5. In iOS, support for it was added
with Safari 5, so that's probably why the behavior of the 'number' type
changed. There are others, too; see:

https://developer.apple.com/library/safari/#documentation/appleapplication
s/reference/SafariHTMLRef/Articles/InputTypes.html
http://www.w3schools.com/html5/att_input_type.asp


Regards,
Bob

--
Robert E. Williams, Jr.
Associate Vice President of Software Development
Newtek Businesss Services, Inc. -- The Small Business Authority
https://www.newtekreferrals.com/rewjr
http://www.thesba.com/



I now see that to be true.  In fact, it works really well on the iphone the 
ipad
mail or telephone and delete the e-mail and the attachments (if any).



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



Re: [PHP] Nested database loops and completing an unordered list....

2012-03-02 Thread Jim Lucas

On 03/01/2012 06:20 PM, Jay Blanchard wrote:

[snip]
Can you show the output of the function above?
[/snip]




Doesn't this SQL query return everything that has company_id set to 3 
which would it not contain all the data from the other queries combined 
into one large data set?


At this point, I don't believe you have shown your output.  Please show 
the output of your function.



0
SELECT DISTINCT `TIER1DATA` FROM `POSITION_SETUP` WHERE `COMPANY_ID` = '3'
Executives and Management

Normally this query alone returns 9 rows of data. Each of these rows should be 
included in the next query where TIER1DATA = each of the nine in succession

1
SELECT DISTINCT `TIER2DATA` FROM `POSITION_SETUP` WHERE `COMPANY_ID` = '3' AND 
`TIER1DATA` = 'Executives and Management'
  Executives and ManagementLeadership
2
SELECT DISTINCT `TIER3DATA` FROM `POSITION_SETUP` WHERE `COMPANY_ID` = '3' AND 
`TIER2DATA` = 'Executives and ManagementLeadership'
   Executives and ManagementLeadershipManager
3
SELECT DISTINCT `BUSTIER1DATA` FROM `POSITION_SETUP` WHERE `COMPANY_ID` = '3' 
AND `TIER3DATA` = 'Executives and ManagementLeadershipManager'
Knee
4
SELECT DISTINCT `BUSTIER2DATA` FROM `POSITION_SETUP` WHERE `COMPANY_ID` = '3' 
AND `BUSTIER1DATA` = 'Knee'
 KneeDIV01
5
SELECT DISTINCT `BUSTIER3DATA` FROM `POSITION_SETUP` WHERE `COMPANY_ID` = '3' 
AND `BUSTIER2DATA` = 'KneeDIV01'
  KneeDIV01DEPT02
6
SELECT DISTINCT `BUSTIER4DATA` FROM `POSITION_SETUP` WHERE `COMPANY_ID` = '3' 
AND `BUSTIER3DATA` = 'KneeDIV01DEPT02'
   KneeDIV01DEPT02GRP04
7
SELECT DISTINCT `` FROM `POSITION_SETUP` WHERE `COMPANY_ID` = '3' AND 
`BUSTIER4DATA` = 'KneeDIV01DEPT02GRP04'
1054Unknown column '' in 'field list'



--
Jim Lucas

http://www.cmsws.com/
http://www.cmsws.com/examples/
http://www.bendsource.com/

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



Re: [PHP] curl equivalent in PHP

2012-03-02 Thread Jim Lucas

On 03/02/2012 06:26 AM, Nibin V M wrote:

Hello,

I am trying to display the website content through a php code ( my own
websites; doesn't cause copy right issues ).

I use curl to display the page via the following simple code.

?php
$curl = curl_init();
curl_setopt ($curl, CURLOPT_URL, http://mytest.com;);
curl_exec ($curl);
curl_close ($curl);
?

But on some of my servers, curl isn't enabled! Is there any equivalent code
to  achieve the same?

Thank you,



As long as you do not need to perform posts to the other website via the 
PHP request, you could include, file_get_contents, fopen + fread, etc...


All you need to make sure is that allow_url_fopen is enabled.

--
Jim Lucas

http://www.cmsws.com/
http://www.cmsws.com/examples/
http://www.bendsource.com/

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



Re: [PHP] Nested database loops and completing an unordered list....

2012-03-02 Thread Jim Lucas

On 03/02/2012 08:27 AM, Jay Blanchard wrote:

[snip]
Doesn't this SQL query return everything that has company_id set to 3
which would it not contain all the data from the other queries combined
into one large data set?
[/snip]

I could do that, I can return one large dataset for all of the columns
shown in the tiers array. I have to remove the DISTINCT's. When I return
that dataset in this case I return seven columns of data with the parent
being in the leftmost column and descending to the right. The goal with
the the recursive function was to get each descendant line so that it
could be formatted in a nested unordered list. So in the SQL below you
get 9 records. For each of the 9 records you could get any number of
children depending on which of the 9 you're looking at. Then for each of
those children you could get their descendants and so on.

I was doing it the long way at first, until a recursive function was
suggested. The problem that I was having there was formatting the ul's
and li's properly.


I'm not saying you should get rid of the recursive function calls, but 
rather, why not pull all your data in one SQL call, then use recursive 
functions on the returned array of data.  It will save a little time by 
not hitting the DB on each function call too.




Now I feel as if I am really close to a better solution than the brute
force method. I may just be a little too frustrated to see what is a
simple answer.

Thanks for your help!



--
Jim Lucas

http://www.cmsws.com/
http://www.cmsws.com/examples/
http://www.bendsource.com/

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



[PHP] SESSION var and Objects problem

2012-03-02 Thread Jim Giner
My first foray into classes  objects.

When retrieving a set of records, I'm using a class to build an object.  At 
this time I save each record/object into a Session array by doing this:

$rows = mysql_num_rows($qrslts);
 if ($rows  0)
  for ($i=1;$i=$rows;$i++)
  {
   $row = mysql_fetch_array($qrslts);
   $e = new Entry;
   if ($e-GetAnEntry($row['recordkey'],$row['Eventcode']))
   {
$evts[] = $e;
array_push($_SESSION['TMScurr_evts'],$e); // THIS DOESN'T
$cls_errs .=  Stored $e-event in sess var $i-1; ;   // THIS 
WORKS
   }
   else
$cls_errs .= Could not retrieve event record for 
.$row['recordkey']. .$row['Eventcode'];
  }

The above code works AFAIK - the line above the array_push correctly stores 
my retreived record data  in the $evts array just fine and I can see the 
data when I use that array to display my page.
Note also that the var $cls_errs following the array_push does show me that 
valid values are being stored in $e
Later on, in my main process I attempt to retreive the contents of my 
Session var to use to re-display the data.  The code for that doesn't 
display any values.  In trying to debug this here is what I've done:

$cnt = count($_SESSION['TMScurr_evts']);
 echo In Display  process with $cnt recs in session var TMScurr_evts. ; 
// THIS WORKS
 reset($_SESSION['TMScurr_evts']);
 $e = new Entry;
 for ($i=0;$icount($_SESSION['TMScurr_evts']);$i++)
 {
  $e = array_pop($_SESSION['TMScurr_evts']);
  echo  in Display process - sess event $i is $e-eventbr;// 
THIS DOESN'T
 }

This debugging code correctly tells me how many entries are in the Session 
array variable, but the attempt to echo the values stored in the first field 
of each object contained in it shows blank for each one.

What am I doing wrong when I try to pull the contents of my session array 
out and store them back into an Entry object, one at a time, so that I can 
display the object on my webpage?? 



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



Re: [PHP] SESSION var and Objects problem

2012-03-02 Thread Jim Giner
Yes I ahve the class defined.  The classes work in most cases - just this 
one place where I want to save the objects in a sess var for re-use fails 
me. 




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



Re: [PHP] SESSION var and Objects problem

2012-03-02 Thread Jim Giner
ok - In examinig the objects in the Session after the data has been 
displayed and the user has hit triggered a re-entry into my script (just one 
script involved here), the objects in the session array now say 
[__PHP_Incomplete_Class_Name and __PHP_Incomplete_Class Object .  They 
didn't say that during my examiniation of the sess var before exiting the 
script.

Also with All error reporting on (a great tip that I never think of) I get 
many messages indicating that the object may not have been loaded.  I don't 
know what this means.  The include file for my class is present in my script 
and is always loaded.  But at this point in the process no functions of the 
class have been called.  Is that a problem?  In trying to re-display my data 
stored in the Sessioin array I instantiate a var of the class and then pop 
an array off the session var and assign it to the object and then call my 
display function to show the data on the webpage - that is where I get the 
errors.  Here is one of these messages:

  Notice: DisplayAnEntry() [function.displayanentry]: The script tried to 
execute a method or access a property of an incomplete object. Please ensure 
that the class definition Entry of the object you are trying to operate on 
was loaded _before_ unserialize() gets called or provide a __autoload() 
function to load the class definition in 
/home/albany/public_html/tms/php/tmsentry.php on line 372

 



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



Re: [PHP] SESSION var and Objects problem

2012-03-02 Thread Jim Giner
Stuart Dallas stu...@3ft9.com wrote in message 
news:7eeba658-c7f6-4449-87bd-aac71b41e...@3ft9.com...

Make sure the class is declared before you call session_start.
*

You Da Man!!

I see now why it makes a difference.  The session tries to bring back the 
data but doesn't know how to handle the objects in the session vars since 
the objects haven't been defined.  Never would of thought of that!

Thank you for being there!  :) 



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



Re: [PHP] Nested database loops and completing an unordered list....

2012-03-01 Thread Jim Lucas

On 03/01/2012 04:39 PM, Jay Blanchard wrote:


On Mar 1, 2012, at 6:36 PM, Jay Blanchard wrote:


[snip]…stuff…[/snip]

I am getting close, but I am also getting frustrated. I probably need to walk 
away for a bit.

I have an array of tiers….

Array
(
[0] =  TIER1DATA
[1] =  TIER2DATA
[2] =  TIER3DATA
[3] =  BUSTIER1DATA
[4] =  BUSTIER2DATA
[5] =  BUSTIER3DATA
[6] =  BUSTIER4DATA
)
Each of the tiers which represent parents in children in pairs. TIER1DATA is 
the parent of TIER2DATA, etc. representing 7 columns of data. Here is my code 
so far - any insight would be valuable and extremely appreciated by me.

function display_children($i, $child) {
global $dbc;
global $tierArray;
echo $i.br /;
/* retrieve children of parent */
$get = SELECT DISTINCT `. $tierArray[$i] .` FROM `POSITION_SETUP` ;
$get .= WHERE `COMPANY_ID` = '3' ;
if($i  0) {
$get .= AND ` . $tierArray[$i - 1] . ` = ' . $child . ' ;
}
echo $get.br /;
if(!($result = mysql_query($get, $dbc))) {
echo mysql_errno() . \t . mysql_error() . \n;
exit();
}

while($row = mysql_fetch_array($result)) {

/* indent and display the title of this child */
echo str_repeat('nbsp;',$i).$row[$tierArray[$i]].br /\n;

/* get the children's children */
display_children($i + 1, $row[$tierArray[$i]]);
}
}

It does produce the right query for only the first child in each case, I cannot 
get it to go deeper. I have just been looking at it for too long. TVMIA!


Forgot to say that if I isolate any one level without recursion I get all of 
the results for that level.




How are you calling this?  What are your initial arguments?

What does your DB schema look like?

Can you show a brief example of the data in the table?
  Dump: SELECT * FROM position_setup WHERE company_id='3'

Can you show the output of the function above?


--
Jim Lucas

http://www.cmsws.com/
http://www.cmsws.com/examples/
http://www.bendsource.com/

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



Re: [PHP] Selecting checkboxes based on SQL query

2012-02-23 Thread Jim Lucas

On 02/23/2012 11:30 AM, Rick Dwyer wrote:

So, to use my existing function, how do I get the following array to
look like the above one:

Array ( [0] = Array ( [cb] = 2 ) [1] = Array ( [cb] = 6 ) [2] =
Array ( [cb] = 1 ) )


$d = results from SQL query
$a = array();
foreach ($d AS $r)
  $a[] = $r['cb'];

--
Jim Lucas

http://www.cmsws.com/
http://www.cmsws.com/examples/
http://www.bendsource.com/

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



[PHP] Re: Test

2012-02-20 Thread Jim Giner
meaning what?
Jay Blanchard jay.blanch...@sigmaphinothing.org wrote in message 
news:4f4297a6.3000...@sigmaphinothing.org...
 Does this work? 



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



Re: [PHP] Headers on smart phone browsers

2012-02-06 Thread Jim Giner
Nice article!!

You should read up on responsive web design. 
http://www.alistapart.com/articles/responsive-web-design/ should get you 
started.  HTH!= 



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



[PHP] Re: Long Live GOTO

2012-02-06 Thread Jim Giner
NO GO!
As one who started back in the 70's with old style coding that utilized GoTo 
in Cobol, Fortran, etc. and had to deal with spaghetti code written by 
even earlier developers who never considered that someone else would have to 
maintain their code, I feel strongly that GoTo is not to be used.

There are many ways of avoiding the perceived need for a GoTo statement. 
The 'Break' is one in PHP as is the 'Continue'.  Better instruction in 
programming since the 70's has taught beginning coders the value of 
well-structured code using function calls and distinct paragraphs (if you 
will) of code that help to structure the entire process into manageable 
chunks to facilitate understanding and maintenance.  Random GoTos 
interspersed into code because a designer just hasn't taken the time to 
write it well is just not smart.  Think of a well-written article in a 
journal or newspaper.  Do you think that the author just threw it together 
and the points to be made just fell out of it?  No - that writer probably 
spent a good amount of time re-working his first draft into second and third 
drafts before getting his thoughts and words in the right order to 
facilitate the presentation of the ideas he was trying to communicate.  The 
same process can and should be brought into play when writing code and in 
that way produce a quality product that will stand the test of time and lend 
itself easily to necessary improvements when needed.

My $.02.


Adam Richardson simples...@gmail.com wrote in message 
news:CAC6CJqYLdqSih0+v=x78lnb_wun7sqmctkxdc0790th7c-c...@mail.gmail.com...
 Hi,

 While not purely focused on PHP, I toss this out to the group because I
 believe there are some novel, interesting points regarding the potential
 benefits of using the goto construct as implemented in PHP:

 



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



Re: [PHP] Long Live GOTO

2012-02-06 Thread Jim Giner
Adam Richardson simples...@gmail.com wrote in message 
news:cac6cjqz5wku8c9ruqgc4rqg5cq35a-lfs1rryos3wtfys6r...@mail.gmail.com...
 On Mon, Feb 6, 2012 at 10:05 AM, Robert Cummings 
 rob...@interjinn.comwrote:

 On 12-02-06 04:07 AM, Tim Streater wrote:

 On 06 Feb 2012 at 07:47, Adam 
 Richardsonsimpleshot@gmail.**comsimples...@gmail.com
  wrote:

  While not purely focused on PHP, I toss this out to the group because I
 believe there are some novel, interesting points regarding the 
 potential
 benefits of using the goto construct as implemented in PHP:

 http://adamjonrichardson.com/**2012/02/06/long-live-the-goto-**
 statement/http://adamjonrichardson.com/2012/02/06/long-live-the-goto-statement/


 Your val_nested() function looks like a straw-man to me. I've not used a
 goto since I stopped writing in FORTRAN in 1978, and not missed it [1].
 Neither do I ever have deeply nested if-then-else - these are a good 
 source
 of bugs. I suppose the rest of your article might have been dealing with
 simplifying val_nested() but TBH I wasn't interested enough to find out.

 [1] Not quite true - a Pascal compiler I once had to use in 1983 lacked 
 a
 return statement, so I had to fake it by putting a 999: label at the end 
 of
 the function and goto-ing to that.


 Goto has it's uses, demonizing it due to the poor implementation and
 misuse of it's same-named historical counterparts is an exercise in
 closed-mindedness. Goto can really shine in parsers and various other
 scenarios. While the example shown may be contrived it doesn't miss the
 point. Since goto cannot jump out of the function nor jump into the
 function it is well constrained to provide readability while eliminating
 complexity. Additionally, it is quite likely that it is more optimal. A
 single jump target versus one or more state variables to control nested
 conditionals or loops results in faster execution (also important for
 parsers).

 I've had a strong opinion on goto for a very long time. I was one of the
 proponents who argued on internals for its inclusion several years ago. I
 stand by its utility and refer the reader to the fact that many open 
 source
 projects, especially ones that use some kind of parser, have goto hidden
 within their implementation. You can find it in the C code for the PHP,
 MySQL, and Apache to name a few easily recognizable projects.

 Cheers,
 Rob.


 All excellent points, Robert.

 Tim mentioned that my example was a straw-man, and you mentioned it was
 contrived. Actually, it's a refactoring of a real function in my web
 framework that I've committed to trunk and going to use for a while (it's
 functionally inspired, and having the ability to store and retrieve
 immutable values is quite handy in this situation.)

 I like experimenting with different approaches (my background is in
 cognitive psychology), and there's certainly research to show that deeply
 nested ifs are problematic, cognitively speaking. Then, there are the 
 other
 techniques mentioned in the blog post to deal with them (guard clauses,
 pulling out functions, grouping conditions), but they have they're issues,
 too, in terms of processing (they can hurt proximity of related concepts,
 forcing programmers to work against the mental model they've built up of a
 problem, etc.) There are going to be issues with the goto approach I took
 to refactoring the function, too, but I'm keenly interested in playing
 around with it a while and letting the evidence accrue over time. I've 
 read
 many, many sources that seem to reject ANY approach using GOTO even 
 without
 properly evaluating its use within a language like PHP that offers some
 beneficial restrictions.

 Thanks for the insights (and I'm glad you pushed for the construct :)

 Adam

 -- 
 Nephtali:  A simple, flexible, fast, and security-focused PHP framework
 http://nephtaliproject.com

The use of goto was acceptable in the early days of computer programming. 
It was a major part of it in fact.  I believe that the trend to remove them 
from usage was because of that very thing.  The early programs naturally had 
to go thru improvements  maintenance but a new generation of programmers 
came along and that was when the problem with GoTos was realized.  It was 
difficult if not impossible to follow a process completely through so that 
one could implement a change easily and in the end people unfamiliar with 
the entire program were forced to put code into multiple spots to ensure 
that the change they were trying to implement got hit in all the correct 
circumstances.

Gotos allow for too much flexibility and open up diverging paths in the flow 
of the process.  Sure - it works for the original developer, but code must 
be seen as not the work of one author but as a product that can later be 
modified/improved/corrected by future authors.  Sure - you can say that the 
life of a specific program/module may not be that long in today's fast-paced 
changing technologies, but the same argument 

Re: [PHP] Long Live GOTO

2012-02-06 Thread Jim Giner

Robert Cummings rob...@interjinn.com wrote in message 
news:4f30086a.6080...@interjinn.com...
 1) deal with the trivial and error cases first

 Some say you should never return early from a function... I too think that 
 early returns can improve the readability of a function-- 
 especially if they are short snippets of logic that clearly indicate the 
 reason for an early exit (usually edge case constraints).

 :)

 Cheers,
 Rob.
 -- 

I agree.  Using multiple returns is merely a goto.  Maintenance of that 
function must then take into account those multiple paths in that function 
as the changes are added.  Modifying the original function to remove the 
returns so that *all* flows will encounter the 'new' code can cause problems 
if today's author misses something in the logical path of the process(es). 



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



Re: [PHP] Re: Re: File upload in map drive with PHP

2012-01-28 Thread Jim Lucas

On 1/27/2012 5:41 PM, Michelle Konzack wrote:

Merhaba Mehmet YAYLA,

Am 2012-01-26 15:10:34, hacktest Du folgendes herunter:

I'm using code this bellow.


...with an error!


form enctype=multipart/form-data action=upload_file.php?upload=1 method=post  input 
type=hidden name=MAX_FILE_SIZE value=3 /
 Select image:input name=userfile type=file/
 input type=submit value=Upload /


You can not use
 action=upload_file.php?upload=1

together with
 method=post


Wrong!  Try this...

http://www.cmsws.com/examples/php/testscripts/linux4miche...@tamay-dogan.net/form_upload.php



and you have to use
 form enctype=multipart/form-data action=upload_file.php method=post  input type=hidden 
name=MAX_FILE_SIZE value=3 /
   input type=hidden name=upload value=1 /


Wrong.  See above.



Thanks, Greetings and nice Day/Evening
 Michelle Konzack



--
Jim Lucas

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



[PHP] Re: File upload in map drive with PHP

2012-01-26 Thread Jim Giner
Do you mean you are trying to do an upload of a file on a mapped drive, such 
as a network drive?  Is this upload using an html form with an input 
type=file tag? 



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



[PHP] Re: Getting Column Names from an AS400 Database

2012-01-26 Thread Jim Giner
I'm thinking that it should read

$rs = $conn-execute($q);
$outval = odbc_columns($rs, DB#LIBNAME, %, TABLENAME, %);

You need to provide the results of the query to the odbc_columns, not the 
connection object.
Just my guess since I've never used this. 



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



Re: [PHP] Re: sql injection protection

2012-01-26 Thread Jim Lucas

On 01/26/2012 06:46 AM, Haluk Karamete wrote:

when we do b64e and then back b64d, you are saying. we get the org
input all as clear text but this time as a string. because it is now a
string, (which by definition can not be executed)

what's the difference between b64e+b64d vs (string) casting then? if
you were to cast the original input into string using (string),
wouldn't you be in the same shoes?


Re-read his example.  He encodes the data in PHP.  But decodes the data 
in SQL.  So, if you echo the SQL statement, you would see a base64 
encoded string that SQL then decodes.




also on another note, if you know the userinput is in UTF-8, ( you
verify that by running mb_detect_encoding($str, 'UTF-8', true); ), is
there a situation where you think mysql_real_escape_string would fail
in SQLINjection against string based user input ?  The reason I ask
this about specifically for strings is because it is fairly easy to
validate againsts integers,floats,booleans using the built in
validation filters my biggest issue is on strings...

also what do you think about filter_sanitize_string.


read this:

http://www.php.net/manual/en/filter.filters.sanitize.php

Then read this:

http://www.php.net/manual/en/filter.filters.flags.php

It seems to me that filter_sanitize_string does not deal with anything 
other then ASCII.


YMMV



and finally, where do you think PHP community plus Rasmus is having a
hard time implementing what you have in mind - that is a one liner
that will do the  inline string interpolation you are talking about..
what's the issue that it hasn't been done before?



On Tue, Jan 24, 2012 at 1:45 PM, Alex Nikitinniks...@gmail.com  wrote:

You don't need to store it in the database as b64, just undo the
encoding into your inputs

for the purpose of the explanation, this is language independent

b64e - encoding function
b64d - decoding function


pseudo code

given:
bad_num = ') union select * from foo --'
bad_str = 
good_num = 123456
good_str = some searchable text

the b64 way:
bad_num=b64e(bad_num)
...
good_str=b64e(good_str)


inserts:
query(insert into foo (num, str) values (b64d(\+bad_num+\),
b64d(\+bad_str+\)));
query(insert into foo (num, str) values (b64d(\+good_num+\),
b64d(\+good_str+\)));

Can you see that this will safely insert clear text into the database?
This is because when you convert anything from b64, it will return
from the function as a string and will not be executed as code...


Now let's try a search:
bad_num= '1 or 2 not like 5'
bad_str = ' or \40oz\ like \40oz\

again we:
bad_num=b64e(bad_num)
bad_str=b64e(bad_str)

then we can do a full text search:
query(select * from foo where match(str) against(b64d(\+bad_str+\)))
or even a number search
query(select * from foo where num=b64d(\+bad_num+\))

again this is possible because no matter what you put in bad num, it
will never be able to make post b64e bad_num look like code, just
looks like junk, until b64d converts it to a string (which by
definition can not be executed)

make sense now?


by check i mean, run utf8_decode for example...


Problem is, that i can tell you how to write the most secure code, but
if it's hard, or worse yet creates more problems than it solves
(seemingly), nobody other than a few individuals with some passion for
security will ever find the code useful. We need to fix this on the
language level, then we can go around and tell programmers how to do
it right. I mean imagine telling a programmer, that something that
takes them 2 lines of code now, can be done much more securely in 5-7,
and it creates code that doesn't read linearly... Most programmers
will just ignore you. I want to say, hey programmer, what you do in 2
lines of code, you can do in 1 and make it impossible to inject into,
then, then people will listen, maybe... This is where inline string
interpolation syntax comes in, but it is not implemented in any
programming languages, sadly actually. This is what i want to talk to
Rasmus about.





--
Jim Lucas

http://www.cmsws.com/
http://www.cmsws.com/examples/
http://www.bendsource.com/

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



Re: [PHP] Re: File upload in map drive with PHP

2012-01-26 Thread Jim Lucas

On 01/26/2012 07:13 AM, Jim Giner wrote:

You're using a GET in your script when your form is a POST.


and if you look at the method value you will see that he is passing 
upload=1 in the URL.  Which would be seen as a GET value.


--
Jim Lucas

http://www.cmsws.com/
http://www.cmsws.com/examples/
http://www.bendsource.com/

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



Re: [PHP] Re: Settings to Allow Precise File Upload Bytes

2012-01-20 Thread Jim Lucas
 willing to make 2 requests:
1) just to find out if the attempted upload will fail and inform the user.
2) for the actual upload if it should succeed.


TIA








--
Jim Lucas

http://www.cmsws.com/
http://www.cmsws.com/examples/
http://www.bendsource.com/

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



[PHP] Re: srand questions

2012-01-12 Thread Jim Giner
The manual notes some of your concerns - especially the lack of a need to do 
a 'seeding' and (since 5.2.1) the presence of a new algorithm that generates 
a unique sequence regardless if the 'seed' is repeated.  Furthermore, since 
there is no need to do a seed, I would guess that each call to the function 
mt_rand utilizes a new 'seed' internally, which the developer need not worry 
about.

Just my $.02. 



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



[PHP] Re: advise on simplfying session usage

2012-01-12 Thread Jim Giner
You're kidding us aren't you?

session(age) =90 versus $_SESSION['age']=90 (btw you left out a keystroke)
That's a difference of 2 keystrokes.  And you're looking to save keystrokes? 



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



Re: [PHP] Variable Troubleshooting Code

2012-01-10 Thread Jim Lucas

On 01/09/2012 07:16 PM, Donovan Brooke wrote:

Just to share, a Mr. Harkness forwarded me a consolidated version of my
code.. basically substituting the innards for:


if (!isset($pmatch) || substr($key,0,strlen($pmatch)) == $pmatch) {
print $key = $valuebr /;
}


Cheers,
Donovan





I would change the above the the following:

if ( empty($pmatch) || ( strpos($key, $pmatch) === 0 ) ) {
  print $key = $valuebr /;
}

it would be slightly faster

--
Jim Lucas

http://www.cmsws.com/
http://www.cmsws.com/examples/
http://www.bendsource.com/

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



[PHP] Re: php sendmail_from

2012-01-09 Thread Jim Giner
And how are you generating the email? 



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



[PHP] Re: php sendmail_from

2012-01-09 Thread Jim Giner
I guess I'm asking to see your code pertaining to sending the email. 
Telling us about a couple of ini settings doesn't really present us a 
picture of your problem. 



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



[PHP] Printing

2012-01-05 Thread Jim Giner
My first attempt to print something to a printer.
I actually just went ahead and tried this from my website:
$hdl = printer_open();
printer_write($hdl,This is my printed page);
printer_write($hdl,This is line 1);
printer_write($hdl,This is line 2);
printer_write($hdl,This is line 3);
printer_close($hdl);


The error I got was:  Fatal error: Call to undefined function printer_open() 
in .

Reading in the manual I find the following conflicting statements:
 1) These functions are only available under Windows 9.x, ME, NT4 and 2000. 
They have been added in PHP 4.0.4.
2) No external libraries are needed to build this extension.

3) This » PECL extension is not bundled with PHP. Windows users must enable 
php_printer.dll inside of php.ini in order to use these functions. A DLL for 
this PECL extension is currently unavailable. See also the building on 
Windows section.



I'm not sure what all those tidbits of information are telling me.  Are they 
outdated?  Is there some other chapter in the manual  I should read?  I only 
looked in Printer.

FWIW - I'm running windows xp on my client.  My host runs Apache and 2.2.21 
and PHP 5.3.6.

My question is:  Is there something I (me!) have to do to get printing to 
function in my domain's PHP install?





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



Re: [PHP] Printing

2012-01-05 Thread Jim Giner
Add extension=php_printer.dll in php.ini?

Will adding that line install the extension? 



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



Re: [PHP] Printing

2012-01-05 Thread Jim Giner

Nilesh Govindarajan cont...@nileshgr.com wrote in message 
news:CAPo3nobqHPTH5V+0RqsRsQ0vDAne7V4s1Nc0dB12Gb=akws...@mail.gmail.com...
On Thu, Jan 5, 2012 at 9:16 PM, Jim Giner jim.gi...@albanyhandball.com 
wrote:
 and where do I get the dll? That was my original question. The
 documentation didn't tell me anything other than it had to be enabled.
 - Original Message - From: Nilesh Govindarajan
 cont...@nileshgr.com
 To: Jim Giner jim.gi...@albanyhandball.com
 Cc: php-general@lists.php.net
 Sent: Thursday, January 05, 2012 10:42 AM
 Subject: Re: [PHP] Printing



 On Thu, Jan 5, 2012 at 9:05 PM, Jim Giner jim.gi...@albanyhandball.com
 wrote:

 Add extension=php_printer.dll in php.ini?

 Will adding that line install the extension?




 It will enable the extension. Install = compile + enable. It will
 not work if you don't have the DLL.

 --
 Nilesh Govindarajan
 http://nileshgr.com





I can't tell you much on this, because I don't use windows. You have
to get the source at http://pecl.php.net/printer and compile it. I
don't know the procedure, etc.

-- 
Nilesh Govindarajan
http://nileshgr.com

Now that is some new information!  Thanks for the pointer - I'll read up on 
it. 



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



Re: [PHP] Printing

2012-01-05 Thread Jim Giner


I can't tell you much on this, because I don't use windows. You have
to get the source at http://pecl.php.net/printer and compile it. I
don't know the procedure, etc.

-- 
Nilesh Govindarajan
http://nileshgr.com

That was a short trip.  Clicked on the link for documentation and it takes 
me right back to the php manual pages that I'd already read.  Clicked on the 
link to download the latest and it's a dead link.

Does anyone print from their php websites?? 



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



[PHP] PDF Printing instead?

2012-01-05 Thread Jim Giner
ok - somebody has advised that I should not be trying to print to a printer 
from my website php script.

The suggestion of creating a pdf and sending to the client was made.  How do 
I install the pdf functions?  I've never had to install a package before or 
is that something my hoster does? 



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



Re: [PHP] Question about date calculations

2011-12-30 Thread Jim Lucas

On 12/29/2011 01:22 PM, Eric Lommatsch wrote:

Hello List,

I am using PHP version 5.2.6.


I am using PHP V5.3.3

In my setup, the following lines give me errors stating that PHP cannot 
convert the DateTime object to a string.  I was able to get around the 
error by changing your code to the following.



   $intDayCnt=$dteEndDate[$i]-$dteStartDate[$i];


$intDayCnt = ( $dteEndDate[$i]-format('m') -
   $dteStartDate[$i]-format('m') );

Be sure to change the following line as well.
$dteCheckDate = date('U');


   if (($dteCheckDate=($dteEndDate[$i]-7)
$dteCheckDate=($dteEndDate[$i]+1))  $intDayCnt16)


if (
 $dteCheckDate = ( $dteEndDate[$i]-format('U') - (7*86400) )
 
 $dteCheckDate = ( $dteEndDate[$i]-format('U') + (86400) )
 
 $intDayCnt  16
   ) {


Eric Lommatsch.


--
Jim Lucas

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



[PHP] Re: [php] static html search engine for php static html site

2011-12-26 Thread Jim Lucas
On 12/26/2011 5:37 PM, Izo duwa wrote:
 the whole site is in php and all content should be searchable. I have tried
 zoom site search [http://www.wrensoft.com/zoom/] but the result was not
 good.   I just need a simple site search functionality that I can install
 on a share hosting. it should be able to serach through the whole site
 files and index it.  Do you know you of any pre-made solutions that works?
 
 thanks

I wrote a text bases search tool a few years ago because I wanted to be able to
search through my source files quickly and easily.

Form: http://www.cmsws.com/examples/search.php
Source: http://www.cmsws.com/examples/search.phps

Maybe it will give you a little start in the direction of writing your own 
solution.

-- 
Jim Lucas

http://www.cmsws.com/
http://www.cmsws.com/examples/
http://www.bendsource.com/

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



Re: [PHP] Error Reporting

2011-12-23 Thread Jim Lucas
On 12/23/2011 8:13 AM, Floyd Resler wrote:
 I know this is a very basic question and I'm almost embarrassed to ask it, 
 but it's something I really struggle with.  That is, getting the right 
 combination of error reporting options together to report the errors I want.  
 Right now, I get the errors I want except for parse errors.  Basically, I 
 want all errors but not warnings.  What would be a good combination of error 
 report options for my php.ini file?
 
 Thanks!
 Floyd
 
 

I run this on my server:

error_reporting = E_ALL
display_errors = On
log_errors = On

It shows me everything, including warnings.

If you want to hide the Warning, then you would use this

error_reporting = E_ALL  ~E_NOTICE
display_errors = On
log_errors = On

E_NOTICE includes warnings.

Reference here: http://us.php.net/manual/en/errorfunc.constants.php

-- 
Jim Lucas

http://www.cmsws.com/
http://www.cmsws.com/examples/
http://www.bendsource.com/

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



Re: [PHP] Online Form Creation

2011-12-22 Thread Jim Lucas
On 12/22/2011 8:22 AM, Christopher Lee wrote:
 On Dec 21, 2011, at 2:14 AM, Tedd Sperling wrote:
 
 I don't see a problem here.

 1. Figure out how to create a HTML form (Investigate HTML tables).
 2. Then write a PHP that will scrub the data and submit it to MySQL.

 The length and layout of the forms are of no significance.

 This is basic html/php -- try creating something and submit your work for 
 our 
 review. If you want us to write the code for you, please look elsewhere.
 
 Tedd,
 
 I appreciate your reply to my post. In no way do I expect anyone to code for 
 me. 
 If that were the case I would hire someone. I have posted to this list 
 numerous
 times and, if I am not mistaken, the list is designed to ask for suggestions,
 which I did. Being rude does not help anyone.

He wasn't being rude.  He was informing you of what to expect.  Honestly, with
how your two emails read, it seemed as though you were asking for examples of
how to write the basic structure of the HTML and processing script.

We like to see someone submit code that attempts to complete the task that they
are looking to accomplish when they are asking for help.

 
 I understand how to program radio buttons in a form that record 'instances' 
 of a 
 response. 

If you understand how to program radio buttons, then you should know how to
include an input type=text .. / field and textarea .../textarea in your
code as well.

 I just was not sure how to set-up a similar matrix to allow the user 
 to enter a numerical value.

matrix = table ??

wrap the table in a form and add the radio and text fields as needed.  throwing
in a needed textarea here and there would be helpful as well.

 
 I will follow your suggestion and submit my work.
 
 Best,
 
 Christopher
 
 -Original Message-
 From: Tedd Sperling [mailto:tedd.sperl...@gmail.com]
 Sent: Wednesday, December 21, 2011 12:05 PM
 To: PHP-General List
 Cc: Christopher Lee
 Subject: Re: [PHP] Online Form Creation
 
 On Dec 21, 2011, at 2:14 AM, Christopher Lee wrote:
 
 Hello All,

 I have two forms (see attached) that I would like to recreate and enable the 
 user to complete the form online. The data would be collected in a MySQL DB.

 http://ucensys.com/activities.pdf

 http://ucensys.com/guidelines.pdf

 You will see that the forms are in a matrix format. I am having trouble 
 figuring out the best way to create the form and ensure the data is collected
 properly in the DB. Any suggestions would be greatly appreciated.

 Best,

 Christopher
 
 I don't see a problem here.
 
 1. Figure out how to create a HTML form (Investigate HTML tables).
 2. Then write a PHP that will scrub the data and submit it to MySQL.
 
 The length and layout of the forms are of no significance.
 
 This is basic html/php -- try creating something and submit your work for our 
 review. If you want us to write the code for you, please look elsewhere.
 
 Cheers,
 
 tedd
 
 _
 t...@sperling.com
 http://sperling.com



-- 
Jim Lucas

http://www.cmsws.com/
http://www.cmsws.com/examples/
http://www.bendsource.com/

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



Re: [PHP] PHP page source charset

2011-12-20 Thread Jim Lucas
On 12/19/2011 6:44 PM, Rick Dwyer wrote:
 Hello all.
 
 When I set my page charset from iso-8859-1 to utf-8, when I run it through the
 W3C validator, the validator returns an error that it can't validate the page
 because of an illegal character not covered by UTF-8.
 
 
 Sorry, I am unable to validate this document because on line 199 it contained
 one or more bytes that I cannot interpret as utf-8(in other words, the bytes
 found are not valid values in the specified Character Encoding). Please check
 both the content of the file and the character encoding indication.
 The error was: utf8 \x99 does not map to Unicode
 
 Line 199 is a line with my open PHP declaration:
 ?php
 
 Not sure why W3C is having a hard time with this.  Any ideas?
 
  --Rick
 
 

You need to look at the output of your script, not the source for your script.

The validation only happens after PHP has executed  processed the php script
and sent the output to the browser.  It is the source in the browser that the
validation script sees.

-- 
Jim Lucas

http://www.cmsws.com/
http://www.cmsws.com/examples/
http://www.bendsource.com/

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



Re: [PHP] Working on a Subsummary Report

2011-12-19 Thread Jim Lucas
On 12/17/2011 4:21 PM, DealTek wrote:
 
 On Dec 16, 2011, at 12:56 PM, Jim Lucas wrote:


 1) What does your db schema look like?
 2) What SQL do you currently use?
 3) What criteria do you want to use to sort the data?
 4) Will the output be plaintext, html, etc?
 5) Is this going to be used to import into another app, or display  
 printing?

 
 Hi Jim - sorry I didn't see this earlier...
 
 
 1 - schema - think of a basic 2 table system  parent table and line items 
 table... - but really all the important fields are in the child line items...
 2 - mysql 5.xx
 3 - sort 1st by date (all records happen 1st of every month) then product 
 (only 2 products needed for this)
 4 - html for now
 5 - for now just display and printing like:
 
 
 JAN 2011
 --- PRODUCT 1
 
 data row 1
 data row 2
 
 --- PRODUCT 2
 
 data row 3
 data row 4
 
 like that...
 
 
 - thanks for checking this out
 
 
 
 
 --
 Thanks,
 Dave - DealTek
 deal...@gmail.com
 [db-11]

Well, by the sounds of it, you are using a join to combine the two tables into
one result set and you have doubling up on the parent information.

I would do it like this.

$SQL = 'SELECT p_id, month_name, prod_id, l_id, descr';

$results = query($SQL);

while ( $r = fetch_assoc($results) ) {
  $data[$r['p_id']]['descr'] = $r['month_name'];
  $data[$r['p_id']]['x'][$r['prod_id']]['descr'] = $r['descr'];
  $data[$r['p_id']]['x'][$r['prod_id']]['x'][$r['l_id']] = $r;
}

print_r($data);

Now, use instead of looping through the result set multiple times, us the
$dataSet array to loop through it once.

foreach ( $data AS $months ) {
  echo {$months['month']}\n;
  foreach ( $months['x'] AS $prod_id = $products ) {
echo --- {$products['descr']} #{$prod_id}\n\n;
foreach ( $products['x'] AS $product ) {
  echo str_pad($product['l_id'], 16, ' ', STR_PAD_LEFT), '  ',
   str_pad($product['descr'], 32, ' ', STR_PAD_RIGHT), PHP_EOL;
}
echo PHP_EOL;
  }
  echo PHP_EOL;
}

YMMV - This is completely untested,  It should give you an idea about how to
prepare/store the data and then display it.

-- 
Jim Lucas

http://www.cmsws.com/
http://www.cmsws.com/examples/
http://www.bendsource.com/

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



Re: [PHP] Working on a Subsummary Report

2011-12-18 Thread Jim Lucas
On 12/17/2011 6:14 PM, DealTek wrote:


 for the above to work right, you will need to loop through the mysql result 
 set
 one time.  Placing all the results in to one large array.  Then you can loop
 through the array as many times as needed.

 What you will probably find is that you can sort all the data into the proper
 order withing your SQL statement.  Then display the data looping through the
 mysql result set once without having to create the additional array 
 mentioned in
 my first statement above.
 
 
 
 Thanks Jim,
 
 I will look into how to make this work with arrays...
 
 more beginner questions...
 
 - as stated -  when I try to loop through 2x ...
 - the table 2 only shows 1 record..
 - Q: ... like the query number row number? needs to be reset - but how?
 
 So is it not possible to loop more than 1x? Is that why we are loading into 
 array?

Exactly

 
 
 --
 Thanks,
 Dave - DealTek
 deal...@gmail.com
 [db-11]


-- 
Jim Lucas

http://www.cmsws.com/
http://www.cmsws.com/examples/
http://www.bendsource.com/

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



Re: [PHP] Working on a Subsummary Report

2011-12-16 Thread Jim Lucas
On 12/16/2011 9:04 AM, Dave wrote:
 Hi all,
 
 I need to create a year to date report with individual  Subsummary
 Report (ala filemaker / others?) headings for each month. So, I’m
 curious the best way to approach this for performance speed and
 flexibility etc.
 
 -  I can do 1 sql query for the whole year’s data - or 12 individual
 queries... probably best to do 1 big year sql query - but I’m not sure
 how to split things up with loops etc.
 
 each summary month heading will need to show:
 - total month count of records
 - special counts within each month
 - more stuff
 - also the record data
 
 like:
 
 JAN - total record count = 50 special count = 3
 
 data record 1
 data record 2
 data record 3
 
 FEB - total record count = 47 special count = 4
 
 data record 1
 data record 2
 data record 3
 etc.
 
 
 Q: is it better to do 1 year find or 12 month queries - is 1 big find faster?
 
 Q: with one year find - how do I setup 12 loops to simulate summaries?
 do i just loop through the full set and only display if record is in
 month 1 or 2 or whatever?
 
 If there are any links describing this process - that would be great
 
 any help would be appreciated...
 
 

1) What does your db schema look like?
2) What SQL do you currently use?
3) What criteria do you want to use to sort the data?
4) Will the output be plaintext, html, etc?
5) Is this going to be used to import into another app, or display  printing?

-- 
Jim Lucas

http://www.cmsws.com/
http://www.cmsws.com/examples/
http://www.bendsource.com/

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



Re: [PHP] Working on a Subsummary Report

2011-12-16 Thread Jim Lucas
On 12/16/2011 12:56 PM, DealTek wrote:


 what about creating a master report that has the total summarized by
 category and then offering a drill thru type structure to dig deeper
 in certain areas?
 
 
 
 - Hi Bastien,
 
 That's a cool idea. In this case they want it on a longer single page so they 
 may save or print all at once.
 
 A while back - I remember doing a query for let's say just the unique product 
 names - then as I looped though them in a table - I did a sub query for all 
 records with that product name and did a 2nd loop in a second table to 
 show them  It ended up working like I wanted but I'm not sure if this was 
 the best way to do it
 
 
 -
 
 also
 
 also while I am testing I am trying to loop through the query 2 times
 
 table 1
 
 i tell it to show records if they meet criteria 1
 
 then do again in table 2
 
 table 2
 
 i tell it to show records if they meet criteria 2
 
 but the table 2 only shows 1 record
 
 Q: ... like the query number row number? needs to be reset - but how?
 
 
 
 
 - like ...
 
 like 2x ...
 
   ?php do { ?
   
  ?php if ($row_get1['loc'] = 'back') { ?
   
 tr
   td?php echo $row_get1['id']; ?/td
   td?php echo $row_get1['loc']; ?/td
   tdnbsp;/td
   tdnbsp;/td
   tdnbsp;/td
   tdnbsp;/td
 /tr
 
?php  }; ?
 
 ?php } while ($row_get1 = mysql_fetch_assoc($get1)); ?

for the above to work right, you will need to loop through the mysql result set
one time.  Placing all the results in to one large array.  Then you can loop
through the array as many times as needed.

What you will probably find is that you can sort all the data into the proper
order withing your SQL statement.  Then display the data looping through the
mysql result set once without having to create the additional array mentioned in
my first statement above.

 
 
 


 -- 
 
 --
 Thanks,
 Dave - DealTek
 deal...@gmail.com
 [db-11]


-- 
Jim Lucas

http://www.cmsws.com/
http://www.cmsws.com/examples/
http://www.bendsource.com/

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



Re: [PHP] Re: Preferred Syntax

2011-12-15 Thread Jim Lucas
On 12/14/2011 11:50 PM, Ross McKay wrote:
 On Wed, 14 Dec 2011 07:59:46 -0500, Rick Dwyer wrote:
 
 Can someone tell me which of the following is preferred and why?

  echo a style='text-align:left;size:14;font-weight:bold' href='/ 
 mypage.php/$page_id'$page_name/abr;

  echo a style='text-align:left;size:14;font-weight:bold' href='/ 
 mypage.php/.$page_id.'.$page_name./abr;
 [...]
 
 Just to throw in yet another possibility:
 
 echo HTML
 a style=text-align:left;size:14;font-weight:bold
href=/mypage.php/$page_id$page_name/abr
 HTML;
 
 I love HEREDOC for slabs of HTML, sometimes SQL, email bodies, etc.
 because they allow you to drop your variables into the output text
 without crufting up the formatting with string concatenation, AND they
 allow you to use double quotes which can be important for HTML
 attributes that may contain single quotes.
 
 So whilst either above option is fine for the specific context, I prefer
 HEREDOC when there's attributes like href.
 
 But what is preferred is rather dependent on the preferrer.

I second this example, with one minor change, I would add '{' and '}' around
variables.

echo HTML
a style=text-align:left;size:14;font-weight:bold
   href=/mypage.php/{$page_id}{$page_name}/abr
HTML;

This works for $variables, $objects, and variable functions calls.  But doesn't
work if you try to call functions directly (bummer).

$ cat variable_usage.php
?php

$v1 = 'Variable 1';

$o1 = new stdClass();
$o1-v1 = 'Object 1';

function something($str) {
return ...{$str}...;
}

$f1 = something;

echo _
{$v1}
{$o1-v1}
{$f1('Function 1')}
{something('F1')}
_;

?

Results in this

$ php -f variable_usage.php
Variable 1
Object 1
...Function 1...
{something('F1')}


This is why I like heredoc syntax over pretty much everything else.
-- 
Jim Lucas

http://www.cmsws.com/
http://www.cmsws.com/examples/
http://www.bendsource.com/

C - (541) 408-5189
O - (541) 323-9113
H - (541) 323-4219

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



Re: [PHP] Unique items in an array

2011-12-15 Thread Jim Lucas
On 12/15/2011 6:24 AM, Marc Guay wrote:
 Assuming you want to make things unique based on the contact_first_name 
 field,
 how would you decide which record to keep?  The first one you run in to, the
 last one you come across, or some other criteria?
 
 The unique field is actually the contact_id.
 
 Marc
 

Marc,

If that is the case, can you explain to us how you got the two entries in the
array to begin with?  If this is from a DB query, then it should probably be
address else where.  If it was loaded from a text file, it should be handled
differently.

No matter how it was created, you could always build a method (if the dataset
isn't too large) that would filter things out.

Given your example array, I would do something like this:

?php

$oldDataSet = array(
  array(
contact_id = 356,
contact_first_name = Marc,
  ),
  array(
contact_id = 247,
contact_first_name = Marc,
  ),
  array(
contact_id = 356,
contact_first_name = Marc,
  ),
);

$newDataSet = array();

foreach ( $oldDataSet AS $k = $entry ) {
  $newDataSet[$entry['contact_id']] = $entry;
  unset($oldDataSet[$k]);
}

print_r($newDataSet);

?

This would result in something like this:

Array
(
[356] = Array
(
[contact_id] = 356
[contact_first_name] = Marc
)

[247] = Array
(
[contact_id] = 247
[contact_first_name] = Marc
)

)

Give it a try, should do what you are wanting.

-- 
Jim Lucas

http://www.cmsws.com/
http://www.cmsws.com/examples/
http://www.bendsource.com/

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



Re: [PHP] Unique items in an array

2011-12-14 Thread Jim Lucas
On 12/13/2011 1:15 PM, Marc Guay wrote:
 Hi folks,
 
 Let's say that I have the following array:
 
   [0]=
   array(35) {
 [contact_id]=
 string(3) 356
 [contact_first_name]=
 string(4) Marc
  }
   [1]=
   array(35) {
 [contact_id]=
 string(3) 247
 [contact_first_name]=
 string(4) Marc
   }
   [2]=
   array(35) {
 [contact_id]=
 string(3) 356
 [contact_first_name]=
 string(4) Marc
  }
 
 And I would like to filter out exact duplicates, such as key 0 and key
 2 in this example, leaving me with an array containing only unique
 entries.  How would you go about it?
 
 Thanks for any help,
 Marc
 

Assuming you want to make things unique based on the contact_first_name field,
how would you decide which record to keep?  The first one you run in to, the
last one you come across, or some other criteria?

-- 
Jim Lucas

http://www.cmsws.com/
http://www.cmsws.com/examples/
http://www.bendsource.com/

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



Re: [PHP] Problem with date

2011-12-07 Thread Jim Lucas
On 12/7/2011 10:48 AM, Jack wrote:
 Hello All,
 
 I have a problem where Dates are coming out as 12.31.1969 19:00:00 which of
 course we didn't have PC's in 1969
 
 I'm not able to see where the date is getting screwed up, any ideas??
 
 //
 
 #
 function ShowFeed_RSS($XmlRoot) {
   $title = GetFirstChildContentByPath($XmlRoot, channel/title);  
   $link = GetFirstChildContentByPath($XmlRoot, channel/link);  
   $desc = GetFirstChildContentByPath($XmlRoot, channel/description);
 # Next 2 lines display the title of the feed, and feed description
 #  echo font face=arial color=blue size =2ba
 href=\$link\$title/a/b\n;
 #  echo $desc;
   $nodelist = GetChildrenByPathAndName($XmlRoot, channel, item);
   if (!$nodelist) return 0;
   foreach ($nodelist as $nl) {
 $title   = GetFirstChildContentByName($nl, title);
 $link= GetFirstChildContentByName($nl, link);
 $desc= GetFirstChildContentByName($nl, description);
 $creator = GetFirstChildContentByName($nl, author);
 #if (!$creator) $creator = GetFirstChildContentByName($nl,
 dc:creator);
 #   echo JACK . $nl . br;
 #$pubdate = GetFirstChildContentByName($nl, pubDate);
 if (!isset($pubdate)) $pubdate = GetFirstChildContentByName($nl,
 dc:date);
 #if (!$pubdate) $pubdate = GetFirstChildContentByName($nl, dc:date);
 if (isset($pubdate)) $pubdate = strtotime($pubdate);
 if (isset($pubdate)) $pubdate = strftime(%m.%d.%Y %H:%M:%S, $pubdate);
 $out = $creator;
 if ( ($creator != )  ($pubdate != ) ) $out .=  @ ;
 $out .= $pubdate;
 echo a class=\rss-link\ href=\$link\b$title/b/a;
 echo font size=1 color=\black\$outbr;
 echo font size=2$descbrbr;
 #   echo font size=1 class=rss-linkThis is not green/font;
 }
 #  this line is after each rss feed group
 #  echo hr\n;
 }
 Thanks!
 Jack

Can you supply an example of the data you are feeding this.

-- 
Jim Lucas

http://www.cmsws.com/
http://www.cmsws.com/examples/
http://www.bendsource.com/

C - (541) 408-5189
O - (541) 323-9113
H - (541) 323-4219

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



Re: [PHP] Webcal and file_get_contents

2011-12-06 Thread Jim Lucas
On 12/6/2011 2:57 AM, Davo Smith wrote:
 Does anyone know if there is a simple way to convince
 'file_get_contents' to treat webcal urls (e.g.
 webcal://www.calendarlabs.com/templates/ical/US-Holidays.ics ) as
 being the same as an http url? (according to Wikipedia, http is
 assumed for webcal urls)

Reading the other emails makes me ask the question, must you use
file_get_contents?  Or could you use cURL?

 
 I've looked into using 'stream_wrapper_register', but, unless I've
 misunderstood it, this would require me to write the whole http access
 myself, without being able to just pass it onto the internal http
 processing code.
 
 I've done some web searching, looked through the PHP docs and had a
 look through the archives here, but not managed to find anything
 (sorry if I've missed anything obvious).
 
 Davo
 

-- 
Jim Lucas

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



Re: [PHP] Common way to store db-password of open session?

2011-12-04 Thread Jim Giner
To put it another way - your appl should control the access that a user 
has - different screens/functions available depending upon the signon 
credentials.  The entire application's sql use (or all 'users' of the 
database) should have a minimal number of user ids associated with it - both 
to make programming simpler and to minimize the number of 'entry' points to 
your database. 



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



Re: [PHP] Class instance pointers

2011-11-29 Thread Jim Lucas
On 11/29/2011 7:56 AM, Tim Streater wrote:
 Is there any benefit to setting a pointer to a class instance to null before 
 returning from a function? As in:
 
 function myfunc ()
  {
  $p = new myclass ();
  // do stuff
  $p = null;
  }
 
 Thanks.
 
 --
 Cheers  --  Tim
 
 

Nope, AFAIK everything inside the function will disappear when the function
exits.  Unless you run into one of the memory release issues talked about in the
past, in that case you might be SOL.

-- 
Jim Lucas

http://www.cmsws.com/
http://www.cmsws.com/examples/
http://www.bendsource.com/

C - (541) 408-5189
O - (541) 323-9113
H - (541) 323-4219

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



Re: [PHP] Common way to store db-password of open session?

2011-11-29 Thread Jim Lucas
On 11/29/2011 6:28 AM, Al wrote:
 
 
 On 11/29/2011 7:40 AM, Nilesh Govindarajan wrote:
 On Tue 29 Nov 2011 01:34:08 PM IST, Andreas wrote:
 Hi,

 is there a most advisable way to store db-passwords of an open
 user-session?
 As far as I get it, a common login strategy is to let the user login
 by namepassword, check it, store a login=TRUE as php-session variable
 and later use a common dbuser+pw to query data provided login is TRUE.

 This way one wouldn't have to store the users pw or actually the user
 wouldn't have a real db-account but rather an application account.

 Is this really better or equal than using real db-accounts?

 Should I rather store the db-credentials in a session or cookies?

 Session is vulnerable as any host-user could look into /tmp.
 This would generally be a trusted few though.

 On the other hand cookies could be manipulated by the user or at least
 be spied upon on the way between user and web-host every time the
 credentials are needed for a query.


 What exactly do you mean by db-account?
 I didn't understand your question, but this is what I do in my
 applications- When the user submits the login form, validate POST data
 (for mischievous stuff) and check if username  password query works
 out successfully. If it does, store a session variable login=true and
 let the user work on the private parts of the site.
 The cookie essentially, contains just the session id. I never use
 cookies to store data, only sessions.
 I also add ip and user-agent filtering to my auth systems.

 
 Sounds like $_SESSION buffer is what you need. I use the buffer extensively in
 most of my designs.
 
 
 

It seems to me that the OP isn't asking where to store it, s/he is asking what
to store.

I would suggest storing only the SESSION ID in the cookies.  In most setups,
this is done automatically.

Then in the sessions file place only the information that will allow you to
identify the individual in question.

In some cases, I have seen were the first step is followed above, but then
rather the just the identifiable information in the session, one would grab all
the account details and place this information in the session instead.  The only
benefit I see here is the within future page requests, you don't have to hit the
DB for the account details, they are in a session file that you already had to
load into memory.  The drawback to this approach is that all the account details
are in a file on the file system that could (in some situations) be read by
other system user accounts.

YMMV

-- 
Jim Lucas

http://www.cmsws.com/
http://www.cmsws.com/examples/
http://www.bendsource.com/

C - (541) 408-5189
O - (541) 323-9113
H - (541) 323-4219

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



Re: [PHP] Auto CRUD Generator Xataface

2011-11-29 Thread Jim Lucas
On 11/29/2011 12:54 PM, Daevid Vincent wrote:
 
 
 -Original Message-
 From: Matijn Woudt [mailto:tijn...@gmail.com] 
 Sent: Tuesday, November 29, 2011 12:48 PM
 To: Daevid Vincent
 Cc: php-general-h...@lists.php.net; php-general@lists.php.net
 Subject: Re: [PHP] Auto CRUD Generator Xataface
 
 On Tue, Nov 29, 2011 at 9:44 PM, Daevid Vincent dae...@daevid.com wrote:
 -Original Message-
 Search Google for Xataface.  It's a full frontend which
 dynamically changes with database structure changes.

 http://xataface.com/videos is broken and therefore we can't view the demo,
 and nothing pisses me off more than a site that doesn't have a simple
 contact email link!

 UGH!


 I think your PC is broken.. I can watch the videos just fine ;)
 
 I tried it in FF 3.6.24 as well as Chrome 15.0.874.121 m (is that really 
 necessary Google?!) and lastly IE 8.0.7601.17514 (is that really necessary 
 Micro$oft?!). All on Win7 64-bit burley-ass Dell PC.
 
 I code in PHP all day long and have no troubles with other websites. Not even 
 other pages on THAT web site. That particular tab / page however only 
 shows the logo top left, search top right, and then these in the tabs:
 
   Home Forum Documentation Videos a href=http://
 
 And the rest of the page is white.
 
 Garbage.
 
 

System: Windows XP 32-bit

I run FF 5.0.1 w/NoScript and I had allow both xataface.com and weblite.ca then
the video popped up.

IE 6.0 on the same system works fine too.

-- 
Jim Lucas

http://www.cmsws.com/
http://www.cmsws.com/examples/
http://www.bendsource.com/

C - (541) 408-5189
O - (541) 323-9113
H - (541) 323-4219

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



Re: [PHP] API for something like phpsysinfo?

2011-11-22 Thread Jim Lucas
On 11/22/2011 6:24 AM, Michelle Konzack wrote:
 Hello *,
 
 is there something like an API to phpsysinfo?
 
 I have the need to access more then 4800 Servers from scripts and I like
 to do it over https.  The infos on phpsysinfo are already enough,  but
 I need the values in a script
 
 Any suggestions?
 
 Thanks, Greetings and nice Day/Evening
 Michelle Konzack
 

Use the XML output option and parse returned data.

-- 
Jim Lucas

http://www.cmsws.com/
http://www.cmsws.com/examples/
http://www.bendsource.com/

C - (541) 408-5189
O - (541) 323-9113
H - (541) 323-4219

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



Re: [PHP] Think I found a PHP bug

2011-11-15 Thread Jim Lucas
On 11/15/2011 2:58 PM, Tim Streater wrote:
 On 15 Nov 2011 at 22:34, Geoff Shang ge...@quitelikely.com wrote: 
 
 The bug is that if a server's timezone is set to Europe/London and you
 don't set an explicit timezone in your script, if it's winter time in
 the UK, PHP thinks the timezone is UTC instead of Europe/London.
 
 I find I need to do this:
 
   date_default_timezone_set (@date_default_timezone_get ());
 
 in all my scripts since 5.x.x to avoid rude messages.
 
 --
 Cheers  --  Tim
 
 

Also, I recalled something from the early 5.1.0 version that was related to the
introduction of the date_timezone_set() function.  So, from there I searched
Google for php changelog and found the changelog for php v5.  Then I searched
that document for 'date_' and found that under the 5.1.0 they added the above
function.  How it is stated, it makes me think that PHP now requires you to call
this function prior to any use of other date functions.  I cannot find anything
in the php manual confirming my last statement.  YMMV

1 http://us3.php.net/manual/en/function.date-timezone-set.php
2 http://php.net/ChangeLog-5.php#5.1.0

-- 
Jim Lucas

http://www.cmsws.com/
http://www.cmsws.com/examples/
http://www.bendsource.com/

C - (541) 408-5189
O - (541) 323-9113
H - (541) 323-4219

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



[PHP] Re: Novice MySQL problem

2011-11-14 Thread Jim Giner
Actually, no it doesn't,  since I have a well-developed sense of all of 
that, but that's not helping to answer the OP's question now, is it?  Stay 
on point. 



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



[PHP] Re: Novice MySQL problem

2011-11-13 Thread Jim Giner

drive view drivev...@gmail.com wrote in message 
news:cam4sn2ip7yncw2-2soq-vjk8suer7u5x96fvpeqoitkkcaj...@mail.gmail.com...
 Hi,

 I'm a novice to MySQL and am currently facing the following difficulty.
 I'm trying to update a table with a row of data the primary key of which 
 is
 an ID which I believe is an auto incrementing serial number.  My first
 question is how to check if this is the case.


If you are updating a row, you should already know the id of the record, so 
in your update statement you reference it in the where clause.   (ie, where 
rec_id = $curr_rec_key)

 Secondly while trying to insert such a row leaving out this column mySql 
 is
 inserting the row at ID 0 (the previous ID's in the table are from 1 to 
 9),
 but then will not take further inserts.

 Thanks for any help available.


 Regards

 Toni


I don't know what the problem here is.  Personally I never use auto-inc 
fields. 



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



Re: [PHP] json_encode confusion

2011-11-10 Thread Jim Lucas
On 11/10/2011 6:45 AM, Bastien Koert wrote:
 Morning all,
 
 I've been having some fun with converting a text data file import into
 a json object for storage.
 
 I have a text file that is pipe delimited coming in via an upload. The
 first row is the headers and the second row is the data.
 
 Using this code:
 
 $data = file(inline_Nov_8_2011.txt);
 
 if(count($data)==2){
   
   $keys   = explode(|, $data[0]);
   $fields = explode(|, $data[1]);   
 
   $combine = array_combine($keys, $fields);
   
   $json = json_encode($combine);
 }
 
 After the combine, I get an array that looks like this
 
 Array
 (
 ['Legal Last Name '] = Andros
 ['Legal Middle Initial '] =
 ['Legal First Name '] = Marisa
 ['Maiden/Other Name '] =
 ['Social Insurance No. '] = 123456789
 ['Date of Birth '] = 2/1/1988
 ['Gender '] = Female
 )
 
 But the json encoded value looks like this (there are way more
 elements but this should be enough to represent what I need to do).
 
 {null:Andros,null:,null:Marisa,null:,null:123456789,null:2\/1\/1988,null:Female}
 
 I have been googling for info about allowed values for the json keys,
 but can't seem to find a clear doc on what is allowed and what isn't.
 I have tried unquoted keys, replaced the spaced with underscores but
 nothing I do seems to help.
 
 When I echo out the json encoded data, the keys are all nulls.
 
 Can someone point me in the correct direction? It may be that I need
 to manually create the key names as an array first, which I was hoping
 to avoid since the file format coming from the client is still in some
 flux.
 

Looking at your input array example, I see that you have trailing spaces in your
keys.  Looking at the working example of DiRaven, the only difference that I see
with his example is that the input key values do not have a trailing spaces.
json is probably having an issue with that trailing spaces.

-- 
Jim Lucas

http://www.cmsws.com/
http://www.cmsws.com/examples/
http://www.bendsource.com/

C - (541) 408-5189
O - (541) 323-9113
H - (541) 323-4219

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



[PHP] Re: delete and recreate

2011-11-09 Thread Jim Giner
This really doesn't tell me what you are trying to do. 



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



Re: [PHP] delete and recreate

2011-11-09 Thread Jim Giner
Is anyone concerned about the OP's original statement about receives a 
password via query string.  Perhaps that is his problem since he did 
mention it?  I didn't attempt to answer it because I didn't know what/why he 
was prompting for a password. 



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



Re: [PHP] delete and recreate

2011-11-09 Thread Jim Lucas
On 11/9/2011 7:35 AM, Kirk Bailey wrote:
 So, I want to create a script to delete an old file and create a new one which
 is empty. The script receives a password via query string. The obvious methods
 give me back a very useless 500 error. Any suggestions on how to accomplish 
 what
 I seek?
 

First, please include the at minimum the following information when asking a
question about a problem that you are having.

1) Operating System (Windows, Linux, etc...)
2) Web server type and version
3) PHP Version ( and how it is loaded in the web server )
3) Example code that you have tried.
   a) What the code is doing.
   b) What you expect the code to be doing.

-- 
Jim Lucas

http://www.cmsws.com/
http://www.cmsws.com/examples/
http://www.bendsource.com/

H - (541) 323-4219
C - (541) 408-5189
O - (541) 323-9113

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



[PHP] Re: Writing out errors to a file

2011-11-03 Thread Jim Giner
Try reading the manual on set_error_handler.  I've never needed to do this 
kind of thing, but this sure looks like something that could do it. 
Basically, I'm imagining that it would open a file handle on some text file 
in some folder, then append a write of mysql_error() to that file and 
probably the line number and such and then close it. 



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



[PHP] Re: Placing the masterpassword

2011-11-01 Thread Jim Giner
I've always thought that it was pretty safe to store this kind of material 
outside of the web-browser accessible path of your host.  Of course, you 
then have to be careful who has access to your site via ftp.

Let's see what comes of this question  :) 



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



Re: [PHP] Placing the masterpassword

2011-11-01 Thread Jim Giner

 I store things like this in a file above the document root - so not 
 grabbable by URL.
 Don't store it in the code ... you then end up with the password stored in 
 several
 places  then difficult to change.

 -- 
 Alain Williams
 Linux/GNU Consultant - Mail systems, Web sites, Networking, Programmer, IT 
 Lecturer.
 +44 (0) 787 668 0256  http://www.phcomp.co.uk/
 Parliament Hill Computers Ltd. Registration Information: 
 http://www.phcomp.co.uk/contact.php
 #include std_disclaimer.h

This is what I thought was proper protocol.  Though I actually store my sql 
password in a file that I include in my programs to make the sqlconnect to a 
database.  So - that way I don't have it stored in multiple places.  And 
yes - I use the same pswd for all my databases. 



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



Re: [PHP] Exporting large data from mysql to html using php

2011-10-31 Thread Jim Lucas
On 10/24/2011 5:50 PM, Jason Pruim wrote:
 Now that I've managed to list 3 separate programming languages and somewhat 
 tie it back into php here's the question...
 
 I have about 89 million records in mysql... the initial load of the page 
 takes 2 to 3 minutes, I am using pagination, so I have LIMIT's on the SQL 
 query's... But they just aren't going fast enough...
 
 What I would like to do, is pull the data out of MySQL and store it in the 
 HTML files, and then update the HTML files once a day/week/month... I can 
 figure most of it out... BUT... How do I automatically link to the individual 
 pages?
 
 I have the site working when you pull it from MySQL... Just the load time 
 sucks... Any suggestions on where I can pull some more info from? :)
 
 Thanks in advance!
 
 
 Jason Pruim
 li...@pruimphotography.com
 

Jason,

How large a data set are you starting with?  How many records in all.

Will you show us your DB schema?

-- 
Jim Lucas

http://www.cmsws.com/
http://www.cmsws.com/examples/
http://www.bendsource.com/

C - (541) 408-5189
O - (541) 323-9113
H - (541) 323-4219

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



[PHP] Why does this script run out of memory?

2011-10-28 Thread Jim Long
I'm running PHP 5.3.8 on FreeBSD 8.2 with MySQL 5.1.55.

The script below is designed to be able to WHILE it's way through
a MySQL query result set, and process each row.

However, it runs out of memory a little after a quarter million
rows.  The schema fields total to about 200 bytes per row, so
the row size doesn't seem very large.

Why is this running out of memory?

Thank you!

Jim

?php

$test_db_host = localhost;
$test_db_user = foo;
$test_db_pwd  = bar;
$test_db_name = farkle;

$db_host = $test_db_host;
$db_user = $test_db_user;
$db_name = $test_db_name;
$db_pwd  = $test_db_pwd;

if (!($db_conn = mysql_connect( $db_host, $db_user, $db_pwd )))
die( Can't connect to MySQL server\n );

if (!mysql_select_db( $db_name, $db_conn ))
die( Can't connect to database $db_name\n );

$qry = select * from test_table order by contract;

if ($result = mysql_query( $qry, $db_conn )) {

$n = 0;
while ($row = mysql_fetch_assoc( $result )) {
// process row here
$n++;
} // while

mysql_free_result($result);
echo $n\n;

} else {

die( mysql_error() . \n );

}

?


PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to 
allocate 20 bytes) in xx3.php on line 24

Line 24 is:

24  while ($row = mysql_fetch_assoc( $result )) {


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



Re: [PHP] Why does this script run out of memory?

2011-10-28 Thread Jim Long
On Fri, Oct 28, 2011 at 01:21:36PM -0400, Eric Butera wrote:
 On Fri, Oct 28, 2011 at 12:38 PM, Jim Long p...@umpquanet.com wrote:
  I'm running PHP 5.3.8 on FreeBSD 8.2 with MySQL 5.1.55.
 
  The script below is designed to be able to WHILE it's way through
  a MySQL query result set, and process each row.
 
  However, it runs out of memory a little after a quarter million
  rows. ??The schema fields total to about 200 bytes per row, so
  the row size doesn't seem very large.
 
  Why is this running out of memory?
 
  Thank you!
 
  Jim
 
  ?php
 
  $test_db_host = localhost;
  $test_db_user = foo;
  $test_db_pwd ??= bar;
  $test_db_name = farkle;
 
  $db_host = $test_db_host;
  $db_user = $test_db_user;
  $db_name = $test_db_name;
  $db_pwd ??= $test_db_pwd;
 
  if (!($db_conn = mysql_connect( $db_host, $db_user, $db_pwd )))
  ?? ?? ?? ??die( Can't connect to MySQL server\n );
 
  if (!mysql_select_db( $db_name, $db_conn ))
  ?? ?? ?? ??die( Can't connect to database $db_name\n );
 
  $qry = select * from test_table order by contract;
 
  if ($result = mysql_query( $qry, $db_conn )) {
 
  ?? ?? ?? ??$n = 0;
  ?? ?? ?? ??while ($row = mysql_fetch_assoc( $result )) {
  // process row here
  ?? ?? ?? ?? ?? ?? ?? ??$n++;
  ?? ?? ?? ??} // while
 
  ?? ?? ?? ??mysql_free_result($result);
  ?? ?? ?? ??echo $n\n;
 
  } else {
 
  ?? ?? ?? ??die( mysql_error() . \n );
 
  }
 
  ?
 
 
  PHP Fatal error: ??Allowed memory size of 134217728 bytes exhausted (tried 
  to allocate 20 bytes) in xx3.php on line 24
 
  Line 24 is:
 
  ?? ??24 ?? ?? ?? ?? ??while ($row = mysql_fetch_assoc( $result )) {
 
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 
 Not sure what is happening inside process row here, but I'm sure
 that is where your issue is.  Instead of building some giant structure
 inside of that while statement you should flush it out to the screen.

Eric:

Thanks for your reply.

process row here is a comment.  It doesn't do anything.  The
script, exactly as shown, runs out of memory, exactly as shown.

Jim

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



Re: Re: [PHP] Why does this script run out of memory?

2011-10-28 Thread Jim Long
On Fri, Oct 28, 2011 at 01:32:32PM -0400, James wrote:
 
 On Fri, Oct 28, 2011 at 12:38 PM, Jim Long p...@umpquanet.com wrote:
  I'm running PHP 5.3.8 on FreeBSD 8.2 with MySQL 5.1.55.
 
  The script below is designed to be able to WHILE it's way through
  a MySQL query result set, and process each row.
 
  However, it runs out of memory a little after a quarter million
  rows. ??The schema fields total to about 200 bytes per row, so
  the row size doesn't seem very large.
 
  Why is this running out of memory?
 
  Thank you!
 
  Jim
 
  ?php
 
  $test_db_host = localhost;
  $test_db_user = foo;
  $test_db_pwd ??= bar;
  $test_db_name = farkle;
 
  $db_host = $test_db_host;
  $db_user = $test_db_user;
  $db_name = $test_db_name;
  $db_pwd ??= $test_db_pwd;
 
  if (!($db_conn = mysql_connect( $db_host, $db_user, $db_pwd )))
  ?? ?? ?? ??die( Can't connect to MySQL server\n );
 
  if (!mysql_select_db( $db_name, $db_conn ))
  ?? ?? ?? ??die( Can't connect to database $db_name\n );
 
  $qry = select * from test_table order by contract;
 
  if ($result = mysql_query( $qry, $db_conn )) {
 
  ?? ?? ?? ??$n = 0;
  ?? ?? ?? ??while ($row = mysql_fetch_assoc( $result )) {
  // process row here
  ?? ?? ?? ?? ?? ?? ?? ??$n++;
  ?? ?? ?? ??} // while
 
  ?? ?? ?? ??mysql_free_result($result);
  ?? ?? ?? ??echo $n\n;
 
  } else {
 
  ?? ?? ?? ??die( mysql_error() . \n );
 
  }
 
  ?
 
 
  PHP Fatal error: ??Allowed memory size of 134217728 bytes exhausted (tried 
  to allocate 20 bytes) in xx3.php on line 24
 
  Line 24 is:
 
  ?? ??24 ?? ?? ?? ?? ??while ($row = mysql_fetch_assoc( $result )) {
 
 
 Not sure what is happening inside process row here, but I'm sure
 that is where your issue is.  Instead of building some giant structure
 inside of that while statement you should flush it out to the screen.
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 Try unsetting the $row variable, you may be fetching extremely
 large rows but that's a big if, because your script is allowed to
 allocate 128MB of memory before puking. Are you dealing with very
 large data sets from the database? If you are dealing with large
 data sets, then try redefining your query.

James:

Thanks for taking time to help.

The row size is small by my standards (see below).  The query result
has just under 300,000 records, and it's puking about 90% of the way
through.

Changing the while loop to:

while ($row = mysql_fetch_assoc( $result )) {
$n++;
echo sprintf( %7d %12d\n, $n, memory_get_peak_usage() );
} // while

the tail end of the output becomes:

 274695134203084
 274696134203524
 274697134203964
PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to 
allocate 240 bytes) in xx3.php on line 26

Changing the while loop further to:

while ($row = mysql_fetch_assoc( $result )) {
unset( $row );
$n++;
echo sprintf( %7d %12d\n, $n, memory_get_peak_usage() );
} // while

the tail end of the output becomes:

 274695134202232
 274696134202672
 274697134203112
 274698134203552
 274699134203992
PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to 
allocate 240 bytes) in xx3.php on line 27

So it does get a little farther through the dataset, but not much.

Jim


mysql describe test_table;
+--+-+--+-+-+---+
| Field| Type| Null | Key | Default | Extra |
+--+-+--+-+-+---+
| contract | int(11) | YES  | | NULL|   |
| A| int(8) unsigned | NO   | | 0   |   |
| B| datetime| YES  | | NULL|   |
| C| int(8) unsigned | YES  | | 0   |   |
| D| char(8) | YES  | | NULL|   |
| E| char(8) | YES  | | |   |
| F| int(4)  | YES  | | 0   |   |
| G| int(1)  | YES  | | 0   |   |
| H| char(8) | YES  | | 00:00   |   |
| I| varchar(100)| YES  | | XXX |   |
+--+-+--+-+-+---+
10 rows in set (0.00 sec)


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



Re: [PHP] BP for Looping through an Array

2011-10-28 Thread Jim Long
On Fri, Oct 28, 2011 at 12:09:24PM -0600, George Langley wrote:
   Hi all. Am wondering if there is a best practice for looping through an 
 array, when you need both the item and its position (ie. 1, 2, 3). The 
 two ways I know of:
 
 // the for loop tracks the position and you get each item from the array
   $allFiles = array(coffee.jpg, tea.jpg, milk.jpg);
   $numberOfFiles = count($allFiles);
   for ($i=1; $i=$numberOfFiles; $i++) {
   $currFile = $allFiles[$i - 1]; // since arrays start with 0
   doThisWith($currFile);
   doThatWith($i);
   }
 
 OR:
 
 // the for loop gets each item and you track the position
   $allFiles = array(coffee.jpg, tea.jpg, milk.jpg);
   $counter = 1;
   foreach ($allFiles as $currFile) {
   doThisWith($currFile);
   doThatWith($counter);
   $counter += 1;
   }
 
   Both are the same number of lines, but my tests (see code below) 
 indicate that the foreach loop is twice as fast.
   Anyone have a better way - faster, more efficient, cooler, etc.? 
 (Or see some flaw in my test code below?)
   Thanks.
 
 George Langley

If you are certain that your array is consecutively indexed from 
0, you can shave two lines off your code with:

$allFiles = array(coffee.jpg, tea.jpg, milk.jpg);
foreach ($allFiles as $key = $currFile) {
doThisWith($currFile);
doThatWith($key+1);
}


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



Re: [PHP] Why does this script run out of memory?

2011-10-28 Thread Jim Giner
If all you want to do is count the records, why are you not letting sql do 
it for you instead of doing the while loop?  That's all that script is 
doing, if that is the exact code you ran. 



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



Re: [PHP] Why does this script run out of memory?

2011-10-28 Thread Jim Long
On Fri, Oct 28, 2011 at 03:24:37PM -0400, Jim Giner wrote:
 If all you want to do is count the records, why are you not letting sql do 
 it for you instead of doing the while loop?  That's all that script is 
 doing, if that is the exact code you ran. 

Hi, Jim.

Thank you for replying.

One of the key concepts of troubleshooting is that when you
encounter a problem, you try to state the problem with as simple
a test case as possible, so that testing will not be complicated
by extraneous variables or code that may or may not have any
impact on the problem.

I don't want to just count the records, I want to get some work
done for a client.  That work involves processing every record in
the result set.  Counting is just a simple process to conduct
for the purpose of debugging this loop algorithm.

The problem is that this algorithm fails to process all the
records in the result set.

I appreciate any insights you have as to why that is happening.

Jim


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



Re: [PHP] Why does this script run out of memory?

2011-10-28 Thread Jim Long
On Fri, Oct 28, 2011 at 03:42:48PM -0400, Eric Butera wrote:
 On Fri, Oct 28, 2011 at 3:29 PM, Daniel Brown danbr...@php.net wrote:
  On Fri, Oct 28, 2011 at 13:25, Jim Long p...@umpquanet.com wrote:
 
  Eric:
 
  Thanks for your reply.
 
  process row here is a comment. ??It doesn't do anything. ??The
  script, exactly as shown, runs out of memory, exactly as shown.
 
  ?? ??My response presumes that you're planning on placing something
  into this comment area, in which the memory will only further
  increase. ??If *presumed* should be replaced by *ASSumed* in this case,
  skip mysql_unbuffered_query() and go straight for mysql_num_rows().
  Do not pass GO. ??Do not collect $200.
 
  --
  /Daniel P. Brown
  Network Infrastructure Manager
  http://www.php.net/
 
 
 I was glad to learn what comments were.

Eric: Please forgive me if I was curt in my message to you.  I
don't mean to bite the hands that are trying to help.  As Daniel
rightly observed, my concern is just that if a pretty much empty
while loop runs out of memory when trying to step through each
record, I'm really going to be hosed if I try to start doing some
productive work within the while loop.

Daniel's memory trend analysis is helpful.  I'm testing from the
command line, so there's no Apache overhead, but the memory usage
starts as:

  1 12145496
  2 12145976
  3 12146408
  4 12146804
  5 12147200
  6 12147596
...

I normally prefer to work in PostgreSQL, but the client has already
gone down the MySQL road.  Just for edification's sake, I exported
the table in PostgreSQL and re-worked my code:

if (!($db_conn = pg_connect( host=$db_host user=$db_user dbname=$db_name 
password=$db_pwd )))
die( Can't connect to SQL server\n );

$qry = select * from test_table order by contract;

if ($result = pg_query( $db_conn, $qry )) {

$n = 0;
while ($row = pg_fetch_assoc( $result )) {
unset( $row );
$n++;
echo sprintf( %7d %12d\n, $n, memory_get_peak_usage() );
} // while

pg_free_result($result);
echo $n\n;

} else {

die( pg_last_error() . \n );

}

Using PostgreSQL (on a completely different machine), this runs
to completion, and memory consumption is nearly flat:

  1   329412
  2   329724
  3   329796
  4   329796
  5   329796
...
 295283   329860
 295284   329860
 295285   329860
 295286   329860
 295287   329860
295287

If one were to describe the memory consumption as a 'leak', then
PostgreSQL is leaking at a much slower rate than MySQL.  Postgres
leaks as much over the entire run (329860-329412=448) as MySQL
does on each row.  Put another way, the MySQL version leaks
memory almost 300,000 times faster.

My PostgreSQL machine also has MySQL installed, so I ran the
MySQL version of the code on that machine for testing, a second
opinion if you like.  It leaked memory almost as bad as my
client's PHP/MySQL installation, but a little more slowly, 396
bytes or so per row.  The slower memory consumption enabled the
code to run to completion, barely:

  1 12149492
  2 12149972
  3 12150404
  4 12150800
...
 295284129087704
 295285129088100
 295286129088496
 295287129088892
295287

So is this just a difference in the programming quality of the 
database extensions for MySQL vs. PostgreSQL that one gobbles up
memory profusely, while the other one has only a slight, slow
leak?

I will try experimenting with Daniel's idea of unbuffered
queries, but my understanding is that while an unbuffered result
resource is in use, no other SQL transactions can be conducted.
Maybe I can get around that by using one MySQL connection for the
unbuffered query, and another separate MySQL connection for the
incidental SQL queries that I need to perform as I process each
record from the large dataset.

Jim

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



Re: [PHP] Why does this script run out of memory?

2011-10-28 Thread Jim Long
On Fri, Oct 28, 2011 at 02:57:02PM -0700, Tommy Pham wrote:
 On Fri, Oct 28, 2011 at 9:38 AM, Jim Long p...@umpquanet.com wrote:
 
  I'm running PHP 5.3.8 on FreeBSD 8.2 with MySQL 5.1.55.
 
 
 Jim,
 
 Installed from packages or standard port tree build?  Did you do any tweak
 for the ports build?  Any special compiler parameters in your make.conf?
 I've noticed that you used MySQL extensions.  Have you tried MySQLi to see
 if there's any difference?
 
 Regards,
 Tommy

MySQL server and PHP and extensions built from ports, without any
local tweaks.  Nothing very interesting in /etc/make.conf:

MASTER_SITE_FREEBSD=1
CPUTYPE?=p3
USA_RESIDENT=YES
NO_INET6=YES
WITHOUT_IPV6=YES
NO_I4B=true
NO_BLUETOOTH=true
NO_IPFILTER=true
NO_KERBEROS=true
NO_ATM=true # do not build ATM related programs and libraries
NOUUCP=true # do not build uucp related programs
NO_UUCP=true # do not build uucp related programs
NO_GAMES=true
NO_PROFILE=true
PERL_VERSION=5.10.1

Port options for php5-extensions are:

_OPTIONS_READ=php5-extensions-1.5
WITH_BCMATH=true
WITHOUT_BZ2=true
WITHOUT_CALENDAR=true
WITH_CTYPE=true
WITHOUT_CURL=true
WITHOUT_DBA=true
WITH_DOM=true
WITHOUT_EXIF=true
WITH_FILEINFO=true
WITH_FILTER=true
WITHOUT_FRIBIDI=true
WITH_FTP=true
WITHOUT_GD=true
WITHOUT_GETTEXT=true
WITHOUT_GMP=true
WITH_HASH=true
WITHOUT_ICONV=true
WITHOUT_IMAP=true
WITHOUT_INTERBASE=true
WITH_JSON=true
WITHOUT_LDAP=true
WITHOUT_MBSTRING=true
WITHOUT_MCRYPT=true
WITHOUT_MSSQL=true
WITH_MYSQL=true
WITHOUT_MYSQLI=true
WITHOUT_ODBC=true
WITHOUT_OPENSSL=true
WITHOUT_PCNTL=true
WITH_PDF=true
WITH_PDO=true
WITHOUT_PDO_SQLITE=true
WITH_PGSQL=true
WITH_POSIX=true
WITHOUT_PSPELL=true
WITHOUT_READLINE=true
WITHOUT_RECODE=true
WITH_SESSION=true
WITHOUT_SHMOP=true
WITH_SIMPLEXML=true
WITHOUT_SNMP=true
WITHOUT_SOAP=true
WITHOUT_SOCKETS=true
WITHOUT_SQLITE=true
WITHOUT_SQLITE3=true
WITHOUT_SYBASE_CT=true
WITHOUT_SYSVMSG=true
WITHOUT_SYSVSEM=true
WITHOUT_SYSVSHM=true
WITHOUT_TIDY=true
WITH_TOKENIZER=true
WITHOUT_WDDX=true
WITH_XML=true
WITH_XMLREADER=true
WITHOUT_XMLRPC=true
WITH_XMLWRITER=true
WITHOUT_XSL=true
WITHOUT_YAZ=true
WITHOUT_ZIP=true
WITHOUT_ZLIB=true

As Daniel suggested, using mysql_query_unbuffered works a treat,
at the expense of a small amount of additional programming
complexity.  In my prior work with Postgres, I found that it
would handle small or large datasets with equal ease, so I was
surprised to find that MySQL blew up given a sufficient number of
repeated calls to mysql_fetch_row();

Thank you for mentioning MySQLi.  Although it is alphabetically
adjacent in the documentation, it had never drawn my attention.
I'll build the PHP extension and take a look when time permits.

Jim

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



Re: [PHP] mysql_fetch_array() vs mysql_fetch_assoc() WAS: Re: [PHP] Why does this script run out of memory?

2011-10-28 Thread Jim Long
On Fri, Oct 28, 2011 at 06:19:56PM -0400, Daniel Brown wrote:
 On Fri, Oct 28, 2011 at 18:13, Paul Halliday paul.halli...@gmail.com wrote:
 
  Whats the difference between fetch_assoc and fetch_row?
 
  I use:
  while ($row = mysql_fetch_row($theQuery)) {
  ? ?doCartwheel;
  }
 
  on just under 300 million rows and nothing craps out. I have
  memory_limit set to 4GB though. Although, IIRC I pushed it up for GD
  not mysql issues.
 
  Same OS and php ver, MySQL is 5.1.48
 
 Please don't hijack other's threads to ask a question.  I've
 started this as a new thread to address this question.
 
 mysql_fetch_array() grabs all of the data and places it in a
 simple numerically-keyed array.
 
 By contrast, mysql_fetch_assoc() grabs it and populates an
 associative array.  This means that the column names (or aliases, et
 cetera) become the keys for the array.  With mysql_fetch_assoc(), you
 can still call an array key by number, but it's not vice-versa with
 mysql_fetch_array().

I'm not seeing any numeric keys in my mysql_fetch_assoc() arrays.

However, mysql_fetch_row (by default) does both: the array will be
indexed numerically from 0 to N-1 corresponding to the table's N
columns, and the array will also have string key indices which
correspond to the query's column names.  So by default,
mysql_fetch_row uses twice the amount of data, because each field
appears in the array twice.

var_dump( $row ) will show in graphic detail.


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



[PHP] Re: array_unique by id multi-dimensional array

2011-10-27 Thread Jim Giner

 i want to filter the array by [id] sub value?


The PHP manual is a source of infinite knowledge.  A simple entry of array 
in the search for field brings up just what you need.  Have at it! 



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



Re: [PHP] Exporting large data from mysql to html using php

2011-10-27 Thread Jim Giner

 Good luck, that's a LOT of reading.  I'd estimate that's about 3k+ pages 
 of
 reading. :)


 
 
  Regards,
  Tommy




nice to see someone else is finally getting the point that I'm been making. 



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



Re: [PHP] Exporting large data from mysql to html using php

2011-10-26 Thread Jim Giner
Your boss wants to give access to phone numbers to the public in general? 
Then what?

Glad mine's unlisted.



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



Re: [PHP] Exporting large data from mysql to html using php

2011-10-25 Thread Jim Giner
I disagree.  It's not about tuning the queries, it is more about the appl. 
design that currently thinks it SHOULD do such huge queries.

My approach would be to prompt the user for filtering criteria that 
automatically would reduce the result set size.  Although at this time I 
believe the OP mentioned that the db is just telephone numbers so that 
doesn't leave much room for filter-criteria. 



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



Re: [PHP] Exporting large data from mysql to html using php

2011-10-25 Thread Jim Giner
Again  why even do a detail query?  Nobody is going to examine pages and pages 
and etc.  
Do a summary qry if u just need a count - no pagination there
jg


On Oct 25, 2011, at 6:26 PM, Jason Pruim li...@pruimphotography.com wrote:

 
 Jason Pruim
 li...@pruimphotography.com
 
 
 
 On Oct 25, 2011, at 10:51 AM, Jim Giner wrote:
 
 I disagree.  It's not about tuning the queries, it is more about the appl. 
 design that currently thinks it SHOULD do such huge queries.
 
 My approach would be to prompt the user for filtering criteria that 
 automatically would reduce the result set size.  Although at this time I 
 believe the OP mentioned that the db is just telephone numbers so that 
 doesn't leave much room for filter-criteria. 
 
 
 
 Yes it is just phone numbers... The only select that I'm running on the 
 entire site is related to the pagination... A simple:
 $sqlCount = SELECT COUNT(*) FROM main WHERE state = '{$state}';
 
 which limits it to everything inside the state... Unfortunately if you look 
 at the possibilities, it's still quite a large dataset... 89 million :)
 
 The rest of the query's will be much more limited to areacode, exchange, and 
 in some cases the full phone number... Maybe the better way to do it would be 
 not to count the records But set a variable with the total count... That 
 way I don't have to load all the data... The data amount won't change alot... 
 Easy enough to set a variable...  Just need to see if I can integrate that 
 with the pagination...
 
 Back to the drawing board! :)
 
 
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 

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



Re: [PHP] Exporting large data from mysql to html using php

2011-10-25 Thread Jim Giner
David Robley robl...@aapt.net.au wrote in message 
news:49.50.34068.1b567...@pb1.pair.com...

 Consider running EXPLAIN on all your queries to see if there is something
 Mysql thinks could be done to improve performance.


Why do so many responders seem to think the problem here is in the 
preparation of the query?

It is the Approach that it is the problem.  It needs to re-addressed, not 
simply tinkered with.  I don't care if someone figures out how to spew out 
89M+ records in 5 seconds flat.  What are you doing pulling up that many 
detail records at one time for? Who is going to look at them?  You?  If so, 
see my previous post on how long that is going to take you just to examine 
(!) the first million alone.

This problem needs a re-working of the data processing and user interfaces 
to allow for the selection of an appropriate amount of individual records in 
any result set, otherwise simply preparing a summary of some sort. 



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



Re: [PHP] Exporting large data from mysql to html using php

2011-10-25 Thread Jim Giner


- Original Message - 
From: Jason Pruim li...@pruimphotography.com

To: Jim Giner jim.gi...@albanyhandball.com
Cc: php-general@lists.php.net
Sent: Tuesday, October 25, 2011 10:06 PM
Subject: Re: [PHP] Exporting large data from mysql to html using php


It turns out the issue was actually in the pagination... I'm reworking the 
whole thing and stream lining it... But in the pagination that I found on 
the internet it used a SELECT COUNT(*) WHERE state='{$state}'; and the 
COUNT was killing the time... Once that was removed, I was displaying 
records faster then I could imagine... So it's off to pagination land to fix 
it! And possibly redo the entire thing!



So you're still going to generate pages and pages of an un-manageable volume 
of data?


Sorry, but I offer my congratulations on producing a technically marvelous 
solution, and my condolences for a completely worthless application.








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



Re: [PHP] Exporting large data from mysql to html using php

2011-10-24 Thread Jim Giner
Why would any user need to have access to 89M records?



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



Re: [PHP] Exporting large data from mysql to html using php

2011-10-24 Thread Jim Giner
Yes - but - we're talking about a user-app that the OP is trying to provide 
89M records to.  Sure - some users might have need of looking at even as 
much as a million records IF they were researching something that needed it. 
But - for the 'general' user of an app - I cannot see a need to be providing 
even that much data.  Think about it - you give the user 1M records, how 
long is that user going to page thru the results?  Let's say there are 20 
results on a page and it takes a mere (wow!) 2 seconds to scan thru them 
looking for something apparently very obvious.  That's 600 results viewed 
per minute at best.  Six hundred into a M is 1666 minutes which is 27+ 
hours.  Even at 1 second per page view time, it's still more time than in a 
normal work day.  And you want come up with a way to feed him 89M?

The problem needs to be looked at differently - put together a 
business-smart solution to finding the  needle in this haystack of  89M 
pieces of straw and only then apply technology to it.



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



Re: [PHP] Re: Problem of load balance among php-cgi process

2011-10-20 Thread Jim Lucas
On 10/20/2011 5:20 AM, sean chen wrote:

 The red one is busy

My email client is color blind.

-- 
Jim Lucas

http://www.cmsws.com/
http://www.cmsws.com/examples/
http://www.bendsource.com/

C - (541) 408-5189
O - (541) 323-9113
H - (541) 323-4219

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



Re: [PHP] Questions Regarding Recent Ubuntu PHP5 Security Announcement

2011-10-19 Thread Jim Lucas
On 10/19/2011 7:00 AM, Jon Watson wrote:
 Hello All,
 
 I am trying to make some sense of this PHP5 security vulnerability notice
 from 18 October 2011:
 
 http://comments.gmane.org/gmane.linux.ubuntu.security.announce/1478
 
 It states that for Ubuntu 8.04 users, a PHP upgrade to 5.2.4 is required to
 take care of the security issues. It also states that for Ubuntu 10.04
 users, a PHP upgrade to 5.3.3 is required.
 
 For operational reasons, I am running 5.2.17 on Ubuntu 10.04 and cannot
 upgrade to PHP 5.3, Does anyone know if 5.2.17 is safe since evidently 5.2.4
 is?
 
 The security notice doesn't go into any real detail on the specific version
 numbers so I am having trouble understanding what needs to be done.
 
 Thanks.
 
 

This is discussing the packages distributed for Ubuntu X.X.  Sounds like what
you have is your own custom install.  If that is the case, the concern may still
apply, but it is going to be up to you to figure out what the security issue is
and verify your system in some manor.

-- 
Jim Lucas

http://www.cmsws.com/
http://www.cmsws.com/examples/
http://www.bendsource.com/

C - (541) 408-5189
O - (541) 323-9113
H - (541) 323-4219

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



Re: [PHP] Questions Regarding Recent Ubuntu PHP5 Security Announcement

2011-10-19 Thread Jim Lucas
On 10/19/2011 8:05 AM, Jon Watson wrote:
 On Wed, Oct 19, 2011 at 11:54 AM, Jim Lucas li...@cmsws.com wrote:
 
 On 10/19/2011 7:00 AM, Jon Watson wrote:
 Hello All,

 I am trying to make some sense of this PHP5 security vulnerability notice
 from 18 October 2011:

 http://comments.gmane.org/gmane.linux.ubuntu.security.announce/1478

 snip
 
 
 This is discussing the packages distributed for Ubuntu X.X.  Sounds like
 what
 you have is your own custom install.  If that is the case, the concern may
 still
 apply, but it is going to be up to you to figure out what the security
 issue is
 and verify your system in some manor.

 
 Agreed and I guess that is what I am trying to assess. The Ubuntu security
 notice doesn't go into specifics about the 5.2.x version has the issues
 other than presumably something earlier than 5.2.4. It would have been most
 helpful of them to provide some sort of test or at least the full version of
 the affected release.
 
 So, basically hunting around for some confirmation that my version is OK.
 
 I also find it odd that there is no accompanying security notice from
 PHP.net. If this is a security vulnerability in PHP 5 as reported by
 Canonical, why has PHP.net not released a security notice?
 

My guess is that this is not a security issue with PHP but more so a security
issue with they way they had that version configured/setup on the system.

-- 
Jim Lucas

http://www.cmsws.com/
http://www.cmsws.com/examples/
http://www.bendsource.com/

C - (541) 408-5189
O - (541) 323-9113
H - (541) 323-4219

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



Re: [PHP] Check variable value if change inside the Loop

2011-10-19 Thread Jim Lucas
On 10/19/2011 12:32 PM, ®0L¥ wrote:
 Hello World,
 
 I have a question regarding loops, How I can check inside a loop if a
 variable chage a value, for example
 
 $sql = mysql_query(SELECT model FROM table)
 
 while($row=mysql_fetch_array){
 $model = $row['model'];
 echo First model: .$model.br /;
* // if $model chage its model value*
 *   // echo Second Model: .$model.br /*
 }
 
 Thank you world !
 
 

You have two ways of solving this issue:

1) Do it in Mysql with a GROUP BY option

$results = mysql_query(SELECT model FROM table GROUP BY model)

2) Within PHP, do something like this.

$results = mysql_query(SELECT model FROM table)

# This assumes none of the values stored in DB column model are type=NULL
$model = null;
while( $row = mysql_fetch_array($results) ) {
  if ( is_null($model) || $model !== $row['model'] ) {
$model = $row['model'];
echo $model . 'br /';
  }
  ...
}

Either one should give you the same results.

-- 
Jim Lucas

http://www.cmsws.com/
http://www.cmsws.com/examples/
http://www.bendsource.com/

C - (541) 408-5189
O - (541) 323-9113
H - (541) 323-4219

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



[PHP] Re: PHP Version: 5.2.5.

2011-10-17 Thread Jim Giner
what did you name your file?  If it didn't have a .php extension, it won't 
work.
Joseph Adenuga jadenu...@yahoo.com wrote in message 
news:1318859708.50026.yahoomailclas...@web29517.mail.ird.yahoo.com...


Operating System: Window XP

PHP Version: 5.2.5. with Apache 2.2.8

My Firefox browser returns (Output) the same php script code I inserted in 
Notepad: ?php

echo h1Hello
Web!/h1;

?



Please, what am I doing wrong?




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



Re: [PHP] Seeking strategy/algorithm for maintaining order of records

2011-10-16 Thread Jim Giner
tamouse mailing lists tamouse.li...@gmail.com wrote in message 
news:cahuc_t8icx4y4mca05rrgzopv4ze7hwsndaiyjjmdvbambv...@mail.gmail.com...
In Sat, Oct 15, 2011 at 7:57 PM, Stephen stephe...@rogers.com wrote:

\label for=category_oneCategory One/label
input type=text name=category_one value=(current sort order for
category one) id=category_one /


I would capture the input fields by using an array name (category[]) 
instead of specific names (ie, category_one.  That way you don't have to 
modify your input procesing if/when you add a new category.



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



Re: [PHP] Seeking strategy/algorithm for maintaining order of records

2011-10-16 Thread Jim Giner
Tedd Sperling tedd.sperl...@gmail.com wrote in message 
news:4c4ff11f-24ea-48cc-a367-48803df58...@gmail.com...

Stephen:

What you describe is a multistep problem. There are many ways to show 
pictures (images) in any order you want.
*

So far, the OP has only asked how to keep his categories in order. 
Curious, yes, but he hasn't even asked how to display the images in order - 
maybe he doesn't care about that.. 



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



<    1   2   3   4   5   6   7   8   9   10   >