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.

<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>

Line 35 is:

if ($contents==$check) {

Am I executing a command incorrectly, is my connection too slow, or is my code just taking too long to execute?

[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

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??

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?

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??

There was an endless loop, the page that set the cookie did not convert the username to lowercase before encrypting.

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.

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?

Because that's all I knew to do. :sad:

Looking around, do you mean a query like this?

$query="SELECT name, password, md5 FROM users WHERE md5=$check";

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

$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.";
}

Well, I think what Chris was saying was to use the WHERE extension on my query so I don't have to use the while loop.

u can remove the error by modifying the entry in php.ini file in ur webserver settings
set maximum_exec_time=300 // which increase the maximum script time for ur script

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.