Jump to content

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
Link to comment
https://forums.phpfreaks.com/topic/10323-end-error-php-script-not-working/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.