I am trying to get RoScript's PhP Login script to work properly and have blown through a lot of errors myself. Right now I am trying to get the coding down in order to require an Administrator to be logged on to view a page.
Fatal error: Call to a member function qstr() on a non-object on line 340
line 340 on functions.php:
$query = "SELECT `Level_access` FROM `" . DBPREFIX . "users` WHERE `ID` = " . $db->qstr ( $id );
content.php
<?php
session_start();
//Set Inclue Path
function setinclude(){
$levels = substr_count($_SERVER['PHP_SELF'],'/');
$root = '';
for($i = 1; $i < $levels; $i++){$root .= '../';}
set_include_path($root);
}
setinclude();
require_once('login/db.php');
include('login/functions.php');
if ( isadmin ( $_SESSION['user_id'] ) ):
?>
HTML FORM CODE HERE!
<?php
endif;
?>
functions.php lines 325-357
// ------------------------------------------------------------------------
/**
* Is admin - Determines if the logged in member is an admin
*
* @access public
* @param string
* @return bool
*/
function isadmin ( $id )
{
global $db;
$query = "SELECT `Level_access` FROM `" . DBPREFIX . "users` WHERE `ID` = " . $db->qstr ( $id );
if ( $db->RecordCount ( $query ) == 1 )
{
$row = $db->getRow ( $query );
if ( $row->Level_access == 1 )
{
return TRUE;
}
else {
return FALSE;
}
}
else {
return FALSE;
}
}