Azhur Posted November 26, 2008 Share Posted November 26, 2008 <?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? ??? Quote Link to comment Share on other sites More sharing options...
Adam Posted November 26, 2008 Share Posted November 26, 2008 try: echo "Tervetuloa takaisin, <a href=\"./index.php?act=profile&id=".$row['id']."\">".$row['username']."</a>!\n"; Quote Link to comment Share on other sites More sharing options...
samona Posted November 26, 2008 Share Posted November 26, 2008 Try the following echo "Tervetuloa takaisin," . ' <a href="./index.php?act=profile&id=' .$row['id']. '">' .$row['username']."</a>!\n"; Quote Link to comment Share on other sites More sharing options...
ILMV Posted November 26, 2008 Share Posted November 26, 2008 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 Quote Link to comment Share on other sites More sharing options...
Azhur Posted November 26, 2008 Author Share Posted November 26, 2008 All replies worked, but now a new error appeared on the next line: Parse error: syntax error, unexpected '[' in /home/ratik/06/s6laju00/public_html/forum/index.php on line 70 Quote Link to comment Share on other sites More sharing options...
ILMV Posted November 26, 2008 Share Posted November 26, 2008 It shoud be $row['admin'] not row['admin'] Quote Link to comment Share on other sites More sharing options...
Azhur Posted November 26, 2008 Author Share Posted November 26, 2008 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... Quote Link to comment Share on other sites More sharing options...
ILMV Posted November 26, 2008 Share Posted November 26, 2008 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"; Quote Link to comment Share on other sites More sharing options...
Azhur Posted November 26, 2008 Author Share Posted November 26, 2008 I actually tried that, but I thought it was wrong since it brought yet another error. Parse error: syntax error, unexpected T_ELSE in /home/ratik/06/s6laju00/public_html/forum/index.php on line 75 Quote Link to comment Share on other sites More sharing options...
ILMV Posted November 26, 2008 Share Posted November 26, 2008 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"; } ?> Quote Link to comment Share on other sites More sharing options...
revraz Posted November 26, 2008 Share Posted November 26, 2008 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... Quote Link to comment Share on other sites More sharing options...
ILMV Posted November 26, 2008 Share Posted November 26, 2008 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.