| | |
Maximum execution time exceeded.
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jan 2005
Posts: 23
Reputation:
Solved Threads: 0
Two questions here, the first is whether the following error refers to the command exceeding 60 seconds or the whole page taking over 60 seconds to execute.
"Fatal error: Maximum execution time of 60 seconds exceeded in /***/panel.php on line 35"
The code is as follows.
[PHP]
<html>
<head>Text</head>
<body>
<?
$loggedin=0;
$dbusername="*****";
$dbpassword="*****";
$database="*****";
if (isset($_COOKIE['sINFO'])) {
$contents=$_COOKIE['sINFO'];
mysql_connect(localhost,$dbusername,$dbpassword);
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT name, password FROM users";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
$i=0;
$cancelwhile=0;
while ($i<$num && $cancelwhile==0) {
$check=mysql_result($result,$i,"name");
$check.=mysql_result($result,$i,"password");
$check=md5($check);
if ($contents==$check) {
echo ("Welcome back ".mysql_result($result,$i,"name"));
$cancelwhile=1;
$loggedin=1;
}
$i++;
if ($i=$num && $cancelwhile==1) {echo ("You are not logged in.");}
}
}else{
echo ("You are not logged in.");
}
if (loggedin==1) {
echo ("<br>Select an option.");
}
?>
</body>
</html>
[/PHP]
Line 35 is:
[PHP]if ($contents==$check) {[/PHP]
Am I executing a command incorrectly, is my connection too slow, or is my code just taking too long to execute?
"Fatal error: Maximum execution time of 60 seconds exceeded in /***/panel.php on line 35"
The code is as follows.
[PHP]
<html>
<head>Text</head>
<body>
<?
$loggedin=0;
$dbusername="*****";
$dbpassword="*****";
$database="*****";
if (isset($_COOKIE['sINFO'])) {
$contents=$_COOKIE['sINFO'];
mysql_connect(localhost,$dbusername,$dbpassword);
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT name, password FROM users";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
$i=0;
$cancelwhile=0;
while ($i<$num && $cancelwhile==0) {
$check=mysql_result($result,$i,"name");
$check.=mysql_result($result,$i,"password");
$check=md5($check);
if ($contents==$check) {
echo ("Welcome back ".mysql_result($result,$i,"name"));
$cancelwhile=1;
$loggedin=1;
}
$i++;
if ($i=$num && $cancelwhile==1) {echo ("You are not logged in.");}
}
}else{
echo ("You are not logged in.");
}
if (loggedin==1) {
echo ("<br>Select an option.");
}
?>
</body>
</html>
[/PHP]
Line 35 is:
[PHP]if ($contents==$check) {[/PHP]
Am I executing a command incorrectly, is my connection too slow, or is my code just taking too long to execute?
•
•
Join Date: Aug 2005
Posts: 76
Reputation:
Solved Threads: 1
[proviso]I've not properly looked through your code.[/proviso]
It could be the entire script, or it might not be getting a response that it was expecting when, for example, you're trying to access the cookie.
This might help you with debugging: http://uk.php.net/function.set_time_limit
It could be the entire script, or it might not be getting a response that it was expecting when, for example, you're trying to access the cookie.
This might help you with debugging: http://uk.php.net/function.set_time_limit
The error is referred to execute time up to line 35.
It is very likely there is error in your php code (may be an endless loops etc). I suggest you use echo to display values in $contents (after line 15) and in $check (after line 33), before solving line 35.
I'm not quite sure that you close the mysql connection before call the results??
It is very likely there is error in your php code (may be an endless loops etc). I suggest you use echo to display values in $contents (after line 15) and in $check (after line 33), before solving line 35.
I'm not quite sure that you close the mysql connection before call the results??
Ecommerce-Web-Store.com Building Your e-Business.
I don't understand your code at all. Why are you running a loop to check every record in the table for the value in the cookie? Why don't you just execute a query that checks for the existence of the value you are looking for and save yourself a lot of execution time and headaches?
Did we help you? Did we miss the point entirely? Update your thread and let us know.
Don't like the answers you are getting?
Did you try searching?
Clean up and optimize Windows 2000/XP
Don't like the answers you are getting?
Did you try searching?
Clean up and optimize Windows 2000/XP
•
•
Join Date: Jan 2005
Posts: 23
Reputation:
Solved Threads: 0
•
•
•
•
Originally Posted by zippee
The error is referred to execute time up to line 35.
It is very likely there is error in your php code (may be an endless loops etc). I suggest you use echo to display values in $contents (after line 15) and in $check (after line 33), before solving line 35.
I'm not quite sure that you close the mysql connection before call the results??
And it looks like you should close the connection as soon as possible to make it easier on the server so it doesn't have to keep listening for requests. TI think the query places the contents of the rows into $result rather than linking the two.
•
•
•
•
Originally Posted by chrisbliss18
I don't understand your code at all. Why are you running a loop to check every record in the table for the value in the cookie? Why don't you just execute a query that checks for the existence of the value you are looking for and save yourself a lot of execution time and headaches?
Looking around, do you mean a query like this?
[PHP]$query="SELECT name, password, md5 FROM users WHERE md5=$check";[/PHP]
Where I call the cookie into $check earlier and create a new column 'md5' with pre-calculated hashes?
And if I removed the first reference to the md5 column in the above, would it still be able to use the WHERE portion of the query?
Try this (I hope this is what you after [php]$contents=$_COOKIE['sINFO'];
mysql_connect(localhost,$dbusername,$dbpassword);
@mysql_select_db($database) or die( "Unable to select database");
$query = "SELECT name, password FROM users";
$result = mysql_query($query) or die('Query failed: ' . mysql_error());
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
$check = md5($row['name'].$row['password'];
if($check==$contents) {
echo "Welcome back ".$row['name'];
$loggedin = 1;
}
}
if (loggedin==1) {
echo "<br>Select an option.";
}
else {
echo "You are not logged in.";
}[/php]
mysql_connect(localhost,$dbusername,$dbpassword);
@mysql_select_db($database) or die( "Unable to select database");
$query = "SELECT name, password FROM users";
$result = mysql_query($query) or die('Query failed: ' . mysql_error());
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
$check = md5($row['name'].$row['password'];
if($check==$contents) {
echo "Welcome back ".$row['name'];
$loggedin = 1;
}
}
if (loggedin==1) {
echo "<br>Select an option.";
}
else {
echo "You are not logged in.";
}[/php]
Ecommerce-Web-Store.com Building Your e-Business.
![]() |
Similar Threads
Other Threads in the PHP Forum
- Previous Thread: Help with complicated script
- Next Thread: Declaring functions
| Thread Tools | Search this Thread |
apache api array beginner binary body broken buttons cakephp checkbox class cms code cron curl database date date/time display dynamic ebooks echo email error file files folder form forms function functions google href htaccess html image include insert ip javascript joomla limit link list login mail mediawiki menu mlm msqli_multi_query multiple mycodeisbad mysql number oop parameter paypal pdf php phpincludeissue phpmyadmin problem query radio random recourse recursion regex remote script search seo server sessions sms source sp space speed sql static subdomain syntax system table tag tutorial update upload url validator variable vbulletin video web webdesign white wordpress xml youtube





