Jump to content


Photo

$end error - php script not working


  • Please log in to reply
1 reply to this topic

#1 Drezard

Drezard
  • Members
  • PipPipPip
  • Advanced Member
  • 244 posts

Posted 24 May 2006 - 06:28 AM

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:
<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>

- Cheers, Daniel

#2 Honoré

Honoré
  • Members
  • PipPipPip
  • Advanced Member
  • 66 posts
  • LocationAntwerp - Belgium

Posted 24 May 2006 - 06:49 AM

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





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users