Re: Re: temporary error
| From: | Nathan Rixham | Date: | Thu, 21 Feb 2008 17:43:09 +0000 |
| Subject: | Re: Re: temporary error | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-269803@lists.php.net to get a copy of this message | ||
Andrés Robinet wrote:
I often find the best way to clarify whats going on in a specific section of code is to document it properly. I'd strongly suggest you do the same Mirco, it'll save you hours in the future. <?php /** * Project Spaghetti Super Cala Fraga Listic * Ex Peal Ado Tio Us Incremental Counter * * Incrementation of Super Cala based Integer variables * Definitions and Library * * Thu Feb 21 17:19:44 GMT 2008 * * @copyright 2008, Project Spaghetti Solutions Ltd, UK * @package Project_Spaghetti * @subpackage Super * @subsubpackage Cala * @subsubsubpackage Fraga * @subsubsubsubpackage Listic * @subsubsubsubsubsubpackage Ex * @subsubsubsubsubsubsubpackage Peal * @subsubsubsubsubsubsubsubpackage Ado * @subsubsubsubsubsubsubsubsubpackage Tio * @subsubsubsubsubsubsubsubsubsubsubpackage Us * @subsubsubsubsubsubsubsubsubsubsubsubpackage Counter * @subsubsubsubsubsubsubsubsubsubsubsubsubpackage Increment * @author "Mirco Soderi" <m.soderi@alice.it> * @version 1.0.0.0.1.0.2.3.0.4.56.0.2b.9 * @revision 98.3.0.0.2.0.b */ /** * Definition of the numerical integer value used * within all single integer incrementation functions needing * an incremental value of one(1); within the Super Cala Fraga Listic * Ex Peal Ado Tio Us subpackage counter incrementation of * Project Spaghetti 1.0.0.0.1.0.2.3.0.4.56.0.2b.9 * rev 98.3.0.0.2.0.b */ define('Increment_Super_Cala_Fraga_Listic_Ex_Peal_Ado_Tio_Us_Counter_For_Project _Spaghetti', 1); /** * Compacted incrementation function of the numerical integer value used * within all the Super Cala Fraga Listic Ex Peal Ado Tio Us subpackage * counter incrementation; this is the function that increments our * value held in the Counter variable by surely to god your not still * reading this the number defined in the incrementation value * definition for counter value project spaghetti. * Project Spaghetti 1.0.0.0.1.0.2.3.0.4.56.0.2b.9 * rev 23.0.3.0.7.1.a */ $Super_Cala_Fraga_Listic_Ex_Peal_Ado_Tio_Us_Counter_For_Project_Spaghetti = $Super_Cala_Fraga_Listic_Ex_Peal_Ado_Tio_Us_Counter_For_Project_Spaghetti + Increment_Super_Cala_Fraga_Listic_Ex_Peal_Ado_Tio_Us_Counter_For_Project_Spaghetti; ?> sure beats $i++-----Original Message----- From: Shawn McKenzie [mailto:nospam@mckenzies.net] Sent: Thursday, February 21, 2008 10:36 AM To: php-general@lists.php.net Subject: [PHP] Re: temporary error Mirco Soderi wrote:You forgot to add the project name you are working on to the counter, this way you'll never confuse yourself at all. define('Increment_Super_Cala_Fraga_Listic_Ex_Peal_Ado_Tio_Us_Counter_For_Project _Spaghetti', 1); $Super_Cala_Fraga_Listic_Ex_Peal_Ado_Tio_Us_Counter_For_Project_Spaghetti = $Super_Cala_Fraga_Listic_Ex_Peal_Ado_Tio_Us_Counter_For_Project_Spaghetti + Increment_Super_Cala_Fraga_Listic_Ex_Peal_Ado_Tio_Us_Counter_For_Project_Spaghet ti; LOLIn my opinion, variable names are a personal choice, I think the time you loose when writing the name (about a second is long less than the time you gain when, months later, you go and modify the code and you have clear the content and meaning of each variable. In the original code there were no sintax errors, I added some errors when pasting here. Sorry. I have found that in the first execution, it was the $logQueryInserimentoDatiAllenamentoCalciPiazzati that evaluated to false. After having removed the two-field key that I had originally defined for that table and having added an autoincrement key, the problem seems to be solved. Do you find any reason for that? ""Mirco Soderi"" <m.soderi@alice.it> ha scritto nel messaggio news:39.96.21621.F728DB74@pb1.pair.com...Glad to see that you found your problem. Variables may be easier to read with some underscores. Personally, here is what I use as a counter in most all of my code, instead of $i++; which isn't always clear. $Super_Cala_Fraga_Listic_Ex_Peal_Ado_Tio_Us_Counter = $Super_Cala_Fraga_Listic_Ex_Peal_Ado_Tio_Us_Counter + ($Super_Cala_Fraga_Listic_Ex_Peal_Ado_Tio_Us_Counter / $Super_Cala_Fraga_Listic_Ex_Peal_Ado_Tio_Us_Counter); If you wan to shorten a bit you can use a constant as the counter increment like so: define('Increment_Super_Cala_Fraga_Listic_Ex_Peal_Ado_Tio_Us_Counter', 1); $Super_Cala_Fraga_Listic_Ex_Peal_Ado_Tio_Us_Counter = $Super_Cala_Fraga_Listic_Ex_Peal_Ado_Tio_Us_Counter + Increment_Super_Cala_Fraga_Listic_Ex_Peal_Ado_Tio_Us_Counter; -ShawnConsider the following code: $sqlQueryInserimentoDatiAllenamentoCalciPiazzati = "INSERT INTO ... etc etc ...." $queryInserimentoDatiAllenamentoCalciPiazzati = mysql_query($sqlQueryInserimentoDatiAllenamentoCalciPiazzati); if($queryInserimentoDatiAllenamentoCalciPiazzati) { // do something } if($queryInserimentoDatiAllenamentoCalciPiazzati) { $logQueryInserimentoDatiAllenamentoCalciPiazzati = mysql_query("insert into log ... etc etc ..."); if($logQueryInserimentoDatiAllenamentoCalciPiazzati) { // do something } } if($queryInserimentoDatiAllenamentoCalciPiazzati && $logQueryInserimentoDatiAllenamentoCalciPiazzati) { // do something } 1st execution: $queryInserimentoDatiAllenamentoCalciPiazzati && $logQueryInserimentoDatiAllenamentoCalciPiazzati, where clause of last conditional statement, evaluates to false even if both queries are correctly executed. I modify as follows: $sqlQueryInserimentoDatiAllenamentoCalciPiazzati = "INSERT INTO ... etc etc ...." $queryInserimentoDatiAllenamentoCalciPiazzati = mysql_query($sqlQueryInserimentoDatiAllenamentoCalciPiazzati); if($queryInserimentoDatiAllenamentoCalciPiazzati) { // do something } else echo("error message 1"); if($queryInserimentoDatiAllenamentoCalciPiazzati) { $logQueryInserimentoDatiAllenamentoCalciPiazzati = mysql_query("insert into log ... etc etc ..."); if($logQueryInserimentoDatiAllenamentoCalciPiazzati) { // do something } else echo("error message 2"); } if($queryInserimentoDatiAllenamentoCalciPiazzati && $logQueryInserimentoDatiAllenamentoCalciPiazzati) { // do something } 2nd execution: $queryInserimentoDatiAllenamentoCalciPiazzati && $logQueryInserimentoDatiAllenamentoCalciPiazzati, where clause of last conditional statement, evaluates to true. Now, I modify again, back to the original version: $sqlQueryInserimentoDatiAllenamentoCalciPiazzati = "INSERT INTO ... etc etc ...." $queryInserimentoDatiAllenamentoCalciPiazzati = mysql_query($sqlQueryInserimentoDatiAllenamentoCalciPiazzati); if($queryInserimentoDatiAllenamentoCalciPiazzati) { // do something } if($queryInserimentoDatiAllenamentoCalciPiazzati) { $logQueryInserimentoDatiAllenamentoCalciPiazzati = mysql_query("insert into log ... etc etc ..."); if($logQueryInserimentoDatiAllenamentoCalciPiazzati) { // do something } } if($queryInserimentoDatiAllenamentoCalciPiazzati && $logQueryInserimentoDatiAllenamentoCalciPiazzati) { // do something } 3rd execution: $queryInserimentoDatiAllenamentoCalciPiazzati && $logQueryInserimentoDatiAllenamentoCalciPiazzati, where clause of last conditional statement, evaluates to true. Do you know any reason for that?