Wolphie Posted October 7, 2007 Share Posted October 7, 2007 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> Quote Link to comment https://forums.phpfreaks.com/topic/72219-quick-debug/ Share on other sites More sharing options...
GingerRobot Posted October 7, 2007 Share Posted October 7, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/72219-quick-debug/#findComment-364145 Share on other sites More sharing options...
Wolphie Posted October 7, 2007 Author Share Posted October 7, 2007 Ok, sorry. You can witness it for yourself. http://81.132.229.36/dev/dave/register.php Just put your info in and hit register, then you'll see what i mean. Quote Link to comment https://forums.phpfreaks.com/topic/72219-quick-debug/#findComment-364148 Share on other sites More sharing options...
GingerRobot Posted October 7, 2007 Share Posted October 7, 2007 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? Quote Link to comment https://forums.phpfreaks.com/topic/72219-quick-debug/#findComment-364152 Share on other sites More sharing options...
Wolphie Posted October 7, 2007 Author Share Posted October 7, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/72219-quick-debug/#findComment-364156 Share on other sites More sharing options...
Rithiur Posted October 7, 2007 Share Posted October 7, 2007 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) Quote Link to comment https://forums.phpfreaks.com/topic/72219-quick-debug/#findComment-364166 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.