Help - Search - Members - Calendar
Full Version: Odd Syntax Error?
Zymic Webmaster Forums > Web Design & Development > Reviews > Website Reviews
redboypivot12
Every time I try to see if my registration form was successful, I get this message:

Parse error: syntax error, unexpected $end in /www/zxq.net/c/o/o/coolismine/htdocs/register/index.php on line 106

I don't know what the problem is, but I know one thing for sure: the php is getting mixed up with the html. I'll post my code below if you think you can figure it out:

CODE
<HTML>

<HEAD><TITLE>Register to Claim Your COOL!!!</TITLE></HEAD>

<BODY bgcolor=red>

<IMG SRC="coolismine.jpg">

Please fill out the form below:

<?php
include "functions.php"
?>

<center>
<form method="POST" action="register/index.php">
<table border="0" style="text-align: left; border: 1px solid black; padding: 2px; font-family: Tahoma; font-size: 12px;">
<tr>
<td>
Username:
</td>
<td>
<input type="text" name="username" value="<?php echo $_POST['username']; ?>">
</td>
<td>
Password:
</td>
<td>
<input type="password" name="password" value="<?php echo $_POST['password']; ?>">
</td>
<td>
<p>E-mail
</td>
<td>
<p><input type="text" name="email">
</td>
<td>
<p><input type="submit" name="submit" value="submit">
</td>
</tr>
</table>
</form>
<?php if($_POST['submit']) { ?>
<table border="0" style="width: 250; margin-top: 5px; border: 2px solid black; padding: 2px orange; font-family: Tahoma; font-size: 48px">
<?php
$curnum = 0;
$username = $_POST['username'];
$password = $_POST['password'];
$email = $_POST['email'];

if(!username) {
$curnum ++;
echo "<tr><td>".$curnum.". Please fill in your desired username.</td></tr>";
}

if(!password) {
$curnum ++;
echo "<tr><td>".$curnum.". Please fill in your desired password.</td></tr>";
}

if(!email) {
$curnum ++;
echo "<tr><td>".$curnum.". Please fill in your E-mail address.</td></tr>";
}

if($username) {
if(strlen($username) > 30) {
$curnum ++;
echo "<tr><td>".$curnum.". Your username is too long. Please shorten it down to only 30 characters or less.</td></tr>";
}

if(strlen($username) < 3) {
$curnum ++;
echo "<tr><td>".$curnum.". Your username is too short. Please lengthen it to at least 3 characters.</td></tr>";
}

if($password) {
if(strlen($password) > 30) {
$curnum ++;
echo "<tr><td>".$curnum.". Your password is too long. Please shorten it down to only 30 characters or less.</td></tr>";
}

if(strlen($password) < 5) {
$curnum ++;
echo "<tr><td>".$curnum.". Your password is too short. Please lengthen it to at least 3 characters.</td></tr>";
}


$sql = "SELECT * FROM myMembers WHERE username='".$username."'";
$res = mysql_query($sql) or die(mysql_error());

if(mysql_num_rows($res) > 0) {
$scurnum ++;
echo "<tr><td>".$curnum.". The username '<b>".$username."<b>' already exists. Please enter a different username.</td></tr>";


if($curnum == 0) {
mysql_query("INSERT INTO myMembers VALUES(`id`,'".$username."','".$password."','".$email."'):) or die(mysql_error());
} ?>
</table><?php } ?>

</center>

</BODY>

</HTML>


All help is greatly appreciated! I will thank you in advance!
Perry
You forgot to close one of your if statements. It looks to be:

CODE
<?php if($_POST['submit']) { ?>


It also looks like you forgot to close a few others, but it's hard to tell for me without the highlighting wink.gif
redboypivot12
QUOTE(Perry @ Nov 12 2009, 12:23 AM) *
You forgot to close one of your if statements. It looks to be:

CODE
<?php if($_POST['submit']) { ?>


It also looks like you forgot to close a few others, but it's hard to tell for me without the highlighting wink.gif


Thanks. It seems that I'm also getting another error that looks like this:

Warning: mysql_query() [function.mysql-query]: Access denied for user 'vhostswww'@'192.168.1.1' (using password: NO) in /www/zxq.net/c/o/o/coolismine/htdocs/register/index.php on line 94

Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /www/zxq.net/c/o/o/coolismine/htdocs/register/index.php on line 94
Access denied for user 'vhostswww'@'192.168.1.1' (using password: NO)

This is my updated code that I am using:

CODE
<HTML>

<HEAD><TITLE>Register to Claim Your COOL!!!</TITLE></HEAD>

<BODY bgcolor=red>

<IMG SRC="coolismine.jpg">

<p>Please fill out the form below:

<?php
include "functions.php"
?>

<center>
<form method="POST" action="/register/index.php">
<table border="0" style="text-align: left; border: 1px solid black; padding: 2px; font-family: Tahoma; font-size: 12px;">
<tr>
<td>
Username:
</td>
<td>
<input type="text" name="username" value="<?php error_reporting(E_ALL & ~E_NOTICE); echo $_POST['username']; ?>">
</td>
<td>
Password:
</td>
<td>
<input type="password" name="password" value="<?php error_reporting(E_ALL & ~E_NOTICE); echo $_POST['password']; ?>">
</td>
<td>
<p>E-mail
</td>
<td>
<p><input type="text" name="email">
</td>
<td>
<p><input type="submit" name="submit" value="Register">
</td>
</tr>
</table>
</form>
<?php error_reporting(E_ALL & ~E_NOTICE);
if($_POST['submit']) { ?>
<table border="0" style="width: 250; margin-top: 5px; border: 2px solid black; padding: 2px; font-family: Tahoma; font-size: 12px;">
<tr>
<td>
<?php
$curnum = 0;
$username = $_POST['username'];
$password = $_POST['password'];
$email = $_POST['email'];

if(!$username) {
$curnum ++;
echo "<tr><td>".$curnum.". Please fill in your desired username.</td></tr>";
}

if(!$password) {
$curnum ++;
echo "<tr><td>".$curnum.". Please fill in your desired password.</td></tr>";
}

if(!$email) {
$curnum ++;
echo "<tr><td>".$curnum.". Please fill in your E-mail address.</td></tr>";
}

if($username) {
if(strlen($username) > 30) {
$curnum ++;
echo "<tr><td>".$curnum.". Your username is too long. Please shorten it down to only 30 characters or less.</td></tr>";
}

if(strlen($username) < 3) {
$curnum ++;
echo "<tr><td>".$curnum.". Your username is too short. Please lengthen it to at least 3 characters.</td></tr>";
}
}

if($password) {
if(strlen($password) > 30) {
$curnum ++;
echo "<tr><td>".$curnum.". Your password is too long. Please shorten it down to only 30 characters or less.</td></tr>";
}

if(strlen($password) < 5) {
$curnum ++;
echo "<tr><td>".$curnum.". Your password is too short. Please lengthen it to at least 5 characters.</td></tr>";
}
}

$sql = "SELECT * FROM myMembers WHERE username='".$username."'";
$res = include_once "connect_to_mysql.php"; mysql_query($sql) or die(mysql_error());

if(mysql_num_rows($res) > 0) {
$curnum ++;
echo "<tr><td>".$curnum.". The username '<b>".$username."<b>' already exists. Please enter a different username.</td></tr>";
}

$sql = "SELECT * FROM myMembers WHERE email='".$email."'";
$res = mysql_query($sql) or die(mysql_error());

if(mysql_num_rows($res) > 0) {
$curnum ++;
echo "<tr><td>".$curnum.". The e-mail address '<b>".$email."<b>' is already associated with another account. If you would like to make another account with the same address, please contact the administrator at reese51785@yahoo.com with your e-mail, username, and password for your new account.</td></tr>";
}

if($curnum == 0) {
mysql_query ("INSERT INTO myMembers VALUES(`id`,'".$username."','".$password."','".$email."'):) or die(mysql_error())");
}
?>
</td>
</tr>
</table><?php } ?>

</center>

</BODY>

</HTML>


This is also the functions page that I am using in case the error is in there:

CODE
<?php
include_once "connect_to_mysql.php";
function good_query($string, $debug=0)
{
    if ($debug == 1)
        print $string;

    if ($debug == 2)
        error_log($string);

    $result = mysql_query($string);

    if ($result == false)
    {
        error_log("SQL error: ".mysql_error()."\n\nOriginal query: $string\n");
        // Remove following line from production servers
        die("SQL error: ".mysql_error()."\b<br>\n<br>Original query: $string \n<br>\n<br>");
    }
    return $result;
}
?>


This is probably one of the last few errors that I have to fix in order to get a working register form.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2012 Invision Power Services, Inc.