Jump to content

MYSQL Problems


xyn

Recommended Posts

Hi,
I have a config file which Is attached to every page, within
this config file I have a website closed script, this allows
the admins to turn it on or off. the problem is with the SQL

I have created it to check the users rank from a database
if the rank is not an admin then they are redirected to my
closed page. However, when a member is not signed in
it doesn't affect them, neither does it if they are signed in.

Is there any way around it?

My code is...
[code=php:0]$ssql = mysql_query("SELECT usr_rank FROM accounts WHERE usr_user='{$_SESSION['username']['usr_user']}'");
while( $sdat = mysql_fetch_array($ssql, MYSQL_NUM))
{
if( $sdat[0] != admin )
{
$sql = mysql_query("SELECT func_value FROM options WHERE op_id='1' AND func_name='web'");
while( $data = mysql_fetch_array($sql, MYSQL_NUM))
{
$lock = $data[0];
if( $lock == y )
{
echo '<meta http-equiv="REFRESH" content="0;URL=closed/index.php">';
exit;
}
}
}else{
echo '<div align="center">
  <center>
  <table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="50%" background="../template/images/bgmain.gif" height="20" bgcolor="#FFFFFF">
    <tr>
      <td width="100%">
      <p align="center"><b><font size="1" face="Verdana">MAINTENANCE MODE</font></b></td>
    </tr>
  </table>
  </center>
</div>';
}
}[/code]
Link to comment
Share on other sites

yep before the query you could put an if statement.

If no session the redirect to closed page.

the query shoudl only retuen one result so get rid of the while loops.

you if statement to see if they are admin is missing quotes around teh string.... 'admin' as is the lock if statement.....
Link to comment
Share on other sites

I can see a couple of possible problems here.

First, you don't have 'admin' and 'y' in quotations in your conditionals.

Second, I'm not sure that -

echo '<meta http-equiv="REFRESH" content="0;URL=closed/index.php">';

-will result in a redirect (if it does, I've learned something new-thanks). 

You might try header("Location:yourdomain.com/closed/index.php"); instead.
Link to comment
Share on other sites

1. my if statements don't need quotes " or ' i've tested it. 2. the META will redirect.
because: 1. it's a HTML tag. and 2. if the headers are sent with Sessions, cookies or <head> using the META is the other solution to redirecting :/
Link to comment
Share on other sites

Guest
This topic is now 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.