Re: how to handle exception in php

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

 



On 2 May 2010 06:26, Bavithra R <bavithra.r@xxxxxxxxx> wrote:
> hi friends
>
> I am doing a simple student mark details project.
> for calculating rank I need to compare the total marks one by one.
> To do so i use *for loop.* so atlast while reaching the end of the table it
> shows the following warning.
> *
> Warning*: mysql_result()
> [function.mysql-result<http://127.0.0.1/pro/function.mysql-result>]:
> Unable to jump to row 18 on MySQL result index on line *50*
>
> It is because it has no next value to compare.How to use try..catch
> exception handling in this.?Or any other suggestion.
> Can anybody help me
>
> --Bavithra
>

Commonly the while loop looks like ...

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

If you intend to use this for other loops, watch out where the result
of the function is False to indicate the end of the iterations.

while (False !== ($row = mysql_fetch_assoc($result))) {

Whilst this offers nothing extra here, for functions where 0 or "" are
valid responses and False is the "get me out of here" response,
testing for type and value (!==) is important.

-- 
-----
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux