Jump to content

Quick Debug


Wolphie

Recommended Posts

I can't see what the problem is but theres a continuious loop when i try to valdiate the data.

 

 

<?php 
require('includes/config.php');

$sql = mysql_query("SELECT * FROM `site_options`");

while($row = mysql_fetch_array($sql)) 
{

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>


<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="description" content="<?php echo $row['description']; ?>" />
<meta name="keywords" content="<?php echo $row['keywords']; ?>" />

<link rel="stylesheet" href="styles/style.css" type="text/css" />
<script type="text/javascript" src="js/jquery.js"></script>

<title><? echo $row['title']; } ?> - Register</title>


</head>
<body>


<?

require('includes/config.php');
require('includes/header.php');

?>

<td width="200">
<table cellpadding="0" cellspacing="0" border="0" width="200">

	<?
		require("includes/config.php");

		$sql = mysql_query("SELECT * FROM `left` ORDER BY `id` ASC");

		while($row = mysql_fetch_array($sql)) 
		{
			echo $row['head'];
			echo $row['title'];
			echo '</td></tr>';
			echo $row['body'];
			echo $row['content'];
			echo '</td></tr>';
		}	

	?>

</table>
</td>

<?

$var = $_GET['do'];

switch($var) 
{
default:

	?>

	<td width="700">
		<table width="720" cellpadding="0" cellspacing="0" border="0" align="center">

			<tr>
				<td width="500" class="cmodhead">
					Register
				</td>
			</tr>
			<tr>
				<td width="500" class="cmodbody">
					<table width="500" cellpadding="0" cellspacing="0" border="0" class="create">
						<form action="?do=register" method="post">
						<tr><td>
							Username:
						</td></tr>
						<tr><td>
							<input type="text" size="25" maxlength="100" name="username" style="font-family: Tahoma; font-size: 11px;"  value="Username" onClick="this.value='';"
							 />
						</td></tr>
						<tr><td><br />
							Password:
						</td></tr>
						<tr><td>
							<input type="password" maxlength="100" size="25" name="password" style="font-family: Tahoma; font-size: 11px;"  value="password" onClick=
							"this.value='';" />
						</td></tr>
						<tr><td><br />
							Email Address:
						</td></tr>
						<tr><td>
							<input type="text" size="25" maxlength="100" name="email" style="font-family: Tahoma; font-size: 11px;" value="Yourname@email.com" onClick="this.value='';" />
						</td></tr>
						<tr><td>
							<input type="submit" value="Register" style="font-family: Tahoma; font-size: 11px;" />
						</td></tr>
						</form>
					</table>
				</td>
			</tr>

		</table>

	<?

break;


case "register":
	@include("register.php");

	?>

	<td width="700">
		<table width="720" cellpadding="0" cellspacing="0" border="0" align="center">

			<tr>
				<td width="500" class="cmodhead">
					Register
				</td>
			</tr>
			<tr>
				<td width="500" class="cmodbody">
					<table width="500" cellpadding="0" cellspacing="0" border="0" class="create">
					<tr><td align="center">

						<?

							$flag = false;
							foreach($_POST as $field)
							{
								if($field == "")
								{
									$flag = false;
								}
								else
								{
									$flag = true;
								}
							}

							if($flag == false)
							{
								die('Please fill in all of the fields.');
							}
							else
							{
								Header("Location: login.php");
							}

						?>

					</td>
				</tr>
			</table>
		</td>
	</tr>
</table>

	<?

		$username = $_POST['username'];
		$password = MD5($_POST['password']);
		$email = $_POST['email'];

		$sql = mysql_query(sprintf("INSERT INTO `user` ( username, password, email ) VALUES ( '%s', '%s', '%s' )",
		mysql_real_escape_string($username),
		mysql_real_escape_string($password),
		mysql_real_escape_string($email)
		)) or die('Error: ' . mysql_error());

break;

}

require('includes/footer.php');
mysql_close($con);
?>	

</body>
</html>

Link to comment
Share on other sites

What do you mean by a continuous loop? The only loops i can see are the two while loops which deal with the mysql data. Unless there was unlimited data in your database, that couldn't be an infinite loop.

 

What actually happens when you run the script? What is it supposed to do? More information is really needed.

Link to comment
Share on other sites

Having looked at your code a bit more, i have to say im completely and utterly lost. Why do you echo the html declaration and <head> tags inside a loop? Are you actually sure that the code you posted is the code that is being run? The reason i ask is that the loop in the code you posted terminates in this line:

 

<title><? echo $row['title']; } ?> - Register</title>

 

Yet, from a look at the source code, the loop appears to go on further, since the </head> and <body> tags form part of this repeated loop.

 

Also, why do you include config.php 3 times?

Link to comment
Share on other sites

Yeah sorry, i need to clean it up a bit.

The reason why the head is included in a loop is because i need to retrieve the head tags from a database. The loop is also terminated in <?php echo $row['title]; } ?>

E.g.

 

Someone edits the websites information(Title, keywords etc..)

And they'll be displayed on each page.

As for the code that is being run, that is the code for the whole page.

Link to comment
Share on other sites

I think your problem is the line '@include("register.php");' (after 'case "register":'). Basically the file is including itself all the time, which creates the infinite "loop".

 

Perhaps you should try removing that? (although, I don't really have any idea how your website is supposed to work)

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.