473,499 Members | 1,533 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Fatal error

I want to list all the countries (147 in total) per continent with the
quantity of beercoasters that each country has. I get the following
message:

Fatal error: Maximum execution time of 30 seconds exceeded in
C:\wampp2\htdocs\main1.php on line 88

Here is the code...perhaps the loop is too big?

......
$contador = count($countries); //quantity of countries
for ($j=0; $j<$contador; $j++) {
$auxi= $countries[$j][0]; // I process each country
$count_coasters = mysql_query("SELECT COUNTRY_CODE FROM COASTERS");
$count =0;
while ($row = mysql_fetch_array($count_coasters, MYSQL_ASSOC)) {
$coasters[$count][0]=$row[0];
$count=$count+1;
}
$contador1 = count($coasters);
$acum=0;
for ($k=0; $k<$contador1; $k++) {
if(($coasters[$k][0])==$auxi) {
$acum=$acum+1;}
}
}

On the other side, if I write something like:
mysql_query("SELECT COUNTRY_CODE FROM COASTERS WHERE COUNTRY_CODE =
$auxi")
in order to get only the coasters from a country and avoid the seconf
loop (with acum) I receive the following message:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL
result resource in ....

How can I count these records?

Jul 17 '05 #1
6 1538
On 2005-07-03, be*****@coaster.ch <be*****@coaster.ch> wrote:


I want to list all the countries (147 in total) per continent with the
quantity of beercoasters that each country has. I get the following
message:

Fatal error: Maximum execution time of 30 seconds exceeded in
C:\wampp2\htdocs\main1.php on line 88

Here is the code...perhaps the loop is too big?
[snip code]

I won't debug/optimize your code for you, but I will tell you
there is configuration option within PHP to increase the maximum
execution time (look at php.ini).

If more than a 30 second execution time is unacceptable for your
needs, then you'll need to revisit your code.
On the other side, if I write something like:
mysql_query("SELECT COUNTRY_CODE FROM COASTERS WHERE COUNTRY_CODE =
$auxi")
in order to get only the coasters from a country and avoid the seconf
loop (with acum) I receive the following message:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL
result resource in ....

How can I count these records?


'Not a valid MySQL result resource' = probably a problem
with your query (which you would know if were checking for
errors after communication with your database).

I know no more about your database than the information you've
provided, and I'm not a mind-reader, so this is a stab in the
dark: but what data type is 'COUNTRY_CODE'? Perhaps its data
type requires it to be enclosed in quotes?

(i.e., SELECT COUNTRY_CODE
FROM COASTERS
WHERE COUNTRY_CODE = '$auxi')

I'm probably way off, but it's hard not to be with so little
information.

BTW, you may want to look into the use of "mysql_errno" and
"mysql_error" -- they may be helpful in debugging problems
like this.

HTH,
Justin
Jul 17 '05 #2
Just a quick suggestion, and bear in mind I am a novice at all this,
but maybe the "GROUP BY" function of MySQL could optimise this for you?
(Using either a SUM() or COUNT() function to calculate the Number you
need).

As I said, just a novice and I could be (and probably am) wrong...

Jul 17 '05 #3


be*****@coaster.ch wrote (in part):
I want to list all the countries (147 in total) per continent with the
quantity of beercoasters that each country has. I get the following
message:

Fatal error: Maximum execution time of 30 seconds exceeded in
C:\wampp2\htdocs\main1.php on line 88

Here is the code...perhaps the loop is too big?
There are many ways to make this code tighter. Look in
http://www.php.net/array
for hints on the functions you should be using to do your dirty work.

I will just ask a few questions to get you thinking. From the looks of
your code, it's fairly obvious that you didn't come from a C
programming background.
.....
$contador = count($countries); //quantity of countries
for ($j=0; $j<$contador; $j++) {
$auxi= $countries[$j][0]; // I process each country
How is the array $countries defined? You probably shouldn't be using a
second index "[0]".
$count_coasters = mysql_query("SELECT COUNTRY_CODE FROM COASTERS");
$count =0;
while ($row = mysql_fetch_array($count_coasters, MYSQL_ASSOC)) {
$coasters[$count][0]=$row[0];
$count=$count+1;
}
If you just want to get the number of rows that were retreived in a
previous query, there is a mysql funtions for that.

In your code you're retrieving the data as an associative array, but
you're not using it.
$contador1 = count($coasters);
$acum=0;
for ($k=0; $k<$contador1; $k++) {
if(($coasters[$k][0])==$auxi) {
$acum=$acum+1;}
}
}
There are ways to let PHP count the number of values in an array.

On the other side, if I write something like:
mysql_query("SELECT COUNTRY_CODE FROM COASTERS WHERE COUNTRY_CODE =
$auxi")
in order to get only the coasters from a country and avoid the seconf
loop (with acum) I receive the following message:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL
result resource in ....

How can I count these records?


Ken

Jul 17 '05 #4
On Sun, 03 Jul 2005 01:30:17 -0700, bettina wrote:
Fatal error: Maximum execution time of 30 seconds exceeded in
C:\wampp2\htdocs\main1.php on line 88

Here is the code...perhaps the loop is too big?


There is a php.ini option called max_execution_time. If set to 0,
the timer is turned off. It can help if you are certain that your
time is spent in the database rather then in the script. Your program
looks much too complicated for comfort and I wouldn't be fiddling
with php.ini just yet.

--
You can get more of what you want with a kind word and a gun than
you can with just a kind word. (Al Kapone)

Jul 17 '05 #5
Thank you for your tip! You were right, '$auxi' should go between ''

Jul 17 '05 #6
I'm also a novice... I've used COUNT() and it works!

Jul 17 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2431
by: PeterF | last post by:
Hello, what is wrong here? the purpose is to create an array of objects and then interate over it, calling some method from all of them. I get just the following at the marked line ("// FATAL...
8
9977
by: Tim Tyler | last post by:
I'm getting fatal errors when executing code - and my error handler is failing to trap them - so I get no stack backtrace :-( The error I am getting is: "Fatal error: Call to a member function...
2
2936
by: Itjalve | last post by:
This gives me a fatal error. I'm using .NET VC7.1 and made a win32 consol app, I have no problems with VC6. Debug build. I have removed nearly all my code this is whats left. From the beginning...
6
5156
by: Steve Crawford | last post by:
I've started seeing the following in my logs: FATAL: invalid frontend message type 8 I searched back over a month and there are 5 instances of this error of which 4 are in the last 24 hours. ...
4
5634
by: ARF | last post by:
I'm testing AutoCAD 2005 automation via VS2005 Pro C++/CLR and I'm getting fatal compiler errors. I start with a default C++/CLR class library project and modify it by adding the following...
0
2101
by: Rich | last post by:
I am trying to obtain more debugging information for an issue I reported (ref. Bug #37185 <http://bugs.php.net/bug.php?id=37185&edit=2>). Unfortunately, I do not have access to the now-ancient...
1
13933
by: R | last post by:
Hi All, I'm using PHP 5, my code fully separates code from content, my code throws exceptions (LIZException) when error occurs. but every time I throw exception I get this fatal error: ...
3
4183
by: Dhieraj | last post by:
While compiling a C++ code I am getting the following error : CC -c -I/opt/iona/artix/2.0/include -I/opt/iona/asp/6.0/include -I/opt/ar/api63/include -I//var/tmp/vidya/aotscommon/include ...
1
3741
by: kvarada | last post by:
Hello Experts, I am building my application on WinNT.4.0_i386_MSVC.7.1 platform. When I build the application on a stand alone machine, it builds fine. But when I build the same application from a...
2
3006
by: lwo3108 | last post by:
Hi I am using PHP 4.3.1 and i have written a little code for purpose of CAPTCHA Image. i am running this code locally on localhost using IIS 5.0. When i open the code page, i get an fatal...
0
7130
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7007
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7220
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6893
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
4918
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3098
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3090
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1427
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
664
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.