Re: how to handle exception in php
| From: | Richard Quadling | Date: | Tue, 04 May 2010 15:18:39 +0000 |
| Subject: | Re: how to handle exception in php | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-47134@lists.php.net to get a copy of this message | ||
On 2 May 2010 06:26, Bavithra R <bavithra.r@gmail.com> 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