954,597 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Maximum execution time exceeded.

<?

$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 ("
Select an option.");

}


?>

Khishin
Newbie Poster
23 posts since Jan 2005
Reputation Points: 10
Solved Threads: 0
 

[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

leelee
Junior Poster in Training
77 posts since Aug 2005
Reputation Points: 31
Solved Threads: 1
 

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

zippee
Posting Whiz in Training
294 posts since Jan 2005
Reputation Points: 10
Solved Threads: 7
 

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?

chrisbliss18
Posting Shark
917 posts since Aug 2005
Reputation Points: 38
Solved Threads: 25
 

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

Khishin
Newbie Poster
23 posts since Jan 2005
Reputation Points: 10
Solved Threads: 0
 

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 "
Select an option.";
}
else {
echo "You are not logged in.";
}[/php]

zippee
Posting Whiz in Training
294 posts since Jan 2005
Reputation Points: 10
Solved Threads: 7
 

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.

Khishin
Newbie Poster
23 posts since Jan 2005
Reputation Points: 10
Solved Threads: 0
 

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

pc2forum
Newbie Poster
11 posts since Dec 2005
Reputation Points: 10
Solved Threads: 0
 

Post: Markdown Syntax: Formatting Help
You