Jump to content

Error?


unidox

Recommended Posts

I need some help, I keep getting this error popping up.

 

Here is my login.php:

if (($_COOKIE['user']) && ($_COOKIE['pass'])) {
$user = $_COOKIE['user'];
$pass = $_COOKIE['pass'];
$admin = LEVEL_ADMIN;
$ip = $_SERVER["REMOTE_ADDR"];
    $date = "" . date('l dS \of F Y h:i:s A') . " EST";

//MySQL Query
    $q = mysql_query("SELECT * FROM `pcp_users` WHERE password = '$pass' AND username = '$user'");
    $r = mysql_fetch_array($q);
    
    $group = $r['group'];
    $q2 = mysql_query("SELECT * FROM `pcp_groups` WHERE `name` = '$group'");
    $r2 = mysql_fetch_array($q2);
$lvl_array = $r2['pages'];
$lvl_array = split(":", $lvl_array);
    
if ((mysql_num_rows($q) == 1) && (in_array("admin", $lvl_array))) {
	mysql_query("UPDATE `pcp_users` SET ip = '$ip', date = '$date' WHERE password = '$pass' AND username = '$user'");
	$_SESSION['admin'] = 1;
        $_SESSION['user'] = $r['username'];
        header("Location: index.php");
} else {
	setcookie("user", "", time()-60*60*24*100, "/");
   		setcookie("pass", "", time()-60*60*24*100, "/");
	header("Location: login.php");
}

 

That checks a users cookie to make sure they are logged in.

 

But I keep getting this error:

 

Catchable fatal error: Object of class stdClass could not be converted to string in /home/purecp/public_html/beta/admin/process.php on line 23

 

This is index.php:

 

include ('../incs/conf.inc.php');
include("process.php");
session_start();
if ($_SESSION['admin'] != '1') {
header("Location: login.php");
} else {
$user = $_SESSION['user'];
$q = mysql_query("SELECT * FROM `pcp_users` WHERE username = '$user'") or die(mysql_error());
$r = mysql_fetch_array($q);
$usergroup = $r['group'];
$viewer = getenv('HTTP_USER_AGENT');
$browser = 'An Unidentified Browser.';
if (preg_match("/MSIE/i", "$viewer")) { $browser = 'Internet Explorer'; }
if (preg_match("/Netscape/i", "$viewer")) { $browser = 'Netscape'; }
if (preg_match("/Opera/i", "$viewer")) { $browser = 'Opera'; }
if (preg_match("/Firefox/i", "$viewer")) { $browser = 'Mozilla Firefox'; }

$platform = 'An Unidentified Platform.';
if (preg_match("/Windows/i", "$viewer")) { $platform = 'Windows'; }
if (preg_match("/Linux/i", "$viewer")) { $platform = 'Linux'; }

 

and the 1st few lines of process.php:

session_start();
if ($_SESSION['admin'] != '1') {
header("Location: login.php");
} else {
if (!isset($path)) {
	exit();
}

$q = mysql_query("SELECT * FROM `pcp_users` WHERE username = '$user'") or die (mysql_error()); // Line 22 <------
$r = mysql_fetch_array($q);	
$lvl = $r['level'];	 // Find the users level.
$date = date("F jS, g:i a");

 

Whats wrong?

Link to comment
https://forums.phpfreaks.com/topic/103341-error/
Share on other sites

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.