Jump to content

Need help debugging. Unexpected T-ELSE

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
4 replies to this topic

#1
Ascension

Ascension

    Learning Programmer

  • Members
  • PipPipPip
  • 42 posts
I keep getting an error:

Parse error: parse error in C:\wamp\www\ForumPro\index.php on line 32

and in my phpdesigner: Unexpected T_ELSE line 32

Below is my code:

<?php


session_start();

include "./global.php"


?>

<html>

	<head>

		<title>ForumPro Index Page</title>

		<link rel=StyleSheet href="style.css" type="text/css">

	</head>

	<body>

		<center>

			<div id="holder">

				<div id="userInfo">

			 		<?php

			 		

			 		if(isset($_SESSION['uid']))

			 		{

			 			$sql = "SELECT username FROM `users` WHERE `id`='".$_SESSION['uid']."'";

			 			$result = mysql_query($sql) or die(mysql_error());

			 			

			 			if(mysql_num_rows($res) == 0)

			 			{

			 				session_destroy();

			 				echo "Please <a href=\"./login.php\">login</a>, or <a href=\"./register.php\">register</a>.\n";

			 			}	

						 	else {

			 					$row = mysql_fetch_assoc($res);

			 					echo "Welcome back, <a href=\"./index.php?act=profile&id=".$row['id']."\">".$row['username']."</a>\n";

	 						}

						 		else {

							 		echo "Please <a href=\"./login.php\">login</a>, or <a href=\"./register.php\">register</a>.\n"

					 			}

			 		}

			 		?>

				</div>

			<?php

	

	

			?>

	

			</div>

		</center>

		

	</body>

</html>


Any help would be GREATLY appreciated.

#2
BlaineSch

BlaineSch

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,448 posts
Use this:

<?php

session_start();
include "./global.php";

?>
<html>
	<head>
		<title>ForumPro Index Page</title>
		<link rel=StyleSheet href="style.css" type="text/css">
	</head>
	<body>
		<center>
			<div id="holder">
				<div id="userInfo">
			 		<?php
			 		
			 		if(isset($_SESSION['uid']))
			 		{
			 			$sql = "SELECT username FROM `users` WHERE `id`='".$_SESSION['uid']."'";
			 			$result = mysql_query($sql) or die(mysql_error());
			 			
			 			if(mysql_num_rows($res) == 0)
			 			{
			 				session_destroy();
			 				echo "Please <a href=\"./login.php\">login</a>, or <a href=\"./register.php\">register</a>.\n";
			 			} else {
			 					$row = mysql_fetch_assoc($res);
			 					echo "Welcome back, <a href=\"./index.php?act=profile&id=".$row['id']."\">".$row['username']."</a>\n";
	 						}
			 		} else {
						echo "Please <a href=\"./login.php\">login</a>, or <a href=\"./register.php\">register</a>.\n"
					 }
			 		?>
				</div>
			</div>
		</center>
		
	</body>
</html>
+Rep Appreciated

#3
Ascension

Ascension

    Learning Programmer

  • Members
  • PipPipPip
  • 42 posts
++rep'd u

Thanks for your help but I still get this:


Parse error: parse error, expecting `','' or `';'' in C:\wamp\www\ForumPro\index.php on line 33

#4
BlaineSch

BlaineSch

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,448 posts
Sorry, line 32 was missing its semicolon :D

<?php

session_start();
include "./global.php";

?>
<html>
    <head>
        <title>ForumPro Index Page</title>
        <link rel=StyleSheet href="style.css" type="text/css">
    </head>
    <body>
        <center>
            <div id="holder">
                <div id="userInfo">
                     <?php
                     
                     if(isset($_SESSION['uid']))
                     {
                         $sql = "SELECT username FROM `users` WHERE `id`='".$_SESSION['uid']."'";
                         $result = mysql_query($sql) or die(mysql_error());
                         
                         if(mysql_num_rows($res) == 0)
                         {
                             session_destroy();
                             echo "Please <a href=\"./login.php\">login</a>, or <a href=\"./register.php\">register</a>.\n";
                         } else {
                                 $row = mysql_fetch_assoc($res);
                                 echo "Welcome back, <a href=\"./index.php?act=profile&id=".$row['id']."\">".$row['username']."</a>\n";
                             }
                     } else {
                        echo "Please <a href=\"./login.php\">login</a>, or <a href=\"./register.php\">register</a>.\n";
                     }
                     ?>
                </div>
            </div>
        </center>
        
    </body>
</html>


#5
Ascension

Ascension

    Learning Programmer

  • Members
  • PipPipPip
  • 42 posts
K thanks Bro.\

Thank you for your quick response.