STRANGE PROBLEM

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Parody
Forum Contributor
Posts: 252
Joined: Fri May 06, 2005 7:06 pm
Location: Great Britain

STRANGE PROBLEM

Post by Parody »

For some strange reason I get an error on the last line of my code, even though it is empty, it is just a blank line

This is the error :

Code: Select all

Parse error: parse error in c:\program files\eas1yphp1-8\www\registertmp123.php on line 217
And the last 10 lines of the code are:

Code: Select all

<td>
      <td colspan=&quote;2&quote; align=&quote;right&quote; class=&quote;style5&quote;><div align=&quote;center&quote;>
        <input type=&quote;submit&quote; name=&quote;submit&quote; value=&quote;Sign Up&quote;>
      </div></td>&nbsp;</td>
    </tr>
  </table>
</div>
<p class=&quote;style5&quote;>&nbsp;  
</p>
</body>
</html>
It ends on HTML.

Strange :?: :lol:
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post by hawleyjr »

You are missing one of the following characters (;'"{}()) in your PHP code above the HTML you posted.
Parody
Forum Contributor
Posts: 252
Joined: Fri May 06, 2005 7:06 pm
Location: Great Britain

Post by Parody »

Thanks, how do I find out where?

Bit of a stupid question, but is there a quicker way?
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post by anjanesh »

Post Lines 216, 217 & 218 of code c:\program files\eas1yphp1-8\www\registertmp123.php
Parody
Forum Contributor
Posts: 252
Joined: Fri May 06, 2005 7:06 pm
Location: Great Britain

Post by Parody »

That is the point, the line at the end is just this:

Code: Select all

<html>
The last 3 lines are:

Code: Select all

</p>
</body>
</html>
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post by anjanesh »

Parody - a parse can take place for php related code - not HTML.
Post the PHP code of those lines - not the HTML generated output.
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

well start searchign for the missing end of a line...usually it's a missing "}" on a loop or an if or something like that with the error you described.

might help if you posted all of your code...
Parody
Forum Contributor
Posts: 252
Joined: Fri May 06, 2005 7:06 pm
Location: Great Britain

Post by Parody »

Ok, here is the code:

Code: Select all

<?php
require('db_connect.php');	// database connect script.

?>
<html>
<head>
<title>Register an Account</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><style type="text/css">
<!--
body {
	background-image: url(/top2.jpg);
}
.style3 {color: #FFFFFF; font-weight: bold; }
a:link {
	color: #FFFFFF;
}
a:visited {
	color: #FFFFFF;
}
.style4 {
	color: #FFFFFF;
	font-family: Arial, Helvetica, sans-serif;
}
.style5 {font-family: Arial, Helvetica, sans-serif}
.style6 {
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-weight: bold;
	color: #FFFFFF;
}
-->
</style></head>
<body>
<?php

$rand = rand(10248765,99543547);
$chrctr = $_POST['chrctr'];
if(isset($_POST['submit'])) { // if form has been submitted
	/* check they filled in what they supposed to, passwords matched, username
	isn't already taken, etc. */
	if(!$_POST['uname'] | !$_POST['email'] | $_POST['character']) {
		die('You didn\'t complete the register form correctly.');
	
	// check if username exists in database.
	if(!get_magic_quotes_gpc()) {
		$_POST['uname'] = addslashes($_POST['uname']);
	
	$name_check = $db_object->query("SELECT username FROM users WHERE username = '".$_POST['uname']."'");
	if(DB::isError($name_check)) {
		die($name_check->getMessage());
	
	$name_checkk = $name_check->numRows();

	if($name_checkk != 0) {
		die('Sorry, the username: <strong>'.$_POST['uname'].'</strong> is already taken, please pick another one.');
	
	
	// check e-mail format
	if(!preg_match("/.*\@.*\..*/", $_POST['email']) | preg_match("/(\<|\>)/", $_POST['email'])) {
		die('Sorry the e-mail address you submitted was of invalid format.');
	
	// no HTML tags in username, website, location, password
	if(preg_match("/(\<|\>)/", $_POST['uname']) | preg_match("/(\<|\>)/", $_POST['passwd']) | preg_match("/(\<|\>)/")) {
		die('Invalid input, no HTML tags are allowed.');
	

	$_POST['passwd'] = md5($_POST['passwd']);
	if(!get_magic_quotes_gpc()) {
		$_POST['passwd'] = addslashes($_POST['passwd']);
		$_POST['email'] = addslashes($_POST['email']);

	
mysql_connect("localhost", "(myusername)", "(mypassword)") or die(mysql_error());
mysql_select_db("users") or die(mysql_error());
$regdate = date('m d, Y');
$qry = "INSERT INTO users (username, password, regdate, email) VALUES ('".$_POST['uname']."', '".$rand."', '".$regdate."', '".$_POST['email']."')";
echo $qry;
mysql_query($qry)  or die(mysql_error());
#$result = mysql_query($query) or die (mysql_error());
mysql_query("INSERT INTO stats('".$_POST['uname']."','$chrctr', '100', '2000', '001', '01', 000, '01', '01', '01', '1', '0', '00000000', '00000000', '00000000', '00000000')");
echo mysql_errno() . ": " . mysql_error() . "<br><br>";
mysql_close();		
?>
<?php
$to = $_POST['email'];
$subject = "(subject)";
$body = "Your password is: ".$rand;
if (mail($to, $subject, $body))
?>
<h1 class="style4"><strong>Registered</strong></h1>
<p class="style3 style5">Thank you, you successfully registered, you may now <a href="/login.php" title="Login" target="_self">log in</a>.</p>
<span class="style4">
<?php
}
else {	// if form hasn't been submitted
?>
</span>
<h1 class="style4">Register</h1>
<form action="<?=$HTTP_SERVER_VARS['file:///K|/HOMIES/PHP_SELF']?>" method="post">
<table border="1" align="center" cellpadding="3" cellspacing="0" bordercolor="#999999">
<tr><td class="style5"><span class="style3">Username*:</span></td>
<td class="style5"><input type="text" name="uname" maxlength="40"></td></tr>
<tr><td class="style5"><span class="style3">E-Mail*:</span></td>
<td class="style5"><input type="text" name="email" maxlength="100"></td></tr>
<tr></tr>
</table>
</form>
<p align="center" class="style5">
  <?php
}
?>
</p>
<p align="center" class="style6">PICK A HOMIE</p>
<div align="center">
<table width="600" border="1">
    <tr>
      <td width="100"><img src="/characters/1.jpg" width="100" height="150"></td>
      <td width="100"><img src="/characters/2.jpg" width="100" height="150"></td>
      <td width="100"><img src="/characters/3.jpg" width="100" height="150"></td>
      <td width="100"><img src="/characters/4.jpg" width="100" height="150"></td>
      <td width="100"><img src="/characters/5.jpg" width="100" height="150"></td>
      <td width="108"><div align="center"><img src="/characters/6.jpg" width="100" height="150"></div></td>
    </tr>
    <tr>
      <td><div align="center">
  <input type="radio" name="character" value="1">
  <br>
      </div></td>
      <td><div align="center">
        <input type="radio" name="character" value="2">
      </div></td>
      <td><form name="form1" method="post" action="">
        <div align="center">
          <input type="radio" name="character" value="3">
        </div>
      </form></td><td>
        <form name="form1" method="post" action="">
        <div align="center">
          <input type="radio" name="character" value="4">
        </div>
      </form></td>
      <td>
        <form name="form1" method="post" action="">
        <div align="center">
          <input type="radio" name="character" value="5">
        </div>
      </form></td>
      <td><form name="form1" method="post" action="">
        <div align="center">
          <input type="radio" name="character" value="3">
        </div>
      </form></td>
    </tr>
  </table>
<p>&nbsp;</p>
<table width="600" border="1">
  <tr>
    <td width="100"><img src="/characters/7.jpg" width="100" height="150"></td>
    <td width="100"><img src="/characters/8.jpg" width="100" height="150"></td>
    <td width="100"><img src="/characters/9.jpg" width="100" height="150"></td>
    <td width="100"><img src="/characters/10.jpg" width="100" height="150"></td>
    <td width="100"><img src="/characters/11.jpg" width="100" height="150"></td>
    <td width="108"><div align="center"><img src="/characters/12.jpg" width="100" height="150"></div></td>
    <td width="108"><img src="/characters/13.jpg" width="100" height="150"></td>
  </tr>
  <tr>
    <td><div align="center">
        <input type="radio" name="character" value="7">
        <br>
    </div></td>
    <td><div align="center">
        <input type="radio" name="character" value="8">
    </div></td>
    <td><form name="form1" method="post" action="">
        <div align="center">
          <input type="radio" name="character" value="9">
        </div>
    </form></td>
    <td>
      <form name="form1" method="post" action="">
        <div align="center">
          <input type="radio" name="character" value="10">
        </div>
    </form></td>
    <td>
      <form name="form1" method="post" action="">
        <div align="center">
          <input type="radio" name="character" value="11">
        </div>
    </form></td>
    <td><form name="form1" method="post" action="">
        <div align="center">
          <input type="radio" name="character" value="12">
        </div>
    </form></td>
    <td><form name="form1" method="post" action="">
      <div align="center">
        <input type="radio" name="character" value="13">
      </div>
    </form></td>
  </tr>
</table>
<p>&nbsp;</p>
</div>
<div align="center">
  <table width="200" border="1">
    <tr>
      <td>
      <td colspan="2" align="right" class="style5"><div align="center">
        <input type="submit" name="submit" value="Sign Up">
      </div></td>&nbsp;</td>
    </tr>
  </table>
</div>
<p class="style5">&nbsp;  
</p>
</body>
</html>
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

you're missing a TON of "}"

each one of those ifs that has a "{" needs to be "closed" with "}".

you can use ifs without "{" if whatever you want to execute that falls within the condition is only one line

ex:

Code: Select all

if($bob)
  $stuff = "stuff";
$willy = "willy";
// if bob is true, only stuff will get set whereas....
if($bob){
  $stuff = "stuff";
  $willy = "willy";
} // notice the closing bracket here...you need to add a bunch of those
// if bob is true both stuff and willie will get set.
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post by anjanesh »

Your closing block at Line 93 seems to be closing for the Line if(!get_magic_quotes_gpc()) { at Line 44 - Missed a } somwhere.
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

I count a lot more missing than that.

lines:
40
44
48
53
58
62
67
all have { that don't terminate...

there are a few } intertwined with the html below, but I'll leave it up to him to sort through that.
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post by anjanesh »

Parody - If you have you indentations aligned vertically at tabbed intervals for every inner block you would be able to sort it out very easily.
Most people use this style - which till date I have not understood why - esp true c/c++ guys.

Code: Select all

if (condition) {
 // Statements
 }
but I prefer it this way :

Code: Select all

if (condition)
 {
        ?>
        <table>
        </table>
        <?
 }
else
 {
        ?>
        <table>
        .
        .
                <table>
                <?
                echo 'something';
                ?>
                </table>
        .
        .
        </table>
        <?
 }
Parody
Forum Contributor
Posts: 252
Joined: Fri May 06, 2005 7:06 pm
Location: Great Britain

Post by Parody »

Can someone tell me which lines have problems please :?:

:(

If someone can be really kind and tell me the corrections for each line, it would be most apprecciated :D

I can't learn from my mistakes if I don't know what to change :(
Parody
Forum Contributor
Posts: 252
Joined: Fri May 06, 2005 7:06 pm
Location: Great Britain

Post by Parody »

Please :?: :(
Post Reply