Jump to content

T_ENCAPSED_AND_WHITESPACE problem


Azhur

Recommended Posts

<?php
			if($_SESSION['uid']) {
				$sql = "SELECT * FROM `users` WHERE `id`='".$_SESSION['uid']."'";
				$res = mysql_query($sql) or die(mysql_error());

				if(mysql_num_rows($res) == 0) {
					session_destroy();
					echo "<a href=\"./login.php\">Kirjaudu</a> tai <a href=\"./register.php>rekisteroidy</a>!\n";
			}else {
				$row = mysql_fetch_assoc($res);
				echo "Tervetuloa takaisin, <a href=\"./index.php?act=profile&id=".$row['id']."\">"."$row['username'].</a>!\n";
				if(row['admin'] == '1'){
					echo "<a href=\"./admin.php\">Admin-osio</a>\n";

				<a href=\"logout.php\" onClick=\"return confirmLogout()\">Kirjaudu ulos</a>\n";
			}
		}else {
				echo "<a href=\"./login.php\">Kirjaudu</a> tai <a href=\"./register.php\">rekisteröidy</a>\n";
		}
			?>

 

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/ratik/06/s6laju00/public_html/forum/index.php on line 69

 

Line 69 is:

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

 

I have heard many solutions to T_ENCAPSED_AND_WHITESPACE dilemma, but couldn't use any of those to make my code working. Any ideas?  ???

Link to comment
Share on other sites

From this...

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

 

To this...

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

 

The " in front of the $row['username'] should be behind

 

 

Link to comment
Share on other sites

This line

 

<a href="logout.php\" onClick=\"return confirmLogout()\">Kirjaudu ulos</a>\n";

 

Cannot just be slapped here, it needs to be echoed.

 

echo "<a href=\"logout.php\" onClick=\"return confirmLogout()\">Kirjaudu ulos</a>\n";

Link to comment
Share on other sites

Your if statements are all over the place. You need to close the if statements you are not using...

 

<?php
            if($_SESSION['uid']) {
               $sql = "SELECT * FROM `users` WHERE `id`='".$_SESSION['uid']."'";
               $res = mysql_query($sql) or die(mysql_error());
               
               if(mysql_num_rows($res) == 0) { // <- open
                  session_destroy();
                  echo "<a href=\"./login.php\">Kirjaudu</a> tai <a href=\"./register.php>rekisteroidy</a>!\n";
                  // <- no close?
            }else {
               $row = mysql_fetch_assoc($res);
               echo "Tervetuloa takaisin, <a href=\"./index.php?act=profile&id=".$row['id']."\">"."$row['username'].</a>!\n";
               if(row['admin'] == '1'){ // <- open
                  echo "<a href=\"./admin.php\">Admin-osio</a>\n";
                  // <- no close
                  
               <a href="logout.php\" onClick=\"return confirmLogout()\">Kirjaudu ulos</a>\n";
            }
         }else {
               echo "<a href=\"./login.php\">Kirjaudu</a> tai <a href=\"./register.php\">rekisteröidy</a>\n";
         }
            ?>

Link to comment
Share on other sites

Sounds like you should take a little time and review your code instead of posting every single error?  These are pretty easy to fix if you just read the actual error.

 

Now I feel stupid.  :-[

 

Parse error: syntax error, unexpected '<' in /home/ratik/06/s6laju00/public_html/forum/index.php on line 73

 

They just keep on coming...

Link to comment
Share on other sites

Sounds like you should take a little time and review your code instead of posting every single error?  These are pretty easy to fix if you just read the actual error.

 

Now I feel stupid.  :-[

 

Parse error: syntax error, unexpected '<' in /home/ratik/06/s6laju00/public_html/forum/index.php on line 73

 

They just keep on coming...

 

I agree, I am just a sucker to help people.

 

But revraz is correct, if you do receive an error, check to make sure all brackets open and close correctly, the line is terminated and all variables are correctly reference too.

Link to comment
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.