Jump to content

[SOLVED] server timeout when printing query results


mathus

Recommended Posts

by the level to which this issue is irritating me, it must be something simple.

 

All im trying to do is a simple SELECT query. nothing strange about it.

 

$sql = "SELECT wdate, wtype, wreason, wmemo FROM empwarn WHERE l_name = '$name'";
$res = mysqli_query($mysqli, $sql);
	 if($res == true) {
		$list = mysqli_fetch_array($res);
		while($list) {
		printf("<td>".$list['wdate']."</td> <td>".$list['wtype']."</td> <td>".$list['wreason']."</td> <td>".$list['wmemo']."</td> </tr>");

		}


	}

 

thats it. but when i run the query i get this:

The connection was reset

The connection to the server was reset while the page was loading.

 

anybody have an idea where to look??

Link to comment
Share on other sites

This...

 

while($list) {
  printf("<td>".$list['wdate']."</td> <td>".$list['wtype']."</td> <td>".$list['wreason']."</td> <td>".$list['wmemo']."</td> </tr>");
}

 

Is an infinant loop because $list will always be true. You need to use....

 

while($list = mysqli_fetch_array($res)) {
  printf("<td>".$list['wdate']."</td> <td>".$list['wtype']."</td> <td>".$list['wreason']."</td> <td>".$list['wmemo']."</td> </tr>");
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.