php-general Digest 23 Mar 2012 09:03:22 -0000 Issue 7740

2012-03-23 Thread php-general-digest-help

php-general Digest 23 Mar 2012 09:03:22 - Issue 7740

Topics (messages 317190 through 317200):

Re: Thinking out loud - a continuation...
317190 by: Jay Blanchard
317198 by: Robert Cummings

set_error_handler() only triggering every Nth time
317191 by: Daevid Vincent
317199 by: Robert Cummings

MySQL table design
317192 by: Chris Stinemetz
317193 by: Stuart Dallas
317194 by: Bastien
317195 by: Chris Stinemetz
317196 by: Jim Giner

make error
317197 by: »ÆÕÑÔ´

Re: Got HTML5 History API + caching LICKED, I think, grin
317200 by: rene7705

Administrivia:

To subscribe to the digest, e-mail:
php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
php-gene...@lists.php.net


--
---BeginMessage---
[snip]
 At one point you indicated all the data was coming from one table. Can you 
 send me the table fields and indicate which fields are used to determine 
 parent child relationship? Also 2 sample rows of data which have a 
 relationship would be helpful.
[/snip]

Columns - tier1, tier2, tier3, tier4 etc. (ends with tier14)

Children of tier1 are tier2 -

select distinct tier2 from table where tier1 = foo and company = 1
select distinct tier2 from table where tier1 = bar and company = 1
etc.

Children of tier2 are tier3, etc.

tier1   tier2   tier3
1,  executive,  ceo,ceo
1,  executive,  vp-ops, vp-ops
1,  executive,  vp-admin,   vp-admin mgr
1,  executive,  vp-admin,   vp-admin ops mgr
1,  executive,  vp-admin,   vp-admin mgr
1,  executive,  vp-admin,   vp-admin clerk
1,  professionalpro-mgr pro-admin
1,  professionalpro-IT  pro-dev
1,  professionalpro-IT  pro-infra
1,  professionalpro-IT  pro-dev
1,  technician  tech-admin  tech-admin mgr
1,  technician  tech-opstech-ops mgr

Thanks for all of your help. I know I am being a PITA.---End Message---
---BeginMessage---

On 12-03-22 03:54 PM, Jay Blanchard wrote:

[snip]

At one point you indicated all the data was coming from one table. Can you send 
me the table fields and indicate which fields are used to determine parent 
child relationship? Also 2 sample rows of data which have a relationship would 
be helpful.

[/snip]

Columns - tier1, tier2, tier3, tier4 etc. (ends with tier14)

Children of tier1 are tier2 -

select distinct tier2 from table where tier1 = foo and company = 1
select distinct tier2 from table where tier1 = bar and company = 1
etc.

Children of tier2 are tier3, etc.

tier1   tier2   tier3
1,  executive,  ceo,ceo
1,  executive,  vp-ops, vp-ops
1,  executive,  vp-admin,   vp-admin mgr
1,  executive,  vp-admin,   vp-admin ops mgr
1,  executive,  vp-admin,   vp-admin mgr
1,  executive,  vp-admin,   vp-admin clerk
1,  professionalpro-mgr pro-admin
1,  professionalpro-IT  pro-dev
1,  professionalpro-IT  pro-infra
1,  professionalpro-IT  pro-dev
1,  technician  tech-admin  tech-admin mgr
1,  technician  tech-opstech-ops mgr

Thanks for all of your help. I know I am being a PITA.


Your data structure doesn't appear to be very ummm normalized... 
Nonetheless, the following should do it:


?php

//
// Establish the root.
//

$company = 1;

$query =
SELECT DISTINCT 
   .   tier1 AS id 
   .FROM 
   .   tiers 
   .WHERE 
   .   company = {$company} ;

$root = array();
$children = array();
if( $db-query( $query ) )
{
while( ($row = $db-fetchRow()) )
{
$id = $row['id'];

unset( $child );

$child = array
(
'id'   = $id,
'parentId' = false,
'children' = array();
);

$root[$id] = $child;
$children[$id][] = $child;
}
}

//
// Establish the nested levels.
//

for( $tier = 2; $tier = 14; $tier++ )
{
if( !($parents = $children) )
{
break;
}

$parentTier = $tier - 1;

$parentIds = array();
foreach( array_keys( $parents ) as $parentId )
{
$parentIds[$parentId] = $db-quote( $parentId );
}

$query =
SELECT DISTINCT 
   .   tier{$tier} AS id, 
   .   tier{$parentTier} AS parentId 
   .FROM 
   .   tiers 
   .WHERE 
   .   company = {$company} 
   .   AND 

Re: [PHP] Re: Got HTML5 History API + caching LICKED, I think, grin

2012-03-23 Thread rene7705
Because some of you complained about the byte size of my homepage
http://mediabeez.ws (was 2.5mb due to artwork), I've invested some time in
shaving off quite a few bytes;

I've discovered that by using photoshop to reduce the animation image color
depth to indexed color, 217 color, I can get the animation image file
size down to less than 50% of the original that was output by my
spriteGenerator-1.0.0

And you hardly notice the difference at all :)

I'm going to update http://mediabeez.ws later today, hopefully after I find
a way to do this with imagemagick, which my spriteGenerator uses.

And since I also use half the frames for my site logo of http://mediabeez.ws,
that animation file is now 297kb, down from 2mb.


Re: [PHP] Re: Got HTML5 History API + caching LICKED, I think, grin

2012-03-23 Thread rene7705
On Fri, Mar 23, 2012 at 10:02 AM, rene7705 rene7...@gmail.com wrote:

 Because some of you complained about the byte size of my homepage
 http://mediabeez.ws (was 2.5mb due to artwork), I've invested some time
 in shaving off quite a few bytes;

 I've discovered that by using photoshop to reduce the animation image
 color depth to indexed color, 217 color, I can get the animation image
 file size down to less than 50% of the original that was output by my
 spriteGenerator-1.0.0

 And you hardly notice the difference at all :)

 I'm going to update http://mediabeez.ws later today, hopefully after I
 find a way to do this with imagemagick, which my spriteGenerator uses.

 And since I also use half the frames for my site logo of
 http://mediabeez.ws, that animation file is now 297kb, down from 2mb.


 Ok, http://mediabeez.ws and the download zip there are now updated.
On devices with less than 400 pixels wide screen, the total size for the
homepage is now 61kb.
On devices with more than 400 pixels wide screen, it's 910kb, due to more
artwork being loaded.

I take it that takes care of the it's too friggin' large! critiques ;)


Re: [PHP] Re: Got HTML5 History API + caching LICKED, I think, grin

2012-03-23 Thread rene7705
On Fri, Mar 23, 2012 at 12:38 PM, rene7705 rene7...@gmail.com wrote:



 On Fri, Mar 23, 2012 at 10:02 AM, rene7705 rene7...@gmail.com wrote:

 Because some of you complained about the byte size of my homepage
 http://mediabeez.ws (was 2.5mb due to artwork), I've invested some time
 in shaving off quite a few bytes;

 I've discovered that by using photoshop to reduce the animation image
 color depth to indexed color, 217 color, I can get the animation image
 file size down to less than 50% of the original that was output by my
 spriteGenerator-1.0.0

 And you hardly notice the difference at all :)

 I'm going to update http://mediabeez.ws later today, hopefully after I
 find a way to do this with imagemagick, which my spriteGenerator uses.

 And since I also use half the frames for my site logo of
 http://mediabeez.ws, that animation file is now 297kb, down from 2mb.


 Ok, http://mediabeez.ws and the download zip there are now updated.
 On devices with less than 400 pixels wide screen, the total size for the
 homepage is now 61kb.
 On devices with more than 400 pixels wide screen, it's 910kb, due to more
 artwork being loaded.

 I take it that takes care of the it's too friggin' large! critiques ;)


I'd REALLY appreciate if you can load up http://mediabeez.ws on your mobile
phone and tell me
- if it works (if it doesn't, you'll keep staring at a white screen)
- your phone model and type


Re: [PHP] Re: Got HTML5 History API + caching LICKED, I think, grin

2012-03-23 Thread rene7705
On Fri, Mar 23, 2012 at 12:39 PM, rene7705 rene7...@gmail.com wrote:



 On Fri, Mar 23, 2012 at 12:38 PM, rene7705 rene7...@gmail.com wrote:



 On Fri, Mar 23, 2012 at 10:02 AM, rene7705 rene7...@gmail.com wrote:

 Because some of you complained about the byte size of my homepage
 http://mediabeez.ws (was 2.5mb due to artwork), I've invested some time
 in shaving off quite a few bytes;

 I've discovered that by using photoshop to reduce the animation image
 color depth to indexed color, 217 color, I can get the animation image
 file size down to less than 50% of the original that was output by my
 spriteGenerator-1.0.0

 And you hardly notice the difference at all :)

 I'm going to update http://mediabeez.ws later today, hopefully after I
 find a way to do this with imagemagick, which my spriteGenerator uses.

 And since I also use half the frames for my site logo of
 http://mediabeez.ws, that animation file is now 297kb, down from 2mb.


 Ok, http://mediabeez.ws and the download zip there are now updated.
 On devices with less than 400 pixels wide screen, the total size for the
 homepage is now 61kb.
 On devices with more than 400 pixels wide screen, it's 910kb, due to more
 artwork being loaded.

 I take it that takes care of the it's too friggin' large! critiques ;)


 I'd REALLY appreciate if you can load up http://mediabeez.ws on your
 mobile phone and tell me
 - if it works (if it doesn't, you'll keep staring at a white screen)
 - your phone model and type


 As a last note, do NOT load up the buttons demo page if you have to pay
for bandwidth, as that page loads up 10mb of artwork still.


RE: [PHP] Re: Got HTML5 History API + caching LICKED, I think, grin

2012-03-23 Thread Steven Staples
 -Original Message-
 From: rene7705 [mailto:rene7...@gmail.com]
 Sent: March 23, 2012 7:40 AM
 To: php-general
 Subject: Re: [PHP] Re: Got HTML5 History API + caching LICKED, I think,
 grin
 
 On Fri, Mar 23, 2012 at 12:39 PM, rene7705 rene7...@gmail.com wrote:
 
 
 
  On Fri, Mar 23, 2012 at 12:38 PM, rene7705 rene7...@gmail.com wrote:
 
 
 
  On Fri, Mar 23, 2012 at 10:02 AM, rene7705 rene7...@gmail.com wrote:
 
  Because some of you complained about the byte size of my homepage
  http://mediabeez.ws (was 2.5mb due to artwork), I've invested some
time
  in shaving off quite a few bytes;
 
  I've discovered that by using photoshop to reduce the animation image
  color depth to indexed color, 217 color, I can get the animation
 image
  file size down to less than 50% of the original that was output by my
  spriteGenerator-1.0.0
 
  And you hardly notice the difference at all :)
 
  I'm going to update http://mediabeez.ws later today, hopefully after I
  find a way to do this with imagemagick, which my spriteGenerator uses.
 
  And since I also use half the frames for my site logo of
  http://mediabeez.ws, that animation file is now 297kb, down from 2mb.
 
 
  Ok, http://mediabeez.ws and the download zip there are now updated.
  On devices with less than 400 pixels wide screen, the total size for
the
  homepage is now 61kb.
  On devices with more than 400 pixels wide screen, it's 910kb, due to
 more
  artwork being loaded.
 
  I take it that takes care of the it's too friggin' large! critiques
;)
 
 
  I'd REALLY appreciate if you can load up http://mediabeez.ws on your
  mobile phone and tell me
  - if it works (if it doesn't, you'll keep staring at a white screen)
  - your phone model and type
 
 
  As a last note, do NOT load up the buttons demo page if you have to pay
 for bandwidth, as that page loads up 10mb of artwork still.
 

My pet peeve with this, is that it takes at least 5 seconds before anything
displays on the page.  It almost makes me think the site is down.  If you
had a loading content or something (even though that bugs a lot of
people), then it would at least make me think that there is nothing wrong
with your site... (or maybe speed up your code somehow).

Also, the menu dropdowns, I find awkward.   Visually, they don't look
pleasing to me.  There is too much space between them, and the way they
overlap when you have more than 1 level in them, (personally) bugs me.

I also loaded this on my cell phone, LG Optimus One, running Android 2.3,
and it loaded up ok (same slowness), but the menus are VERY slow, and VERY
hard to use unless I zoom right in.




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



Re: [PHP] Re: Got HTML5 History API + caching LICKED, I think, grin

2012-03-23 Thread Marc Guay
Did I accidentally subscribe to the mediabeez website development
mailing list?  Hello?

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



RE: [PHP] Re: Got HTML5 History API + caching LICKED, I think, grin

2012-03-23 Thread ma...@behnke.biz
 concerning your background image:
If I resize my window after loading finished, your images gets distorted
(the one with the bee)

I also think - this is not verified yet - that an animated gif with
interlacing is smaller than your logo png spritemap



Why is this frame loaded

http://mediabeez.ws/code/libraries_rv/animatedJavascriptWidgets-1.0.0/themes/dialogs/dialog_002/frame_normal_000.png

also it is not used in the page you see after loading?



The loading times for these

http://mediabeez.ws/code/libraries_rv/animatedJavascriptWidgets-1.0.0/get_animatedJavascriptWidgets_javascript.php
http://mediabeez.ws/code/libraries_rv/ultiCache-0.1.0/get_ultiCache_javascript.php?gotAnimatedJavascript=true

are greater than one second which is slow. These are cached objects and
should load much faster the second time you call the page

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



Re: [PHP]make error

2012-03-23 Thread Daniel Brown
2012/3/23 黄昭源 wongzhaoy...@gmail.com:
 Hello, I have a problem.
 When I configure php with the parameter --with-mysql=/usr/local/mysql and
 make, some errors happen. Below is the errors:
 ext/mysql/php_mysql.c:995: undefined reference to `_mysqlnd_init'
 ext/mysql/php_mysql.c:1012: undefined reference to `mysqlnd_connect'
 ext/mysql/php_mysql.c:876: undefined reference to `_mysqlnd_init'
 ...
 and so on.
 Is there someone also come across this? Can anyone help me? Thanks!

Sounds like you're missing the MySQL headers from the source
library.  You can either download the full source or install just the
headers via your system's package manager.  If you need more help, let
us know what distribution you're using.

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

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



Re: [PHP] Re: Got HTML5 History API + caching LICKED, I think, grin

2012-03-23 Thread Govinda
 Did I accidentally subscribe to the mediabeez website development
 mailing list?  Hello?

Rene, it's true. ^^^

We'd all LOVE to have an expert list to test our site dev for us... and it can 
even seem to be the case because people are so helpful and certainly help with 
any specific question.. but by now people are wondering, what does this thread 
have to do with PHP?  This is a list for PHP  tips/tricks/questions, etc.

Maybe there is an online service somewhere that connects people who want to 
trade expert technical critique?

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



[PHP] foreach weirdness

2012-03-23 Thread Arno Kuhl
The following snippet is copied from the php manual:
foreach ($arr as $key = $value) {
echo Key: $key; Value: $valuebr /\n;
}

I've always used the foreach loop that way.
But recently I started hitting some really odd problems.

See this following example that illustrates the problem:
$array = array(0, 1, 2, 3, 4, 5, 6); 
foreach ($array as $index=$value) { 
if ( ($index+1)  count($array) ) { 
$array[$index+1] += $value; 
} 
echo $value. ; 
} 
echo br /; 
foreach ($array as $index=$value) { 
echo $value. ; 
} 

You'd expect the output to be: 
0 1 3 6 10 15 21 
0 1 3 6 10 15 21 

But it's actually: 
0 1 2 3 4 5 6 
0 1 3 5 7 9 11 

If you assign the $value by reference in the first loop as someone pointed
out (and confirmed by the manual: As of PHP 5, you can easily modify
array's elements by preceding $value with . This will assign reference
instead of copying the value)

$array = array(0, 1, 2, 3, 4, 5, 6); 
foreach ($array as $index=$value) {// - assign $value by reference
if ( ($index+1)  count($array) ) { 
$array[$index+1] += $value; 
} 
echo $value. ; 
} 
echo br /; 
foreach ($array as $index=$value) { 
echo $value. ; 
} 

it still does not produce the correct result: 
0 1 3 6 10 15 21 
0 1 3 6 10 15 15 

If I watch the $array in a debugger I see odd behaviour for the last element
$array[6] when stepping through the second foreach loop. 
Just before entering the second loop $array[6] == 21 which is correct. 
When I move to the next line (echo $value. ;)  $array[6] changes to 0 !! 
As I step through the second loop $array[6] keeps on changing for each
iteration, with the following values: 
0, 1, 3, 6, 10, 15, 15 
And once I've left the second loop $array[6] is permanently changed from 21
to 15, even though there's no code in the second loop to change $array[6]. 
So what's going on here? 

I confirm this by echoing $array[6] in each iteration in the second loop: 
$array = array(0, 1, 2, 3, 4, 5, 6); 
foreach ($array as $index=$value) {
if ( ($index+1)  count($array) ) { 
$array[$index+1] += $value; 
} 
echo $value. ; 
} 
echo br /; 
foreach ($array as $index=$value) { 
echo $array[6]. ; 
} 
echo br /; 
echo $array[6]; 

the result is: 
0 1 3 6 10 15 21 
0 1 3 6 10 15 15 
15

Note that $array[6] is still 15 even after completing the second foreach
loop.
If you break out of the second loop then $array[6] will be at whatever value
it was at the time you break out (ouch!)

If you assign the $value by reference in the second loop as well: 
$array = array(0, 1, 2, 3, 4, 5, 6); 
foreach ($array as $index=$value) { 
if ( ($index+1)  count($array) ) { 
$array[$index+1] += $value; 
} 
echo $value. ; 
} 
echo br /; 
foreach ($array as $index=$value) {// - assign $value by reference
echo $array[6]. ; 
} 
echo br /; 
echo $array[6]; 

you finally get the correct result: 
0 1 3 6 10 15 21 
21 21 21 21 21 21 21 
21

You can test this with multiple foreach loops and get the same results. If
you modify the array in the first foreach loop, then use an assign $value by
reference in the next 9 foreach loops to get the correct values (without
modifying the array), and then in the 10th foreach loop you don't use an
assign $value by reference (without modifying the array), the array becomes
corrupted.

I sort of understand the need to assign the $value by reference in the first
loop, but why is it also required in every subsequent loop where the array
is not being modified? Especially since all the examples in the manual show
it's not needed? It would appear that once you've modified an array's
elements in a foreach loop you always have to assign $value by reference in
any subsequent foreach loop using that array. And if you don't, not only
will you get the wrong results but the array itself is actually altered,
even if there's no code in the loop to alter it. Is that correct or is it a
bug? At what stage can you start using the array in the normal way again?
That could create hair-pulling havoc for anyone maintaining code if they
haven't noticed that somewhere previously there was code that modified the
array in a foreach loop. Maybe the answer is to always assign $value by
reference in a foreach loop regardless of what you do in that loop, but I'm
not sure what the implications are.

Cheers
Arno


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



Re: [PHP] foreach weirdness

2012-03-23 Thread Robert Cummings

On 12-03-23 11:16 AM, Arno Kuhl wrote:

The following snippet is copied from the php manual:
foreach ($arr as $key =  $value) {
echo Key: $key; Value: $valuebr /\n;
}

I've always used the foreach loop that way.
But recently I started hitting some really odd problems.

See this following example that illustrates the problem:
$array = array(0, 1, 2, 3, 4, 5, 6);
foreach ($array as $index=$value) {
if ( ($index+1)  count($array) ) {
$array[$index+1] += $value;
}
echo $value. ;
}
echo br /;
foreach ($array as $index=$value) {
echo $value. ;
}

You'd expect the output to be:
0 1 3 6 10 15 21
0 1 3 6 10 15 21

But it's actually:
0 1 2 3 4 5 6
0 1 3 5 7 9 11


This is what I would expect since the value is a copy. As such, one 
would expect it to be the value before you made modifications to the array.



If you assign the $value by reference in the first loop as someone pointed
out (and confirmed by the manual: As of PHP 5, you can easily modify
array's elements by preceding $value with. This will assign reference
instead of copying the value)

$array = array(0, 1, 2, 3, 4, 5, 6);
foreach ($array as $index=$value) {//- assign $value by reference
if ( ($index+1)  count($array) ) {
$array[$index+1] += $value;
}
echo $value. ;
}
echo br /;
foreach ($array as $index=$value) {
echo $value. ;
}

it still does not produce the correct result:
0 1 3 6 10 15 21
0 1 3 6 10 15 15


This looks like a bug... the last row should be the same. What version 
of PHP are you using? Have you checked the online bug reports?



If I watch the $array in a debugger I see odd behaviour for the last element
$array[6] when stepping through the second foreach loop.
Just before entering the second loop $array[6] == 21 which is correct.
When I move to the next line (echo $value. ;)  $array[6] changes to 0 !!
As I step through the second loop $array[6] keeps on changing for each
iteration, with the following values:
0, 1, 3, 6, 10, 15, 15
And once I've left the second loop $array[6] is permanently changed from 21
to 15, even though there's no code in the second loop to change $array[6].
So what's going on here?

I confirm this by echoing $array[6] in each iteration in the second loop:
$array = array(0, 1, 2, 3, 4, 5, 6);
foreach ($array as $index=$value) {
if ( ($index+1)  count($array) ) {
$array[$index+1] += $value;
}
echo $value. ;
}
echo br /;
foreach ($array as $index=$value) {
echo $array[6]. ;
}
echo br /;
echo $array[6];

the result is:
0 1 3 6 10 15 21
0 1 3 6 10 15 15
15

Note that $array[6] is still 15 even after completing the second foreach
loop.
If you break out of the second loop then $array[6] will be at whatever value
it was at the time you break out (ouch!)

If you assign the $value by reference in the second loop as well:
$array = array(0, 1, 2, 3, 4, 5, 6);
foreach ($array as $index=$value) {
if ( ($index+1)  count($array) ) {
$array[$index+1] += $value;
}
echo $value. ;
}
echo br /;
foreach ($array as $index=$value) {//- assign $value by reference
echo $array[6]. ;
}
echo br /;
echo $array[6];

you finally get the correct result:
0 1 3 6 10 15 21
21 21 21 21 21 21 21
21

You can test this with multiple foreach loops and get the same results. If
you modify the array in the first foreach loop, then use an assign $value by
reference in the next 9 foreach loops to get the correct values (without
modifying the array), and then in the 10th foreach loop you don't use an
assign $value by reference (without modifying the array), the array becomes
corrupted.

I sort of understand the need to assign the $value by reference in the first
loop, but why is it also required in every subsequent loop where the array
is not being modified? Especially since all the examples in the manual show
it's not needed? It would appear that once you've modified an array's
elements in a foreach loop you always have to assign $value by reference in
any subsequent foreach loop using that array. And if you don't, not only
will you get the wrong results but the array itself is actually altered,
even if there's no code in the loop to alter it. Is that correct or is it a
bug? At what stage can you start using the array in the normal way again?
That could create hair-pulling havoc for anyone maintaining code if they
haven't noticed that somewhere previously there was code that modified the
array in a foreach loop. Maybe the answer is to always assign $value by
reference in a foreach loop regardless of what you do in that loop, but I'm
not sure what the implications are.


Here's how you should do it (IMHO) to avoid all sorts of side effects, 
magic behaviour, and unnecessary complications:


?php

$array = array( 0, 1, 2, 3, 4, 5, 6 );
foreach( array_keys( $array ) as $index )
{
if( ($index + 1)  count( $array ) )
{
   

Re: [PHP]make error

2012-03-23 Thread Asher Wong
I use php-5.4.0.tar.bz2 and MySQL-5.5.21-1.el6.src.rpm in CentOS 6.2. But I
can find the MySQL headers in the MySQL source I used. Is there anything
wrong with my installing MySQL?

2012/3/23 Daniel Brown danbr...@php.net

 2012/3/23 黄昭源 wongzhaoy...@gmail.com:
  Hello, I have a problem.
  When I configure php with the parameter --with-mysql=/usr/local/mysql and
  make, some errors happen. Below is the errors:
  ext/mysql/php_mysql.c:995: undefined reference to `_mysqlnd_init'
  ext/mysql/php_mysql.c:1012: undefined reference to `mysqlnd_connect'
  ext/mysql/php_mysql.c:876: undefined reference to `_mysqlnd_init'
  ...
  and so on.
  Is there someone also come across this? Can anyone help me? Thanks!

 Sounds like you're missing the MySQL headers from the source
 library.  You can either download the full source or install just the
 headers via your system's package manager.  If you need more help, let
 us know what distribution you're using.

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




-- 
黄昭源(Asher Wong)
*Best Wishes To You!*


Re: [PHP]make error

2012-03-23 Thread Asher Wong
I use php-5.4.0.tar.bz2 and MySQL-5.5.21-1.el6.src.rpm in CentOS 6.2. But I
can find the MySQL headers in the MySQL source I used. Is there anything
wrong with my installing MySQL?



 2012/3/23 Daniel Brown danbr...@php.net

 2012/3/23 黄昭源 wongzhaoy...@gmail.com:
  Hello, I have a problem.
  When I configure php with the parameter --with-mysql=/usr/local/mysql
 and
  make, some errors happen. Below is the errors:
  ext/mysql/php_mysql.c:995: undefined reference to `_mysqlnd_init'
  ext/mysql/php_mysql.c:1012: undefined reference to `mysqlnd_connect'
  ext/mysql/php_mysql.c:876: undefined reference to `_mysqlnd_init'
  ...
  and so on.
  Is there someone also come across this? Can anyone help me? Thanks!

 Sounds like you're missing the MySQL headers from the source
 library.  You can either download the full source or install just the
 headers via your system's package manager.  If you need more help, let
 us know what distribution you're using.

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




 --
 黄昭源(Asher Wong)
 *Best Wishes To You!*




-- 
黄昭源(Asher Wong)
*Best Wishes To You!*


[PHP] Re: make error

2012-03-23 Thread Ian
On 23/03/2012 16:58, Asher Wong wrote:
 I use php-5.4.0.tar.bz2 and MySQL-5.5.21-1.el6.src.rpm in CentOS 6.2. But I
 can find the MySQL headers in the MySQL source I used. Is there anything
 wrong with my installing MySQL?

Hi,

You can just install the mysql headers via the devel package if you
don't need the server:

#   yum install mysql-devel


If you want to find where they were installed use:

#   find / -name mysql.h

Regards

Ian
-- 



 
 
 
 2012/3/23 Daniel Brown danbr...@php.net

 2012/3/23 黄昭源 wongzhaoy...@gmail.com:
 Hello, I have a problem.
 When I configure php with the parameter --with-mysql=/usr/local/mysql
 and
 make, some errors happen. Below is the errors:
 ext/mysql/php_mysql.c:995: undefined reference to `_mysqlnd_init'
 ext/mysql/php_mysql.c:1012: undefined reference to `mysqlnd_connect'
 ext/mysql/php_mysql.c:876: undefined reference to `_mysqlnd_init'
 ...
 and so on.
 Is there someone also come across this? Can anyone help me? Thanks!

 Sounds like you're missing the MySQL headers from the source
 library.  You can either download the full source or install just the
 headers via your system's package manager.  If you need more help, let
 us know what distribution you're using.

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




 --
 黄昭源(Asher Wong)
 *Best Wishes To You!*


 
 



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



Re: [PHP] Re: make error

2012-03-23 Thread Asher Wong
I have installed the MySQL-devel and I can find mysql.h, but I still have
the error I mentioned above.
ext/mysql/php_mysql.c:995: undefined reference to `_mysqlnd_init'
ext/mysql/php_mysql.c:1012: undefined reference to `mysqlnd_connect'
ext/mysql/php_mysql.c:876: undefined reference to `_mysqlnd_init'
...
and so on.



 Hi,

 You can just install the mysql headers via the devel package if you
 don't need the server:

 #   yum install mysql-devel


 If you want to find where they were installed use:

 #   find / -name mysql.h

 Regards

 Ian
 --



-- 
黄昭源(Asher Wong)
*Best Wishes To You!*


Re: [PHP] Re: make error

2012-03-23 Thread Daniel Brown
2012/3/23 Asher Wong wongzhaoy...@gmail.com:
 I have installed the MySQL-devel and I can find mysql.h, but I still have
 the error I mentioned above.
 ext/mysql/php_mysql.c:995: undefined reference to `_mysqlnd_init'
 ext/mysql/php_mysql.c:1012: undefined reference to `mysqlnd_connect'
 ext/mysql/php_mysql.c:876: undefined reference to `_mysqlnd_init'

You're using the native driver, so try this instead:

--with-mysql=mysqlnd

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

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



Re: [PHP] Re: make error

2012-03-23 Thread Asher Wong
I trid, but it didn't work.

2012/3/24 Daniel Brown danbr...@php.net

 2012/3/23 Asher Wong wongzhaoy...@gmail.com:
  I have installed the MySQL-devel and I can find mysql.h, but I still have
  the error I mentioned above.
  ext/mysql/php_mysql.c:995: undefined reference to `_mysqlnd_init'
  ext/mysql/php_mysql.c:1012: undefined reference to `mysqlnd_connect'
  ext/mysql/php_mysql.c:876: undefined reference to `_mysqlnd_init'

 You're using the native driver, so try this instead:

--with-mysql=mysqlnd

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




-- 
黄昭源(Asher Wong)
*Best Wishes To You!*


Re: [PHP] Re: make error

2012-03-23 Thread Asher Wong
I tried, but it didn't work.

2012/3/24 Daniel Brown danbr...@php.net

 2012/3/23 Asher Wong wongzhaoy...@gmail.com:
  I have installed the MySQL-devel and I can find mysql.h, but I still have
  the error I mentioned above.
  ext/mysql/php_mysql.c:995: undefined reference to `_mysqlnd_init'
  ext/mysql/php_mysql.c:1012: undefined reference to `mysqlnd_connect'
  ext/mysql/php_mysql.c:876: undefined reference to `_mysqlnd_init'

 You're using the native driver, so try this instead:

--with-mysql=mysqlnd

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




-- 
黄昭源(Asher Wong)
*Best Wishes To You!*


Re: [PHP] Re: make error

2012-03-23 Thread Asher Wong
Now I use the command below to configure php:
./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=mysqlnd
--with-mysql=/usr/local/mysql/bin/mysql_config --with-mysqli=mysqlnd
--with-pdo-mysql=myslqnd

And the error happened:
configure: error: Cannot find MySQL header files under
/usr/local/mysql/bin/mysql_config.


-- 
黄昭源(Asher Wong)
*Best Wishes To You!*


Re: [PHP] Re: make error

2012-03-23 Thread Asher Wong
Now I use the command below to configure php:
./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=mysqlnd
--with-mysql=/usr/local/mysql/bin/mysql_config --with-mysqli=mysqlnd
--with-pdo-mysql=myslqnd

And the error happened:
configure: error: Cannot find MySQL header files under
/usr/local/mysql/bin/mysql_config.
Note that the MySQL client library is not bundled anymore!


-- 
黄昭源(Asher Wong)
*Best Wishes To You!*


Re: [PHP] Re: make error

2012-03-23 Thread Daniel Brown
2012/3/23 Asher Wong wongzhaoy...@gmail.com:
 Now I use the command below to configure php:
 ./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=mysqlnd
 --with-mysql=/usr/local/mysql/bin/mysql_config --with-mysqli=mysqlnd
 --with-pdo-mysql=myslqnd

 And the error happened:
 configure: error: Cannot find MySQL header files under
 /usr/local/mysql/bin/mysql_config.
 Note that the MySQL client library is not bundled anymore!

Drop this:

--with-mysql=/usr/local/mysql/bin/mysql_config

 and please only send one reply.  I keep getting your first
reply, then a second reply one or two minutes later.

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

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



Re: [PHP] Re: make error

2012-03-23 Thread Asher Wong
I droped it but now the new error happened:
checking for mysql_config... not found
configure: error: Unable to find your mysql installation

And I'm sorry to send more than one reply. Maybe there are something wrong
with the network here.

2012/3/24 Daniel Brown danbr...@php.net

 2012/3/23 Asher Wong wongzhaoy...@gmail.com:
  Now I use the command below to configure php:
  ./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=mysqlnd
  --with-mysql=/usr/local/mysql/bin/mysql_config --with-mysqli=mysqlnd
  --with-pdo-mysql=myslqnd
 
  And the error happened:
  configure: error: Cannot find MySQL header files under
  /usr/local/mysql/bin/mysql_config.
  Note that the MySQL client library is not bundled anymore!

 Drop this:

--with-mysql=/usr/local/mysql/bin/mysql_config

 and please only send one reply.  I keep getting your first
 reply, then a second reply one or two minutes later.

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




-- 
黄昭源(Asher Wong)
*Best Wishes To You!*


Re: [PHP] Re: make error

2012-03-23 Thread Daniel Brown
2012/3/23 Asher Wong wongzhaoy...@gmail.com:
 I droped it but now the new error happened:
 checking for mysql_config... not found
 configure: error: Unable to find your mysql installation

Try:

locate mysql_config

 And I'm sorry to send more than one reply. Maybe there are something wrong
 with the network here.

No problem.  I thought it may have been deliberate because of the
intermission between messages.  Not a big deal at all.

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

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



Re: [PHP] Re: make error

2012-03-23 Thread Asher Wong

 This is the result of locate mysql_config:

[zhaoyuan@localhost php-5.4.0]$ locate mysql_config
/home/zhaoyuan/下载/MySQL-5.5.21-1.el6.src/mysql-5.5.21/man/mysql_config.1
/home/zhaoyuan/下载/MySQL-5.5.21-1.el6.src/mysql-5.5.21/scripts/mysql_config
/home/zhaoyuan/下载/MySQL-5.5.21-1.el6.src/mysql-5.5.21/scripts/
mysql_config.pl.in
/home/zhaoyuan/下载/MySQL-5.5.21-1.el6.src/mysql-5.5.21/scripts/mysql_config.sh
/usr/bin/mysql_config
/usr/local/mysql/bin/mysql_config
/usr/local/mysql/man/man1/mysql_config.1
/usr/share/man/man1/mysql_config.1.gz


-- 
黄昭源(Asher Wong)
*Best Wishes To You!*


RE: [PHP] foreach weirdness

2012-03-23 Thread Arno Kuhl
-Original Message-
From: Robert Cummings [mailto:rob...@interjinn.com] 
Sent: 23 March 2012 06:11 PM
To: a...@dotcontent.net
Cc: php-general@lists.php.net
Subject: Re: [PHP] foreach weirdness

On 12-03-23 11:16 AM, Arno Kuhl wrote:
 The following snippet is copied from the php manual:
 foreach ($arr as $key =  $value) {
   echo Key: $key; Value: $valuebr /\n; }

 I've always used the foreach loop that way.
 But recently I started hitting some really odd problems.

 See this following example that illustrates the problem:
 $array = array(0, 1, 2, 3, 4, 5, 6);
 foreach ($array as $index=$value) {//- assign $value by reference
   if ( ($index+1)  count($array) ) {
   $array[$index+1] += $value;
   }
   echo $value. ;
 }
 echo br /;
 foreach ($array as $index=$value) {
   echo $value. ;
 }

 it still does not produce the correct result:
 0 1 3 6 10 15 21
 0 1 3 6 10 15 15

This looks like a bug... the last row should be the same. What version of PHP 
are you using? Have you checked the online bug reports?

.
--

Hi Rob

I'm using php 5.3.5. What result do you get when you run this code?
I haven't checked any bug reports, I'll google to see where I would do that.

Your code gets round the problem, but I was specifically referring to the use 
of foreach with its unexpected side-effects. There are a few different designs 
like look-ahead where it seemed the obvious way to go. I know I've used this 
type of foreach coding in the past, and have this nagging feeling there's a 
whole bunch of code just waiting to explode. I always just assumed it worked 
because it's pretty simple. I'd previously been caught out forgetting the 
assign by reference in the foreach loop that modified the array but I always 
caught it long before it went live, but I never considered having to also use 
assign by reference in subsequent foreach loops because it so obviously wasn't 
necessary. Now I'm searching through my scripts to see if there are any 
potential problems caused by this (already found one), and wondering what else 
I've done where I no longer have access to the sources.

BTW I'm told on another forum this issue has been discussed multiple times on 
this mailing list - did I miss it? Was there a resolution?

Cheers
Arno


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



Re: [PHP] Thinking out loud - a continuation...

2012-03-23 Thread Jay Blanchard
[snip]
 Your data structure doesn't appear to be very ummm normalized... Nonetheless, 
 the following should do it:
[/snip]

You're absolutely correct. Unfortunately I am not the designer and cannot 
really do anything about it. I just have to work with what I have. Thank you 
very much for this - I will test it out this afternoon and let you know how it 
all goes.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Thinking out loud - a continuation...

2012-03-23 Thread Robert Cummings

On 12-03-23 02:08 PM, Jay Blanchard wrote:

[snip]

Your data structure doesn't appear to be very ummm normalized... Nonetheless, 
the following should do it:

[/snip]

You're absolutely correct. Unfortunately I am not the designer and cannot 
really do anything about it. I just have to work with what I have. Thank you 
very much for this - I will test it out this afternoon and let you know how it 
all goes.



I figured it was something you had been given... just thought I'd point 
out the obvious :D


Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] Thinking out loud - a continuation...

2012-03-23 Thread Jay Blanchard
[snip]
$json = JSON_encode( $root );
[/snip]

Update on my test. This works perfectly Robert - thank you very much! But there 
is one small problem that I am trouble-shooting: it only goes one layer and 
doesn't progress any further. I suspect it is on this section of code that I am 
going to add some stuff to to see what is happening.

if( !($parents = $children) ){
   break;
   }

Re: [PHP] Thinking out loud - a continuation...

2012-03-23 Thread Jay Blanchard

 [snip]
   $json = JSON_encode( $root );
 [/snip]
 
 Update on my test. This works perfectly Robert - thank you very much! But 
 there is one small problem that I am trouble-shooting: it only goes one layer 
 and doesn't progress any further. I suspect it is on this section of code 
 that I am going to add some stuff to to see what is happening.
 
 if( !($parents = $children) ){
   break;
   }

It would appear that both arrays are empty on the next cycle through so the 
break occurs.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Thinking out loud - a continuation...

2012-03-23 Thread Robert Cummings

On 12-03-23 03:17 PM, Jay Blanchard wrote:

[snip]

$json = JSON_encode( $root );

[/snip]

Update on my test. This works perfectly Robert - thank you very much! But there 
is one small problem that I am trouble-shooting: it only goes one layer and 
doesn't progress any further. I suspect it is on this section of code that I am 
going to add some stuff to to see what is happening.

if( !($parents =$children) ){
break;
}


I didn't actually test it... if you have trouble figuring out the 
problem feel free to send me a copy of your table (in private) and I'll 
debug :)


Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] Thinking out loud - a continuation...

2012-03-23 Thread Robert Cummings

On 12-03-23 03:22 PM, Jay Blanchard wrote:



[snip]

   $json = JSON_encode( $root );

[/snip]

Update on my test. This works perfectly Robert - thank you very much! But there 
is one small problem that I am trouble-shooting: it only goes one layer and 
doesn't progress any further. I suspect it is on this section of code that I am 
going to add some stuff to to see what is happening.

if( !($parents =$children) ){
   break;
   }


It would appear that both arrays are empty on the next cycle through so the 
break occurs.


Did you get any results form the database on the second run through the 
query loop?


Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] foreach weirdness

2012-03-23 Thread Robert Cummings

On 12-03-23 02:04 PM, Arno Kuhl wrote:

Hi Rob

I'm using php 5.3.5. What result do you get when you run this code?
I haven't checked any bug reports, I'll google to see where I would do that.

Your code gets round the problem, but I was specifically referring to the use 
of foreach with its unexpected side-effects.


I know... but when I first started doing things like what you tried to 
do, there were no references for foreach values and so I've just 
naturally been in the habit of explicitly accessing the values in the 
array by index. Apparently that will serve me well since my stuff won't 
blow up with this bug ;)



There are a few different designs like look-ahead where it seemed the obvious 
way to go. I know I've used this type of foreach coding in the past, and have 
this nagging feeling there's a whole bunch of code just waiting to explode. I 
always just assumed it worked because it's pretty simple. I'd previously been 
caught out forgetting the assign by reference in the foreach loop that modified 
the array but I always caught it long before it went live, but I never 
considered having to also use assign by reference in subsequent foreach loops 
because it so obviously wasn't necessary. Now I'm searching through my scripts 
to see if there are any potential problems caused by this (already found one), 
and wondering what else I've done where I no longer have access to the sources.

BTW I'm told on another forum this issue has been discussed multiple times on 
this mailing list - did I miss it? Was there a resolution?


I must have missed it too... but then I've not been very active in the 
past year or so :)


Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] Thinking out loud - a continuation...

2012-03-23 Thread Jay Blanchard

On Mar 23, 2012, at 2:25 PM, Robert Cummings wrote:

 On 12-03-23 03:17 PM, Jay Blanchard wrote:
 [snip]
$json = JSON_encode( $root );
 [/snip]
 
 Update on my test. This works perfectly Robert - thank you very much! But 
 there is one small problem that I am trouble-shooting: it only goes one 
 layer and doesn't progress any further. I suspect it is on this section of 
 code that I am going to add some stuff to to see what is happening.
 
 if( !($parents =$children) ){
break;
}
 
 I didn't actually test it... if you have trouble figuring out the problem 
 feel free to send me a copy of your table (in private) and I'll debug :)

I had it backwards. Both arrays are empty and the break should not occur 
because they are equal to each other. Let me send you a portion of the table 
Robert. 
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Thinking out loud - a continuation...

2012-03-23 Thread Robert Cummings

On 12-03-23 03:28 PM, Jay Blanchard wrote:


On Mar 23, 2012, at 2:25 PM, Robert Cummings wrote:


On 12-03-23 03:17 PM, Jay Blanchard wrote:

[snip]

$json = JSON_encode( $root );

[/snip]

Update on my test. This works perfectly Robert - thank you very much! But there 
is one small problem that I am trouble-shooting: it only goes one layer and 
doesn't progress any further. I suspect it is on this section of code that I am 
going to add some stuff to to see what is happening.

if( !($parents =$children) ){
break;
}


I didn't actually test it... if you have trouble figuring out the problem feel 
free to send me a copy of your table (in private) and I'll debug :)


I had it backwards. Both arrays are empty and the break should not occur 
because they are equal to each other. Let me send you a portion of the table 
Robert.


No, I'm performing assignment... intentionally. Parent's becomes the 
previous children to move down a level. The following:


if( !($parents = $children) )

performs assignment and an empty array check in one statement.

Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] Thinking out loud - a continuation...

2012-03-23 Thread Jay Blanchard
[snip]
 Did you get any results form the database on the second run through the query 
 loop?
[/snip]

Actually, no. I just ran the raw query - 

SELECT DISTINCT `TIER3DATA` AS id, `TIER2DATA` AS parentId FROM 
`POSITION_SETUP` WHERE `COMPANY_ID` = '3' AND `TIER2DATA` IN ('Executives and 
Management','Professionals','Technicians','Craft 
Workers-Skilled','Operatives','Contractor','Sales Workers','Laborers and 
Helpers','Admin Support')

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



Re: [PHP] Thinking out loud - a continuation...

2012-03-23 Thread Jay Blanchard
[snip]
 No, I'm performing assignment... intentionally. Parent's becomes the previous 
 children to move down a level. The following:
 
if( !($parents = $children) )
 
 performs assignment and an empty array check in one statement.
[/snip]

Gotcha'. 

So all I am ever getting back right now is the result of the first query.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Thinking out loud - a continuation...

2012-03-23 Thread Jay Blanchard
 [snip]
 SELECT DISTINCT `TIER3DATA` AS id, `TIER2DATA` AS parentId FROM 
 `POSITION_SETUP` WHERE `COMPANY_ID` = '3' AND `TIER2DATA` IN ('Executives and 
 Management','Professionals','Technicians','Craft 
 Workers-Skilled','Operatives','Contractor','Sales Workers','Laborers and 
 Helpers','Admin Support')
 
 and it is empty. 
[/snip]

I figured out part of the problem - the for loop starts at tier2 instead of 
tier1

Once I made that change I get the following error:

Fatal error: Cannot use string offset as an array in 
/home/orcadept/public_html/poschart/json_chart.php on line 139

Line 139 is $item['children'][$id] = $child;

Re: [PHP] Thinking out loud - a continuation...

2012-03-23 Thread Robert Cummings

On 12-03-23 03:52 PM, Jay Blanchard wrote:

[snip]
SELECT DISTINCT `TIER3DATA` AS id, `TIER2DATA` AS parentId FROM 
`POSITION_SETUP` WHERE `COMPANY_ID` = '3' AND `TIER2DATA` IN ('Executives and 
Management','Professionals','Technicians','Craft 
Workers-Skilled','Operatives','Contractor','Sales Workers','Laborers and 
Helpers','Admin Support')

and it is empty.

[/snip]

I figured out part of the problem - the for loop starts at tier2 instead of 
tier1


It's meant to since outside the loop we address tier 1 when we generate 
the root and first set of parents (These have no parent ID so they are a 
special case).



Once I made that change I get the following error:

Fatal error: Cannot use string offset as an array in 
/home/orcadept/public_html/poschart/json_chart.php on line 139

Line 139 is $item['children'][$id] =$child;


$item['children'] should be an array, somehow a string has been assigned :/

Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] Thinking out loud - a continuation...

2012-03-23 Thread Jay Blanchard
[snip]
 $item['children'] should be an array, somehow a string has been assigned :/
[/snip]

Yep. I am trying to figure that out now. I'm sure it is something really small. 

BTW, after making the change to the for loop there are results returned as we 
expected.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Thinking out loud - a continuation...

2012-03-23 Thread Jay Blanchard
 [snip]
 $item['children'] should be an array, somehow a string has been assigned :/
 [/snip]
 
 Yep. I am trying to figure that out now. I'm sure it is something really 
 small. 
[/snip]

I have been hammering away at it for a while now and still cannot find the 
issue. I'll push away for a while and come back to it. Robert I owe you so many 
thinks for getting me this far and opening me up to making this more efficient. 
I just have to push on through and get to the point where  the JSON can be 
created and consumed. If any light bulb goes on over your head would you let me 
know. I have tried everything that I know works to keep this from being a 
string - I am just missing something.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Thinking out loud - a continuation...

2012-03-23 Thread Jay Blanchard
[snip]
…stuff….
[/snip]

For those interested here is where the problem seems to occur - 

$child = array
   (
   'id'   = $id,
   'parentId' = $pid,
   'children' = array()
   );
   
   $children[$id][] = $child;
   
   foreach( $parents[$pid] as $items ){
   foreach( $items as $item ){   
 $item['children'][$id] = $child; // error: Cannot use 
string offset as an array
   }
   }

Maybe someone will see this and know what's going on. Before the foreach 
$children is an array. 



Re: [PHP] foreach weirdness

2012-03-23 Thread Simon Schick
2012/3/23 Robert Cummings rob...@interjinn.com

 On 12-03-23 11:16 AM, Arno Kuhl wrote:


 it still does not produce the correct result:
 0 1 3 6 10 15 21
 0 1 3 6 10 15 15


 This looks like a bug... the last row should be the same. What version of
 PHP are you using? Have you checked the online bug reports?



Hi, Robert

Does not seem like a bug to me ...
http://schlueters.de/blog/archives/141-References-and-foreach.html

What you should do to get the expected result:
Unset the variable after you don't need this reference any longer.

Bye
Simon

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



Re: [PHP] foreach weirdness

2012-03-23 Thread Robert Cummings

On 12-03-23 06:30 PM, Simon Schick wrote:

2012/3/23 Robert Cummingsrob...@interjinn.com


On 12-03-23 11:16 AM, Arno Kuhl wrote:



it still does not produce the correct result:
0 1 3 6 10 15 21
0 1 3 6 10 15 15



This looks like a bug... the last row should be the same. What version of
PHP are you using? Have you checked the online bug reports?




Hi, Robert

Does not seem like a bug to me ...
http://schlueters.de/blog/archives/141-References-and-foreach.html

What you should do to get the expected result:
Unset the variable after you don't need this reference any longer.


Ah yes... that clued me in. I disagree with the article's generalization 
with respect to references since references accomplish some things that 
cannot be accomplished otherwise, but even I missed the fact that the 
second loop was using a variable that was a reference to the last 
element of the array as created in the first loop *lol*. The user's very 
act of checking their results was confounding the result... I love it :)


Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] Thinking out loud - a continuation...

2012-03-23 Thread Robert Cummings

On 12-03-23 05:41 PM, Jay Blanchard wrote:

[-- DELETED GARBAGE --]  :)


I just realized... I've been stuck in a thinking rut. I latched onto one 
solution that works well in some case but didn't fully examine the 
nuances of your own scenario. Given the way you are creating your 
hierarchy you will ultimately retrieve all rows. As such the following 
simple solution will do what you need:


?php

$company = 1;

$query =
SELECT DISTINCT 
   .   * 
   .FROM 
   .   tiers 
   .WHERE 
   .   company = {$company} ;

$root = array();
if( $db-query( $query ) )
{
while( ($row = $db-fetchRow()) )
{
$focus = $root;
for( $i = 1; $i = 14; $i++ )
{
$name = $row['tier'.$i];

if( !isset( $focus[$name] ) )
{
$focus[$name] = array();
}

$focus = $focus[$name];
}
}
}

$json = JSON_encode( $root );

?

Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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