Re: [PHP] PHP: inexplicable behaviour of pre- and post-increment operators
On Fri, Feb 26, 2010 at 11:01 PM, clanc...@cybec.com.au wrote: while ($i $j) { $b[$i] = $a[$i++]; } B. You get $b[0] = $a[1], and so on (as you would expect). Wouldn't that be $b[0] = $a[0], with the value of $i being 1 *after* the statement was finished executing? You used a post-decrement operator on $i at the end of your statement, so I don't think that $i would be increased before being used to index into the $a array. // Todd
Re: [PHP] PHP: inexplicable behaviour of pre- and post-increment operators
On Wed, 3 Mar 2010 08:21:06 -0600, halip...@gmail.com (haliphax) wrote: On Fri, Feb 26, 2010 at 11:01 PM, clanc...@cybec.com.au wrote: while ($i $j) { $b[$i] = $a[$i++]; } B. You get $b[0] = $a[1], and so on (as you would expect). Wouldn't that be $b[0] = $a[0], with the value of $i being 1 *after* the statement was finished executing? You used a post-decrement operator on $i at the end of your statement, so I don't think that $i would be increased before being used to index into the $a array. Try it! Clancy -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP: inexplicable behaviour of pre- and post-increment operators
Thanks for taking time to provide the examples, Clancy, I'll know what potential pitfalls to wary of now :) On Fri, Feb 26, 2010 at 11:01 PM, clanc...@cybec.com.au wrote: A week ago Dasn asked a question about converting arrays, and I quoted one possible way of achieving his task, using the operation: $i = 0; while ($i $k) { $b[$a[$i++]] = $a[$i++]; } I added the comment that I have always been wary of using statements like this because I was unsure when the incrementing would occur, so I tried it. I received several CC e-mails replying to this post, including one rather critical comment to the effect that pre-and post-increment were all quite simple, and I really ought to learn the fundamentals before I started trying to do anything elaborate. I posted a reply to these e-mails, but as neither they, nor my reply, or any follow-up discussion ever appeared in the discussion group I will repost this reply. (I did have a power failure at this time, so it is conceivable that any follow-up was lost as a result of a glitch in my mailer, but I think it is more likely that there was a glitch in the discussion group server.) Unfortunately things aren't nearly as simple as this writer believes. The rule I have always used is that if you use the same variable as an index on both sides of an assign statement it is not safe to change the value of the index within the statement. While I have achieved the result I wanted in the example above (using PHP 5.1.6 -- there is no guarantee it would work with other implementations of PHP) the results of doing this in the general case can be quite inexplicable. The particular case which prompted my comment was the one where you want to copy part of one array into the corresponding elements of another array. In accordance with my rule, I normally write: $i = 0; $j=count($a); while ($i $j) { $b[$i] = $a[$i]; ++$i; } It is tempting to try to put the increment into the assignment statement. Clearly the value of $a[$i] has to be read before it can be written to $b[$i], so the logical expression would be: while ($i $j) { $b[$i++] = $a[$i]; } A. However if you try this, you get $b[1] = $a[0], and so on. But if you try the alternative: while ($i $j) { $b[$i] = $a[$i++]; } B. You get $b[0] = $a[1], and so on (as you would expect). Out of curiosity, I then tried: $i = -1; $j=count($a) - 1; while ($i $j) { $b[$i] = $a[++$i]; } C This gave the desired result, and seemed moderately logical. However when I tried: $i = -1; $j=count($a) - 1; while ($i $j) { $b[++$i] = $a[$i]; } D This gave exactly the same result. It is quite impossible to explain the results in cases A and D from the definitions of the pre-and post-increment operator, so I think I will stick to my safe rule! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Nephtali: PHP web framework that functions beautifully http://nephtaliproject.com
[PHP] Re: PHP: inexplicable behaviour of pre- and post-increment operators
Mess Dne 27.2.2010 5:01, clanc...@cybec.com.au napsal(a): A week ago Dasn asked a question about converting arrays, and I quoted one possible way of achieving his task, using the operation: $i = 0; while ($i $k) { $b[$a[$i++]] = $a[$i++]; } I added the comment that I have always been wary of using statements like this because I was unsure when the incrementing would occur, so I tried it. I received several CC e-mails replying to this post, including one rather critical comment to the effect that pre-and post-increment were all quite simple, and I really ought to learn the fundamentals before I started trying to do anything elaborate. I posted a reply to these e-mails, but as neither they, nor my reply, or any follow-up discussion ever appeared in the discussion group I will repost this reply. (I did have a power failure at this time, so it is conceivable that any follow-up was lost as a result of a glitch in my mailer, but I think it is more likely that there was a glitch in the discussion group server.) Unfortunately things aren't nearly as simple as this writer believes. The rule I have always used is that if you use the same variable as an index on both sides of an assign statement it is not safe to change the value of the index within the statement. While I have achieved the result I wanted in the example above (using PHP 5.1.6 -- there is no guarantee it would work with other implementations of PHP) the results of doing this in the general case can be quite inexplicable. The particular case which prompted my comment was the one where you want to copy part of one array into the corresponding elements of another array. In accordance with my rule, I normally write: $i = 0; $j=count($a); while ($i $j) { $b[$i] = $a[$i]; ++$i; } It is tempting to try to put the increment into the assignment statement. Clearly the value of $a[$i] has to be read before it can be written to $b[$i], so the logical expression would be: while ($i $j) { $b[$i++] = $a[$i]; } A. However if you try this, you get $b[1] = $a[0], and so on. But if you try the alternative: while ($i $j) { $b[$i] = $a[$i++]; } B. You get $b[0] = $a[1], and so on (as you would expect). Out of curiosity, I then tried: $i = -1; $j=count($a) - 1; while ($i $j) { $b[$i] = $a[++$i]; }C This gave the desired result, and seemed moderately logical. However when I tried: $i = -1; $j=count($a) - 1; while ($i $j) { $b[++$i] = $a[$i]; }D This gave exactly the same result. It is quite impossible to explain the results in cases A and D from the definitions of the pre-and post-increment operator, so I think I will stick to my safe rule! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP: inexplicable behaviour of pre- and post-increment operators
A week ago Dasn asked a question about converting arrays, and I quoted one possible way of achieving his task, using the operation: $i = 0; while ($i $k) { $b[$a[$i++]] = $a[$i++]; } I added the comment that I have always been wary of using statements like this because I was unsure when the incrementing would occur, so I tried it. I received several CC e-mails replying to this post, including one rather critical comment to the effect that pre-and post-increment were all quite simple, and I really ought to learn the fundamentals before I started trying to do anything elaborate. I posted a reply to these e-mails, but as neither they, nor my reply, or any follow-up discussion ever appeared in the discussion group I will repost this reply. (I did have a power failure at this time, so it is conceivable that any follow-up was lost as a result of a glitch in my mailer, but I think it is more likely that there was a glitch in the discussion group server.) Unfortunately things aren't nearly as simple as this writer believes. The rule I have always used is that if you use the same variable as an index on both sides of an assign statement it is not safe to change the value of the index within the statement. While I have achieved the result I wanted in the example above (using PHP 5.1.6 -- there is no guarantee it would work with other implementations of PHP) the results of doing this in the general case can be quite inexplicable. The particular case which prompted my comment was the one where you want to copy part of one array into the corresponding elements of another array. In accordance with my rule, I normally write: $i = 0; $j=count($a); while ($i $j) { $b[$i] = $a[$i]; ++$i; } It is tempting to try to put the increment into the assignment statement. Clearly the value of $a[$i] has to be read before it can be written to $b[$i], so the logical expression would be: while ($i $j) { $b[$i++] = $a[$i]; } A. However if you try this, you get $b[1] = $a[0], and so on. But if you try the alternative: while ($i $j) { $b[$i] = $a[$i++]; } B. You get $b[0] = $a[1], and so on (as you would expect). Out of curiosity, I then tried: $i = -1; $j=count($a) - 1; while ($i $j) { $b[$i] = $a[++$i]; } C This gave the desired result, and seemed moderately logical. However when I tried: $i = -1; $j=count($a) - 1; while ($i $j) { $b[++$i] = $a[$i]; } D This gave exactly the same result. It is quite impossible to explain the results in cases A and D from the definitions of the pre-and post-increment operator, so I think I will stick to my safe rule! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: RES: [PHP] inexplicable behaviour SOLVED
2009/4/27 9el le...@phpxperts.net: Thanks for the clarification, Mike. In my ignorance, I was under the impression that the right side of the equation was only for the use of the left part. How stupid of me. So what I should have been doing was $Count1 = $Count + 1; right? $Count1 = $Count++; is not the same as $Count1 = $Count + 1; ?php $Count1 = 100; echo Start with $Count1, PHP_EOL; $Count1 = $Count1++; echo For \$Count1 = \$Count1++; the value in \$Count1 is $Count1, PHP_EOL; $Count1 = $Count1 + 1; echo For \$Count1 = \$Count1 + 1; the value in \$Count1 is $Count1, PHP_EOL; outputs ... Start with 100 For $Count1 = $Count1++; the value in $Count1 is 100 For $Count1 = $Count1 + 1; the value in $Count1 is 101 This shows that post-inc during an assignment does not affect the value assigned. Something that I thought would happen was if I ... ?php $Count1 = 100; echo $Count1 = $Count1++, PHP_EOL; echo $Count1, PHP_EOL; I thought I'd get ... 101 100 but I get 100 100 I thought the ++ would happen AFTER the assignment and the ++ to the value of the assignment. But this is not the case. $Count = $Count + 1; is exactly(?) same as $Count++; or ++$Count But not exactly same. PostFix notation adds the value after assigning. PreFix notation adds the value right away. But optimized programming argues about how machine is coded nowadays. Anyway, I don't need that statement anymore as I found the error of my ways and have corrected it. And behold, the light came forth and it worked. :-) Regards Lenin www.twitter.com/nine_L www.lenin9l.wordpress.com -- - Richard Quadling Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498r=213474731 Standing on the shoulders of some very clever giants! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: RES: [PHP] inexplicable behaviour SOLVED
Thats why I used a (?) after exactly. PJ didn't have a need for the value. ;)
RE: RES: [PHP] inexplicable behaviour SOLVED
On 27 April 2009 14:21, PJ advised: Ford, Mike wrote: On 26 April 2009 22:59, PJ advised: kranthi wrote: if $Count1 is never referenced after this, then certainly this assignment operation is redundent. but assignment is not the ONLY operation of this statement. if u hav not noticed a post increment operator has been used which will affect the value of $Count as well, and this operation is required for the script to work. the script should work even if u replace $Count1 = $Count++; with $Count++; Kranthi. Not quite, since that would change the $Count variable and that is used leater in the code. Um -- I must be missing something here, because those two statements have exactly the same effect on $Count, incrementing it by one (and you said the first statement fixed your problem, so logically the second one must too). In fact, because you've used a post-increment, the statement $Count1 = $Count++; ends up with $Count == $Count1+1, and $Count1 being the original value of $Count!! This whole scenario smacks to me of a classic off-by-one error -- either $Count actually *needs* to be one greater than the value you first thought of, or some other value you are comparing it to should be one smaller than it actually is. Cheers! Thanks for the clarification, Mike. In my ignorance, I was under the impression that the right side of the equation was only for the use of the left part. How stupid of me. So what I should have been doing was $Count1 = $Count + 1; right? No -- because, as you stated, $Count1 was not referred to anywhere else, so there was and would have been no usefulness in assigning any value to it. You could equally well have said $Count1 = 2.71828 + 3.14159 * $Count++; and got the same result -- because this still increments $Count by 1, and anything else the statement does is irrelevant if $Count1 is never referred to anywhere else!!! ;) ;) What you did worked because $Count++ *always* adds one to the value of $Count, no matter where it appears -- the crucial part of your original statement was the $Count++ bit, with the assignment to $Count1 being a massive red herring. For ultimate clarification, the following 4 statements all have identical effect: $Count = $Count + 1; $Count += 1; $Count++; ++$Count; and any one of them would have had the same effect on your result. This is why I say it was an off-by-one error -- your programming logic somehow *needed* $Count to be 1 greater than you thought it did, so the inadvertent incrementation of it was doing the trick for you. Hope this helps increase the illumination in your head a tiny bit more. Cheers! Mike -- Mike Ford, Electronic Information Developer, C507, Leeds Metropolitan University, Civic Quarter Campus, Woodhouse Lane, LEEDS, LS1 3HE, United Kingdom Email: m.f...@leedsmet.ac.uk Tel: +44 113 812 4730 To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: RES: [PHP] inexplicable behaviour SOLVED
Ford, Mike wrote: On 27 April 2009 14:21, PJ advised: Ford, Mike wrote: On 26 April 2009 22:59, PJ advised: kranthi wrote: if $Count1 is never referenced after this, then certainly this assignment operation is redundent. but assignment is not the ONLY operation of this statement. if u hav not noticed a post increment operator has been used which will affect the value of $Count as well, and this operation is required for the script to work. the script should work even if u replace $Count1 = $Count++; with $Count++; Kranthi. Not quite, since that would change the $Count variable and that is used leater in the code. Um -- I must be missing something here, because those two statements have exactly the same effect on $Count, incrementing it by one (and you said the first statement fixed your problem, so logically the second one must too). In fact, because you've used a post-increment, the statement $Count1 = $Count++; ends up with $Count == $Count1+1, and $Count1 being the original value of $Count!! This whole scenario smacks to me of a classic off-by-one error -- either $Count actually *needs* to be one greater than the value you first thought of, or some other value you are comparing it to should be one smaller than it actually is. Cheers! Thanks for the clarification, Mike. In my ignorance, I was under the impression that the right side of the equation was only for the use of the left part. How stupid of me. So what I should have been doing was $Count1 = $Count + 1; right? No -- because, as you stated, $Count1 was not referred to anywhere else, so there was and would have been no usefulness in assigning any value to it. You could equally well have said $Count1 = 2.71828 + 3.14159 * $Count++; and got the same result -- because this still increments $Count by 1, and anything else the statement does is irrelevant if $Count1 is never referred to anywhere else!!! ;) ;) What you did worked because $Count++ *always* adds one to the value of $Count, no matter where it appears -- the crucial part of your original statement was the $Count++ bit, with the assignment to $Count1 being a massive red herring. For ultimate clarification, the following 4 statements all have identical effect: $Count = $Count + 1; $Count += 1; $Count++; ++$Count; and any one of them would have had the same effect on your result. This is why I say it was an off-by-one error -- your programming logic somehow *needed* $Count to be 1 greater than you thought it did, so the inadvertent incrementation of it was doing the trick for you. Hope this helps increase the illumination in your head a tiny bit more. Indeed, it does. Thanks. -- Hervé Kempf: Pour sauver la planète, sortez du capitalisme. - Phil Jourdan --- p...@ptahhotep.com http://www.ptahhotep.com http://www.chiccantine.com/andypantry.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: RES: [PHP] inexplicable behaviour SOLVED
$Count = $Count + 1; is *exactly(?)* same as $Count++; Â or ++$Count But not exactly same. Â PostFix notation adds the value after assigning . PreFix notation adds the value right away. But optimized programming argues about how machine is coded nowadays. Thanks Mike for clarifying this much. Butt I already said those in brief I marked them in red now :) Lenin www.twitter.com/nine_L
Re: RES: [PHP] inexplicable behaviour SOLVED
Richard Quadling wrote: 2009/4/27 9el le...@phpxperts.net: Thanks for the clarification, Mike. In my ignorance, I was under the impression that the right side of the equation was only for the use of the left part. How stupid of me. So what I should have been doing was $Count1 = $Count + 1; right? $Count1 = $Count++; is not the same as $Count1 = $Count + 1; ?php $Count1 = 100; echo Start with $Count1, PHP_EOL; $Count1 = $Count1++; echo For \$Count1 = \$Count1++; the value in \$Count1 is $Count1, PHP_EOL; $Count1 = $Count1 + 1; echo For \$Count1 = \$Count1 + 1; the value in \$Count1 is $Count1, PHP_EOL; outputs ... Start with 100 For $Count1 = $Count1++; the value in $Count1 is 100 For $Count1 = $Count1 + 1; the value in $Count1 is 101 This shows that post-inc during an assignment does not affect the value assigned. Something that I thought would happen was if I ... ?php $Count1 = 100; echo $Count1 = $Count1++, PHP_EOL; echo $Count1, PHP_EOL; I thought I'd get ... 101 100 but I get 100 100 I thought the ++ would happen AFTER the assignment and the ++ to the value of the assignment. But this is not the case. $Count = $Count + 1; is exactly(?) same as $Count++; Â or ++$Count But not exactly same. Â PostFix notation adds the value after assigning. PreFix notation adds the value right away. But optimized programming argues about how machine is coded nowadays. Anyway, I don't need that statement anymore as I found the error of my ways and have corrected it. And behold, the light came forth and it worked. :-) Regards Lenin www.twitter.com/nine_L www.lenin9l.wordpress.com Thanks. That is really a nice eye-opener. Phil -- Hervé Kempf: Pour sauver la planète, sortez du capitalisme. - Phil Jourdan --- p...@ptahhotep.com http://www.ptahhotep.com http://www.chiccantine.com/andypantry.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: RES: [PHP] inexplicable behaviour SOLVED
On 26 April 2009 22:59, PJ advised: kranthi wrote: if $Count1 is never referenced after this, then certainly this assignment operation is redundent. but assignment is not the ONLY operation of this statement. if u hav not noticed a post increment operator has been used which will affect the value of $Count as well, and this operation is required for the script to work. the script should work even if u replace $Count1 = $Count++; with $Count++; Kranthi. Not quite, since that would change the $Count variable and that is used leater in the code. Um -- I must be missing something here, because those two statements have exactly the same effect on $Count, incrementing it by one (and you said the first statement fixed your problem, so logically the second one must too). In fact, because you've used a post-increment, the statement $Count1 = $Count++; ends up with $Count == $Count1+1, and $Count1 being the original value of $Count!! This whole scenario smacks to me of a classic off-by-one error -- either $Count actually *needs* to be one greater than the value you first thought of, or some other value you are comparing it to should be one smaller than it actually is. Cheers! Mike -- Mike Ford, Electronic Information Developer, C507, Leeds Metropolitan University, Civic Quarter Campus, Woodhouse Lane, LEEDS, LS1 3HE, United Kingdom Email: m.f...@leedsmet.ac.uk Tel: +44 113 812 4730 To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] inexplicable behaviour
If you want to increment $Count by one, you can use any one of the 3 following lines to do this: $Count = $Count + 1; $Count += 1; $Count++; The 3 lines are equivalent, but have varying degrees of elegance (suit yourself). However, make sure that your mysql function returned a number (and not an error message or whatever else). It's also possible the 'next' redirection isnt working because the value in $Count is invalid somehow? doesnt point to any page or something like that? Simon On Fri, Apr 24, 2009 at 8:14 PM, PJ af.gour...@videotron.ca wrote: Frankly, I don't know what to look for or why something so weird would happen: I have pagination set up and the number for pages next has a link but the next does not. I have experimented with all sorts of configurations of the code but the only thing that works (and this is totally off the wall) is to do this $Count = mysql_num_rows($results); $Count1=$Count++; // without this, the next does not do the link--- but there is no other $Count1 in the code either in the original page or the include page. And this phenomenon was apparent in a similar page. I'd be curious to understand how this could happen. I could post the whole code, but that would be some 300 lines... -- unheralded genius: A clean desk is the sign of a dull mind. - Phil Jourdan --- p...@ptahhotep.com http://www.ptahhotep.com http://www.chiccantine.com/andypantry.php -- 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: RES: [PHP] inexplicable behaviour SOLVED
Ford, Mike wrote: On 26 April 2009 22:59, PJ advised: kranthi wrote: if $Count1 is never referenced after this, then certainly this assignment operation is redundent. but assignment is not the ONLY operation of this statement. if u hav not noticed a post increment operator has been used which will affect the value of $Count as well, and this operation is required for the script to work. the script should work even if u replace $Count1 = $Count++; with $Count++; Kranthi. Not quite, since that would change the $Count variable and that is used leater in the code. Um -- I must be missing something here, because those two statements have exactly the same effect on $Count, incrementing it by one (and you said the first statement fixed your problem, so logically the second one must too). In fact, because you've used a post-increment, the statement $Count1 = $Count++; ends up with $Count == $Count1+1, and $Count1 being the original value of $Count!! This whole scenario smacks to me of a classic off-by-one error -- either $Count actually *needs* to be one greater than the value you first thought of, or some other value you are comparing it to should be one smaller than it actually is. Cheers! Thanks for the clarification, Mike. In my ignorance, I was under the impression that the right side of the equation was only for the use of the left part. How stupid of me. So what I should have been doing was $Count1 = $Count + 1; right? Anyway, I don't need that statement anymore as I found the error of my ways and have corrected it. And behold, the light came forth and it worked. :-) Mike -- Mike Ford, Electronic Information Developer, C507, Leeds Metropolitan University, Civic Quarter Campus, Woodhouse Lane, LEEDS, LS1 3HE, United Kingdom Email: m.f...@leedsmet.ac.uk Tel: +44 113 812 4730 To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm -- Hervé Kempf: Pour sauver la planète, sortez du capitalisme. - Phil Jourdan --- p...@ptahhotep.com http://www.ptahhotep.com http://www.chiccantine.com/andypantry.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: RES: [PHP] inexplicable behaviour SOLVED
Thanks for the clarification, Mike. In my ignorance, I was under the impression that the right side of the equation was only for the use of the left part. How stupid of me. So what I should have been doing was $Count1 = $Count + 1; right? $Count = $Count + 1; is exactly(?) same as $Count++; or ++$Count But not exactly same. PostFix notation adds the value after assigning. PreFix notation adds the value right away. But optimized programming argues about how machine is coded nowadays. Anyway, I don't need that statement anymore as I found the error of my ways and have corrected it. And behold, the light came forth and it worked. :-) Regards Lenin www.twitter.com/nine_L www.lenin9l.wordpress.com
Re: RES: [PHP] inexplicable behaviour
I have pagination set up and the number for pages next has a link but the next does not. I have experimented with all sorts of configurations of the code but the only thing that works (and this is totally off the wall) is to do this *$Count* = *mysql_num_rows($results);* $Count1=*$Count++;* // without this, the next does not do the link--- but there is no other $Count1 in the code either in the original page or the include page. the script should work even if u replace $Count1 = $Count++; with $Count++; There's a NICE video tutorial available on pagination over the internet. You should watch it. You are counting the number of rows of a result. And you are asking to increase the count by 1. :D Thats not realistic. pagination is done with the help of mySQL's * LIMIT recNUMBER, count* * Look for Pagination with PHP + MySQL and watchit http://www.google.com/url?sa=tsource=webct=rescd=10url=http%3A%2F%2Fwww.bestechvideos.com%2F2008%2F07%2F02%2Fsampsonvideos-php-pagination-part-2ei=ohn0SdnlL8KLkAWQrNTbCgusg=AFQjCNEGKOIG3791BpgeVqCiiq5-cikbRA Dont miss this SampsonVideos . PERIOD *Regards Lenin www.twitter.com/nine_L www.lenin9l.wordpress.com
Re: RES: [PHP] inexplicable behaviour
What parameters are you pasing in the link? That will be the telling point of what you are doing wrong. You could pass the search params ( though these are best kept in a session or cookie ) and the offset counter to get the next block of results. Sorry for top posting. Bastien Sent from my iPod On Apr 26, 2009, at 4:23, 9el le...@phpxperts.net wrote: I have pagination set up and the number for pages next has a link but the next does not. I have experimented with all sorts of configurations of the code but the only thing that works (and this is totally off the wall) is to do this *$Count* = *mysql_num_rows($results);* $Count1=*$Count++;* // without this, the next does not do the link--- but there is no other $Count1 in the code either in the original page or the include page. the script should work even if u replace $Count1 = $Count++; with $Count++; There's a NICE video tutorial available on pagination over the internet. You should watch it. You are counting the number of rows of a result. And you are asking to increase the count by 1. :D Thats not realistic. pagination is done with the help of mySQL's * LIMIT recNUMBER, count* * Look for Pagination with PHP + MySQL and watchit http://www.google.com/url?sa=tsource=webct=rescd=10url=http%3A%2F%2Fwww.bestechvideos.com%2F2008%2F07%2F02%2Fsampsonvideos-php-pagination-part-2ei=ohn0SdnlL8KLkAWQrNTbCgusg=AFQjCNEGKOIG3791BpgeVqCiiq5-cikbRA Dont miss this SampsonVideos . PERIOD *Regards Lenin www.twitter.com/nine_L www.lenin9l.wordpress.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: RES: [PHP] inexplicable behaviour
9el wrote: I have pagination set up and the number for pages next has a link but the next does not. I have experimented with all sorts of configurations of the code but the only thing that works (and this is totally off the wall) is to do this *$Count* = *mysql_num_rows($results);* $Count1=*$Count++;* // without this, the next does not do the link--- but there is no other $Count1 in the code either in the original page or the include page. the script should work even if u replace $Count1 = $Count++; with $Count++; There's a NICE video tutorial available on pagination over the internet. You should watch it. You are counting the number of rows of a result. And you are asking to increase the count by 1. :D Thats not realistic. pagination is done with the help of mySQL's * LIMIT recNUMBER, count* * Look for Pagination with PHP + MySQL and watchit http://www.google.com/url?sa=tsource=webct=rescd=10url=http%3A%2F%2Fwww.bestechvideos.com%2F2008%2F07%2F02%2Fsampsonvideos-php-pagination-part-2ei=ohn0SdnlL8KLkAWQrNTbCgusg=AFQjCNEGKOIG3791BpgeVqCiiq5-cikbRA Dont miss this SampsonVideos . PERIOD *Regards Lenin www.twitter.com/nine_L www.lenin9l.wordpress.com Thanks, Lenin, I appreciate the feedback and will take a look at the video. Maybe it will expand my understanding of things and offer an alternative to several that I have already found. :-) -- unheralded genius: A clean desk is the sign of a dull mind. - Phil Jourdan --- p...@ptahhotep.com http://www.ptahhotep.com http://www.chiccantine.com/andypantry.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: RES: [PHP] inexplicable behaviour SOLVED
kranthi wrote: if $Count1 is never referenced after this, then certainly this assignment operation is redundent. but assignment is not the ONLY operation of this statement. if u hav not noticed a post increment operator has been used which will affect the value of $Count as well, and this operation is required for the script to work. the script should work even if u replace $Count1 = $Count++; with $Count++; Kranthi. Not quite, since that would change the $Count variable and that is used leater in the code. But the problem seems to be solved as the paging needed the $Count1 wich was not being supplied because I was debugging the code without enough entries in the database. Once I had a larger base of info I was able to see what the problem was. The code needed to determine how many instances there are in the db of the search criteria and it was not getting that; it was only getting the LIMIT of the query. So I added a few lines to determine the total for $Count1 and it all works fine now. :-) or until I find another glitch. ;-) Thanks for the suggestion. -- unheralded genius: A clean desk is the sign of a dull mind. - Phil Jourdan --- p...@ptahhotep.com http://www.ptahhotep.com http://www.chiccantine.com/andypantry.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: RES: [PHP] inexplicable behaviour
Look for Pagination with PHP + MySQL and watchit http://www.google.com/url?sa=tsource=webct=rescd=10url=http%3A%2F%2Fwww.bestechvideos.com%2F2008%2F07%2F02%2Fsampsonvideos-php-pagination-part-2ei=ohn0SdnlL8KLkAWQrNTbCgusg=AFQjCNEGKOIG3791BpgeVqCiiq5-cikbRA Dont miss this SampsonVideos . PERIOD Well, I went, I looked, I tried... but: I'm afraid this kind of video tutorial or any program of the like is pretty pathertic. Although the intention of the this guy Samson may be commendable, the execution is absolutely atrocious and unprofessional. By profession, I am a director, director of photography and still photography for films, videos, TV stuff, clips as well as still photos for books specialty of food, etc.; you name it. And this is just plain too boring. If he were to cut the padding, it would doubtless be interesting but 21 minutes (for just 1 of 2 clips) I'm not going to waste. During that time I can find lots of other code examples tutorials. Sorry, but this is not for me. If anyone wants any help on shooting stuff, I'll be happy to help but I cannot encourage amateurism. Oh, and while I am at it, I don't much care to Google; their search engine has gone way off course (although it is probably the best available, but I don't wish to have anything to do with any of the rest of their overblown garbage like the analytics, and especially their policies and capitalistic profit drive shown in their actions relating publishing and copyright regarding electronic media. Just love to spread the word. - Oh, yes, if you want to save the planet, start by rethinking capitalism (it hasn't worked too well, has it)... :-D Thanks for the opportunity to rant. -- Hervé Kempf: Pour sauver la planète, sortez du capitalisme - Phil Jourdan --- p...@ptahhotep.com http://www.ptahhotep.com http://www.chiccantine.com/andypantry.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: RES: [PHP] inexplicable behaviour
Phpster wrote: What parameters are you pasing in the link? That will be the telling point of what you are doing wrong. You could pass the search params ( though these are best kept in a session or cookie ) and the offset counter to get the next block of results. Actually, I am trying to use sessions but I'm not sure it's working. I'll have to look throught the manuals and tutorials again to see what's not cookie-ing :-) Any suggestions on how to verify or debug sessions? Sorry for top posting. Bastien Sent from my iPod On Apr 26, 2009, at 4:23, 9el le...@phpxperts.net wrote: I have pagination set up and the number for pages next has a link but the next does not. I have experimented with all sorts of configurations of the code but the only thing that works (and this is totally off the wall) is to do this *$Count* = *mysql_num_rows($results);* $Count1=*$Count++;* // without this, the next does not do the link--- but there is no other $Count1 in the code either in the original page or the include page. the script should work even if u replace $Count1 = $Count++; with $Count++; There's a NICE video tutorial available on pagination over the internet. You should watch it. You are counting the number of rows of a result. And you are asking to increase the count by 1. :D Thats not realistic. pagination is done with the help of mySQL's * LIMIT recNUMBER, count* * Look for Pagination with PHP + MySQL and watchit http://www.google.com/url?sa=tsource=webct=rescd=10url=http%3A%2F%2Fwww.bestechvideos.com%2F2008%2F07%2F02%2Fsampsonvideos-php-pagination-part-2ei=ohn0SdnlL8KLkAWQrNTbCgusg=AFQjCNEGKOIG3791BpgeVqCiiq5-cikbRA Dont miss this SampsonVideos . PERIOD *Regards Lenin www.twitter.com/nine_L www.lenin9l.wordpress.com -- Hervé Kempf: Pour sauver la planète, sortez du capitalisme. - Phil Jourdan --- p...@ptahhotep.com http://www.ptahhotep.com http://www.chiccantine.com/andypantry.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: RES: [PHP] inexplicable behaviour
Oh, the code works ok. Without the $Count1 = $Count++; it does not work. If you are saying it should be $Count+; it does not matter. That's what's weird. I think it would work no matter what I put in it could be $Count1 = $Countmeoutandcrap; and I think it would still work. The similar behaviour was apparent in another code page where I had exactly the same code repeated once and in the second instance the next worked with the href but in the first it did not. I checked checked checkd and finally I just added a 1 to the first code $Count and it worked. But any instances of $Count1 were commented out. I suspect it may have something to do with sessions or with some stack stuff but I really have no idea. Thanks for your interest. Phil Jônatas Zechim wrote: Is the $Count++.. -Mensagem original- De: PJ [mailto:af.gour...@videotron.ca] Enviada em: sexta-feira, 24 de abril de 2009 21:14 Para: php-general@lists.php.net Assunto: [PHP] inexplicable behaviour Frankly, I don't know what to look for or why something so weird would happen: I have pagination set up and the number for pages next has a link but the next does not. I have experimented with all sorts of configurations of the code but the only thing that works (and this is totally off the wall) is to do this $Count = mysql_num_rows($results); $Count1=$Count++; // without this, the next does not do the link--- but there is no other $Count1 in the code either in the original page or the include page. And this phenomenon was apparent in a similar page. I'd be curious to understand how this could happen. I could post the whole code, but that would be some 300 lines... -- unheralded genius: A clean desk is the sign of a dull mind. - Phil Jourdan --- p...@ptahhotep.com http://www.ptahhotep.com http://www.chiccantine.com/andypantry.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: RES: [PHP] inexplicable behaviour
if $Count1 is never referenced after this, then certainly this assignment operation is redundent. but assignment is not the ONLY operation of this statement. if u hav not noticed a post increment operator has been used which will affect the value of $Count as well, and this operation is required for the script to work. the script should work even if u replace $Count1 = $Count++; with $Count++; Kranthi. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] inexplicable behaviour
Frankly, I don't know what to look for or why something so weird would happen: I have pagination set up and the number for pages next has a link but the next does not. I have experimented with all sorts of configurations of the code but the only thing that works (and this is totally off the wall) is to do this $Count = mysql_num_rows($results); $Count1=$Count++; // without this, the next does not do the link--- but there is no other $Count1 in the code either in the original page or the include page. And this phenomenon was apparent in a similar page. I'd be curious to understand how this could happen. I could post the whole code, but that would be some 300 lines... -- unheralded genius: A clean desk is the sign of a dull mind. - Phil Jourdan --- p...@ptahhotep.com http://www.ptahhotep.com http://www.chiccantine.com/andypantry.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RES: [PHP] inexplicable behaviour
Is the $Count++.. -Mensagem original- De: PJ [mailto:af.gour...@videotron.ca] Enviada em: sexta-feira, 24 de abril de 2009 21:14 Para: php-general@lists.php.net Assunto: [PHP] inexplicable behaviour Frankly, I don't know what to look for or why something so weird would happen: I have pagination set up and the number for pages next has a link but the next does not. I have experimented with all sorts of configurations of the code but the only thing that works (and this is totally off the wall) is to do this $Count = mysql_num_rows($results); $Count1=$Count++; // without this, the next does not do the link--- but there is no other $Count1 in the code either in the original page or the include page. And this phenomenon was apparent in a similar page. I'd be curious to understand how this could happen. I could post the whole code, but that would be some 300 lines... -- unheralded genius: A clean desk is the sign of a dull mind. - Phil Jourdan --- p...@ptahhotep.com http://www.ptahhotep.com http://www.chiccantine.com/andypantry.php -- 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