Re: temporary error

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Mirco Soderi wrote:
> In 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@xxxxxxxx> ha scritto nel messaggio 
> news:39.96.21621.F728DB74@xxxxxxxxxxxxxxx
>> Consider 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?

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;

-Shawn

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux