Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Fatal error: Maximum execution time of 30 seconds exceeded in
Old 03-11-2010, 08:26 AM Fatal error: Maximum execution time of 30 seconds exceeded in
Isabella_Smith's Avatar
Ultra Talker

Posts: 285
Trades: 0
Please check my code below:
I need your help...........please let me know wt's mistake.
PHP Code:
$biz_val$row_c['business_id'];
                        
$sql_rat="select * from tblrating where biz_id = ".$row_c['business_id']."";
                        
$result_rat mysql_query($sql_rat);
                        
$tot_rec mysql_fetch_array($result_rat);
                        
$i=0;
                        
$j=0;
                        
$d=0;
                    if(
$tot_rec>0)
                        {
                        while (
$row_rt $tot_rec)
                        {
                            
$i++;
                            
$j$row_rt['rat_num'] + j;    
                        }
                        
$d=$j/$i;  \\\\\Problem is here.....
if (
$d<=1.50)
{
echo 
"<img src=\"rat1.gif\">"
}
if (
$d<=2.50 && $d>=1.51)
{
echo 
"<img src=\"rat2.gif\">"


I've tried to put $d=$j/$i; inside the while loop.

but not working....showing this error.

Fatal error: Maximum execution time of 30 seconds exceeded in

Your help would be highly appreciated.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE



Please login or register to view this content. Registration is FREE
buy all indian salwar Kameez, Sarees and clothes
Isabella_Smith is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 03-11-2010, 09:41 AM Re: Fatal error: Maximum execution time of 30 seconds exceeded in
Knight13's Avatar
Defies a Status

Posts: 10,289
Name: Knight13
Location: Cleveland, Ohio
Trades: 0
$j= $row_rt['rat_num'] + j;

Maybe this

$j = $row_rt['rat_num'] + $j; <-- dollar sign in front of the ending j?
Knight13 is offline
Reply With Quote
View Public Profile
 
Old 03-11-2010, 02:32 PM Re: Fatal error: Maximum execution time of 30 seconds exceeded in
SnapCount80's Avatar
Experienced Talker

Posts: 48
Name: Andrew
Location: Fort Wayne, IN
Trades: 0
Quote:
Originally Posted by Isabella_Smith View Post
Please check my code below:
I need your help...........please let me know wt's mistake.
PHP Code:
$biz_val$row_c['business_id'];
                        
$sql_rat="select * from tblrating where biz_id = ".$row_c['business_id']."";
                        
$result_rat mysql_query($sql_rat);
                        
$tot_rec mysql_fetch_array($result_rat);
                        
$i=0;
                        
$j=0;
                        
$d=0;
                    if(
$tot_rec>0)
                        {
                        while (
$row_rt $tot_rec)
                        {
                            
$i++;
                            
$j$row_rt['rat_num'] + j;    
                        }
                        
$d=$j/$i;  \\\\\Problem is here.....
if (
$d<=1.50)
{
echo 
"<img src=\"rat1.gif\">"
}
if (
$d<=2.50 && $d>=1.51)
{
echo 
"<img src=\"rat2.gif\">"

I've tried to put $d=$j/$i; inside the while loop.

but not working....showing this error.

Fatal error: Maximum execution time of 30 seconds exceeded in

Your help would be highly appreciated.
Actually, if the script is timing out, I'm pretty sure the problem is in the while statement.

I think it might be that $row_rt is being read as a variable and I don't see it assigned any value. If $row_rt and $tot_rec never change, then they will always be equal and the script will loop indefinitely... or until it times out(which is the error you are getting).

Understand?
__________________

Please login or register to view this content. Registration is FREE

SnapCount80 is offline
Reply With Quote
View Public Profile Visit SnapCount80's homepage!
 
Old 03-11-2010, 04:29 PM Re: Fatal error: Maximum execution time of 30 seconds exceeded in
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
Good view snapCount!

The problem is this line
PHP Code:
while ($row_rt $tot_rec
As this will always be true (you can always assign $tot_rec to $row_rt), it will not get out of the while , and timeout here.

Would this rather be what you wanted to do?
PHP Code:
<?php
$biz_val
$row_c['business_id'];
$sql_rat="select * from tblrating where biz_id = $biz_val";
$result_rat mysql_query($sql_rat);
$tot_rec mysql_fetch_array($result_rat);
$i=$j=$d=0;
if(
$tot_rec>0){
    
$row_rt $tot_rec;
    while (
$i<10){    //you set the condition here
        
$i++;
        
$j$row_rt['rat_num'] + j;    
    }
    
$d=$j/$i;  Problem is here.....
    if (
$d<=1.50){
        echo 
"<img src=\"rat1.gif\">"
    
}
    if (
$d<=2.50 && $d>=1.51){
        echo 
"<img src=\"rat2.gif\">"
    
}
}
This is probably a confusion upon loops.
You have 3 types of loop (that I think of) at disposal.
For, while and "do while" loops.

The for loop is well known, and the most current.
You define the counter, the max value and the steps to reach the max value in it's declaration:
PHP Code:
for($cpt=0;$cpt<10;$cpt++){
  
//...

whih means: loop with $cpt from 0 to 9.
Once the condition "$cpt<10" is false, the loop is exited.
In a for loop, the body is executed before the check of the condition.

The while loop is different in the sense that the condition is checked before the logic:
PHP Code:
$cpt=0;
while(
$cpt<10){
  
//..do stuff
  
$cpt++;

And the 3rd loop is a mix of both, "do while":
PHP Code:
$cpt=0;
do{
  
//..stuff here...
  
$cpt++;
}(while 
$cpt<10); 
Here too, the condition is checked after the body have been executed.

The 3 loops here are doing the same, thing.
It's up to you to choose which one should be used in which case.

http://www.php.net/manual/en/control...ures.while.php
http://www.php.net/manual/en/control...s.do.while.php
http://www.php.net/manual/en/control-structures.for.php
__________________
Only a biker knows why a dog sticks his head out the window.

Last edited by tripy; 03-12-2010 at 02:40 AM..
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 03-12-2010, 02:22 AM Re: Fatal error: Maximum execution time of 30 seconds exceeded in
Isabella_Smith's Avatar
Ultra Talker

Posts: 285
Trades: 0
Quote:
Originally Posted by tripy View Post
Good view snapSpot!

The problem is this line
PHP Code:
while ($row_rt $tot_rec
As this will always be true (you can always assign $tot_rec to $row_rt), it will not get out of the while , and timeout here.

Would this rather be what you wanted to do?
PHP Code:
<?php
$biz_val
$row_c['business_id'];
$sql_rat="select * from tblrating where biz_id = $biz_val";
$result_rat mysql_query($sql_rat);
$tot_rec mysql_fetch_array($result_rat);
$i=$j=$d=0;
if(
$tot_rec>0){
    
$row_rt $tot_rec;
    while (
$i<10){    //you set the condition here
        
$i++;
        
$j$row_rt['rat_num'] + j;    
    }
    
$d=$j/$i;  Problem is here.....
    if (
$d<=1.50){
        echo 
"<img src=\"rat1.gif\">"
    
}
    if (
$d<=2.50 && $d>=1.51){
        echo 
"<img src=\"rat2.gif\">"
    
}
}
This is probably a confusion upon loops.
You have 3 types of loop (that I think of) at disposal.
For, while and "do while" loops.

The for loop is well known, and the most current.
You define the counter, the max value and the steps to reach the max value in it's declaration:
PHP Code:
for($cpt=0;$cpt<10;$cpt++){
  
//...

whih means: loop with $cpt from 0 to 9.
Once the condition "$cpt<10" is false, the loop is exited.
In a for loop, the body is executed before the check of the condition.

The while loop is different in the sense that the condition is checked before the logic:
PHP Code:
$cpt=0;
while(
$cpt<10){
  
//..do stuff
  
$cpt++;

And the 3rd loop is a mix of both, "do while":
PHP Code:
$cpt=0;
do{
  
//..stuff here...
  
$cpt++;
}(while 
$cpt<10); 
Here too, the condition is checked after the body have been executed.

The 3 loops here are doing the same, thing.
It's up to you to choose which one should be used in which case.

http://www.php.net/manual/en/control...ures.while.php
http://www.php.net/manual/en/control...s.do.while.php
http://www.php.net/manual/en/control-structures.for.php

Hi, Thanks all of you as all repliese are really helpful to me........

I tried it and its become like a infinite loop.

Actually, its review section for my website...............Please help Its getting infinite when I try the suggestions offered by tripy......

PHP Code:
$biz_val$row_c['business_id'];
                        
$sql_rat="select * from tblrating where rat_biz_id = ".$row_c['business_id']."";
                        
$result_rat mysql_query($sql_rat);
                        
$tot_rec mysql_fetch_array($result_rat);
                        
$i=$j=$d=0;
                    if(
$tot_rec>0)
                    {        
$row_rt $tot_rec;
                        while (
$i==$row_rt)
                        {
                            
$i++;
                            
$j$row_rt['rat_num'] + $j;
                        }    
                        
$d=$j/$i;
                        if (
$d<=1.50


Please help....
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE



Please login or register to view this content. Registration is FREE
buy all indian salwar Kameez, Sarees and clothes

Last edited by Isabella_Smith; 03-12-2010 at 04:44 AM..
Isabella_Smith is offline
Reply With Quote
View Public Profile
 
Old 03-12-2010, 08:40 AM Re: Fatal error: Maximum execution time of 30 seconds exceeded in
Experienced Talker

Posts: 41
Name: Adam B
Trades: 0
I can't say I full understand what you're trying to do.. Seems like you just want to loop through each of the results, why not just use the conventional method?

Code:
while ($row = mysql_fetch_array($result_rat))
{
    // do some stuff here
}
adam89 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Fatal error: Maximum execution time of 30 seconds exceeded in
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.79261 seconds with 12 queries