Jump to content

Archived

This topic is now archived and is closed to further replies.

Drezard

$end error - php script not working

Recommended Posts

I keep getting a

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Parse error: syntax error, unexpected $end in C:\Program Files\xampp\htdocs\Website\new_char.php on line 78 [/quote]

Everytime i try to run this script. I know that means its a if or a else not with a } on it but i cant work out which one. Please help me.

Script:
[code]
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<?
include('connect.php');

$user = $_COOKIE['user'];
  
if (isset($_COOKIE['user'])) {
   $sql="SELECT * FROM users WHERE user= '$user'";
  
   $result=mysql_query($sql);
   // Mysql_num_row is counting table rows
  
   $count=mysql_num_rows($result);
   // If result matched $user, table row must be 1 row
  
   if($count==1){
   //The user is logged in.
  
           $sql="SELECT * FROM users WHERE user='$user' and stage='1'";
  
           $result=mysql_query($sql);
           // Mysql_num_row is counting table rows
  
           $count=mysql_num_rows($result);
           // If result matched $user and 1, table row must be 1 row
  
           if($count==1){
           //The User hasnt created a character.
        ?>        
            <form action="<?=$_SERVER['PHP_SELF']?>" method="post">
        Enter A Character Name: <input type="text" name="char_name">                                              
        <input type="submit" name="submit">
        </form>
        <?php    
        $char_name = empty($_POST['char_name']) ? die ("Please Enter A Character Name") : mysql_escape_string($_POST['char_name']);
    
            if(!empty($_POST)){

            $char_name = mysql_real_escape_string($_POST['char_name']);

            $result = mysql_query("SELECT count(*) FROM `char_name` WHERE `char_name` = '$char_name'") or die(mysql_error());
            $count = mysql_result($result,0);

                if($count > 0){
                die('This Character Name is already in use.  Please select a different one.');
                } else {
              
                 // create query
        $query = "INSERT INTO users (char_name, char_stage) VALUES ('$char_name', '2')";
  
        // execute query
        $result = mysql_query($query) or die ("Error in query: $query. ".mysql_error());
  
        // close connection
        mysql_close($connection);        
    }
    }
    else {
    echo "You have already created a character or have done this part.";
    }
}
}
else {
echo "You must be logged in to view this page.";
}
if (!isset($_COOKIE['user'])) {
    echo "You must be logged in to view this page.";
    }
      ?>
</body>
</html>
[/code]

- Cheers, Daniel

Share this post


Link to post
Share on other sites
try adding a second } at line 72
[code]
echo "You must be logged in to view this page.";
}
}
if (!isset($_COOKIE['user'])) {
[/code]

Share this post


Link to post
Share on other sites

×

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.