Jump to content

include statement with session variable authentication


jandrews3

Recommended Posts

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.

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.