jandrews3 Posted August 4, 2012 Share Posted August 4, 2012 I'm using a database driven session variable authentication for my website. When I put the authentication in the webpage, it works fine. BUT, when I use an "include" to put it in, the page gives me an error. Here's the code: <?php session_start(); extract($_REQUEST); $link = mysql_connect("???????","???????","???????") or die("Could not connect: ".mysql_error()); mysql_select_db("???????")or die("Could not select database: ".mysql_error()); $query = "SELECT * FROM bowl_users WHERE uname = '{$_SESSION['user']['uname']}'"; $result = mysql_query($query) or die("Could not perform query: ".mysql_error()); $row = mysql_fetch_array($result); if ($_SESSION['user']['uname'] == ""){ print "<META HTTP-EQUIV=\"Refresh\" content=\"0;URL=index.php?improper=1\">"; } else { ?> I thought an "include" was the same as having the code in the page itself. The error I'm receiving is: Parse error: syntax error, unexpected '}' in /home/content/45/4971845/html/knowledge/bowl.php on line 120 Now I understand what the error is saying. I have a <?}?> at the end of my page to close out the "else" statement up above in the code. And it works just fine IF I don't use the include, but rather actually type the text in the page. i can do that, but I'd rather use as many "include"'s as I can. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/266681-include-statement-with-session-variable-authentication/ Share on other sites More sharing options...
cpd Posted August 5, 2012 Share Posted August 5, 2012 Unless you show us the code the error occurs at we can't help. You've just provided code that appears, to us, as though it wont work as you have no closing }. I appreciate you said you close it but your clearly doing something wrong because your receiving an error. Paste the code that actually errors. Quote Link to comment https://forums.phpfreaks.com/topic/266681-include-statement-with-session-variable-authentication/#findComment-1366924 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.