Solved

What does this error mean?

Posted on 2013-01-12
21
348 Views
Last Modified: 2013-01-15
Here's the error I'm getting:

 Notice: Undefined variable: main_control in /mnt/vhosts/heavydutylighting.com/httpdocs/cms/index.php on line 124 Notice: Undefined variable: main_control in /mnt/vhosts/heavydutylighting.com/httpdocs/cms/index.php on line 158 ACCESS DENIED control=

From what I've been able to determine so far, the main_control shows up initially at 107 and that seems to be dependent on $control.

In any event, I've spent a bunch of time just getting the site to talk to the correct database. Now that that is in place, I'm running into this mess and I'm not sure what the problem is or how to fix it.

Thoughts?

page is attached
index.php
0
Comment
Question by:brucegust
  • 8
  • 8
  • 3
  • +1
21 Comments
 
LVL 108

Assisted Solution

by:Ray Paseur
Ray Paseur earned 250 total points
ID: 38769979
Please use the code snippet when you post code here at EE.  It gives us a unispace font and line numbers that facilitate discussion.
<?php
include('systemclient.inc');include('mod_user/user.inc.php');include('mod_user/group.inc.php');include('mod_user/editself.inc.php');include('mod_image/image.inc.php');include('obj_pdf/pdffile.inc.php');include('mod_gallery/gallery.inc.php');include('obj_singleimage/singleimage.inc.php');include('mod_product/product.inc.php');include('mod_rep/rep.inc.php');session_start();
ini_set("display_errors",1);

// MAIN APPLICATION CONTROL //
// this coding is the main switch for the application logic
//it controls security clearence and all requests are made to this switch

//Include the Config File//
/*
the config file contains the location information for the main div elements
*/
include 'config.php';
//include('stepsequence.inc.php');

// set the app wide control value to a default start value
$control="main.null.null";
$noparts=0;

//place any form or url  control variable into the local varaible
//print_r($_POST);exit;
if(isset($_POST["control"])){
	$control=$_POST["control"];
}

if(isset($_GET["control"])){
	$control=$_GET["control"];
}

if(isset($_POST["noparts"])){
	$noparts=$_POST["noparts"];
}

if(isset($_GET["noparts"])){
	$noparts=$_GET["noparts"];
}



/* FUNCTIONS */
include 'master_functions.php';


/* Initilize the application*/


$_SESSION["editsteps"] = array();

// if a url var of logout is set then delete current client information
if(isset($_GET["logout"])){
	$_SESSION["SystemClient"] = "";
	$_SESSION ="";
	}
//this controls the timeout length of the client session
if(isset($_SESSION["timeout"])){
	$diff = time()*1 - $_SESSION["timeout"];
	if($diff > 1800){
		$_SESSION["SystemClient"] = "";
		$_SESSION["timeout"] = time();
	}else{
		$_SESSION["timeout"]=time();
	}
}else{
	$_SESSION["timeout"]=time();
}
//call the DataRecord Function//
/*its purpose is to save all form values into their respective session objects*/
StoreData();

	?>
	<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
	<html>
	<head>
	<title><?php echo $_SESSION['layout']['company_name']; ?> CMS</title>
	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
	<script src="default.js" type="text/javascript"></script>
	<script src="utilities.js" type="text/javascript"></script>
	<script src="cal2.js" type="text/javascript"></script>
	<script src="cal_conf2.js" type="text/javascript"></script>
	<?php include 'style.php'?>
</head>

<body style="margin:0px;">
<?php include "login_script.php"; ?>
		<div style="width:100%;height:4;background-color:<?php echo $_SESSION['color_01']; ?>;position:absolute;top:0px;left:0px;border-bottom:1px solid black;z-index:0;"></div>
		<div class="div_control">
			<?php 
			//ECHO for debug
				if(!$noparts){
				echo $control;
				}
			?>
		</div>
		<div class="div_header">
			<img src="media/cms_header.gif" alt="
				<?php $_SESSION['layout']['company_name']?> CMS" 
				<?php
					$name=$_SESSION['SystemClient']->GetName();
					if (strpos($_SERVER['SERVER_NAME'],"localhost") && trim(strtoupper($name))=="MASTERa  CONTROL"){
						echo "width=\"1\"";
					}?> 
			height="69">
		</div>
		<?php
		if(is_object($_SESSION["SystemClient"]) && $_SESSION["SystemClient"]->HasAccess($control)){ 
			//content switch will go here
			$main_control = explode(".", $control);
			include 'nav.php';
			echo"<div style=\"position:absolute;top:100px;height:22px;left:0px;\">";
			BuildNav($nav,$control);
			echo"</div>";
			//always display the logout option
			//615
			DisplayLogout(625,6,$_SESSION["SystemClient"]->GetName());
		}
		?>
		<?php
			$div_height=153 + $_SESSION['main_nav_height'];
		?>
		<div class="div_main_holder" style="top:<?php echo $div_height ?>px;position:absolute;left:15px;">
		
		<?php

			switch ($main_control[0]) {
			
				//DO NOT REMOVE THESE CASES:THEY ARE THE DEFAULT INSTALLED CASES
				case "editself":
					//include the main switch for the user controls
					include 'mod_user/editself.php';
					break;
				case "user":
					//include the main switch for the user controls
					include 'mod_user/index.php';
					break;
				 case "group":
					//include the main switch for the user controls
					include 'mod_user/group_index.php';
					break;
				case "product":
					//include the main switch for the user controls
					include 'mod_product/index.php';
					break;
				case "image":
					//include the main switch for the user controls
					include 'mod_image/index.php';
					break;
				case "main":
					//include the main switch for the user controls
					include 'main.php';
					break;
				case "rep":
					include 'mod_rep/index.php';
					break;

				//END DEFAULT CASES//
			
				default:
					print "<span style=\"COLOR:RED;font-size:34px;\">ACCESS DENIED control=".$main_control[0]."</span>";
					break;
			}
		?>
		</div>

</body>
</html>

Open in new window

0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 38770005
$main_control is initialized on line 107.  It is an array made up from explode(), called on a variable $control.

$control is set on line 17, and possibly modified on lines 23 and/or 27, depending on the request elements in $_GET or $_POST.  $control may be used on line 105.

Not to be flip, but is there any way you can just get rid of this?  It looks like very amateurish programming, and I am not sure it would be worth the time to try to debug it.  But if you want to debug it, the first thing I would recommend is to add error_reporting(E_ALL) to the top of the script and then start using var_dump() to print out the independent variables.  Via that technique you can see where values are coming from and what variables are used to create other variables.  It's not an easy process, and in this pile of spaghetti it may take quite a while to get to a good answer, sorry.
0
 

Author Comment

by:brucegust
ID: 38770064
Morning, Ray! Glad you're up and at 'em!

Frankly, while I'm always open to the path of least resistance, I feel like out of respect for the fact that this isn't my code, I need to try and fix what's there before I introduce something of my own.

So, if you're willing, here goes:

I put error_reporting(E_ALL) at the top of the page and nothing else besides what I've already documented came up. I then added a var_dump($control); on line 70 to see if that was being "seen" at all, and it doesn't appear to be.

I can't figure out where $control is coming from...
0
 

Author Comment

by:brucegust
ID: 38770066
<?php
error_reporting(E_ALL);
 include('systemclient.inc');include('mod_user/user.inc.php');include('mod_user/group.inc.php');include('mod_user/editself.inc.php');include('mod_image/image.inc.php');include('obj_pdf/pdffile.inc.php');include('mod_gallery/gallery.inc.php');include('obj_singleimage/singleimage.inc.php');include('mod_product/product.inc.php');include('mod_rep/rep.inc.php');session_start();
ini_set("display_errors",1);

// MAIN APPLICATION CONTROL //
// this coding is the main switch for the application logic
//it controls security clearence and all requests are made to this switch

//Include the Config File//
/*
the config file contains the location information for the main div elements
*/
include 'config.php';
//include('stepsequence.inc.php');

// set the app wide control value to a default start value
$control="main.null.null";
$noparts=0;

//place any form or url  control variable into the local varaible
//print_r($_POST);exit;
if(isset($_POST["control"])){
	$control=$_POST["control"];
}

if(isset($_GET["control"])){
	$control=$_GET["control"];
}

if(isset($_POST["noparts"])){
	$noparts=$_POST["noparts"];
}

if(isset($_GET["noparts"])){
	$noparts=$_GET["noparts"];
}



/* FUNCTIONS */
include 'master_functions.php';


/* Initilize the application*/


$_SESSION["editsteps"] = array();

// if a url var of logout is set then delete current client information
if(isset($_GET["logout"])){
	$_SESSION["SystemClient"] = "";
	$_SESSION ="";
	}
//this controls the timeout length of the client session
if(isset($_SESSION["timeout"])){
	$diff = time()*1 - $_SESSION["timeout"];
	if($diff > 1800){
		$_SESSION["SystemClient"] = "";
		$_SESSION["timeout"] = time();
	}else{
		$_SESSION["timeout"]=time();
	}
}else{
	$_SESSION["timeout"]=time();
}
//call the DataRecord Function//
/*its purpose is to save all form values into their respective session objects*/
StoreData();
var_dump($control);
	?>
	<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
	<html>
	<head>
	<title><?php echo $_SESSION['layout']['company_name']; ?> CMS</title>
	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
	<script src="default.js" type="text/javascript"></script>
	<script src="utilities.js" type="text/javascript"></script>
	<script src="cal2.js" type="text/javascript"></script>
	<script src="cal_conf2.js" type="text/javascript"></script>
	<?php include 'style.php'?>
</head>

<body style="margin:0px;">
<?php include "login_script.php"; ?>
		<div style="width:100%;height:4;background-color:<?php echo $_SESSION['color_01']; ?>;position:absolute;top:0px;left:0px;border-bottom:1px solid black;z-index:0;"></div>
		<div class="div_control">
			<?php 
			//ECHO for debug
				if(!$noparts){
				echo $control;
				}
			?>
		</div>
		<div class="div_header">
			<img src="media/cms_header.gif" alt="
				<?php $_SESSION['layout']['company_name']?> CMS" 
				<?php
					$name=$_SESSION['SystemClient']->GetName();
					if (strpos($_SERVER['SERVER_NAME'],"localhost") && trim(strtoupper($name))=="MASTERa  CONTROL"){
						echo "width=\"1\"";
					}?> 
			height="69">
		</div>
		<?php
		if(is_object($_SESSION["SystemClient"]) && $_SESSION["SystemClient"]->HasAccess($control)){ 
			//content switch will go here
			$main_control = explode(".", $control);
			include 'nav.php';
			echo"<div style=\"position:absolute;top:100px;height:22px;left:0px;\">";
			BuildNav($nav,$control);
			echo"</div>";
			//always display the logout option
			//615
			DisplayLogout(625,6,$_SESSION["SystemClient"]->GetName());
		}
		?>
		<?php
			$div_height=153 + $_SESSION['main_nav_height'];
		?>
		<div class="div_main_holder" style="top:<?php echo $div_height ?>px;position:absolute;left:15px;">
		
		<?php

			switch ($main_control[0]) {
			
				//DO NOT REMOVE THESE CASES:THEY ARE THE DEFAULT INSTALLED CASES
				case "editself":
					//include the main switch for the user controls
					include 'mod_user/editself.php';
					break;
				case "user":
					//include the main switch for the user controls
					include 'mod_user/index.php';
					break;
				 case "group":
					//include the main switch for the user controls
					include 'mod_user/group_index.php';
					break;
				case "product":
					//include the main switch for the user controls
					include 'mod_product/index.php';
					break;
				case "image":
					//include the main switch for the user controls
					include 'mod_image/index.php';
					break;
				case "main":
					//include the main switch for the user controls
					include 'main.php';
					break;
				case "rep":
					include 'mod_rep/index.php';
					break;

				//END DEFAULT CASES//
			
				default:
					print "<span style=\"COLOR:RED;font-size:34px;\">ACCESS DENIED control=".$main_control[0]."</span>";
					break;
			}
		?>
		</div>

</body>
</html>

Open in new window

0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 38770076
Hey, mate.  $control is getting set from the HTTP request -- either via POST['control'] or GET['control'] with the GET URL variable overwriting whatever was in the POST.  See line 18, 23-24 and 27-28.  So my guess is that this script expects something from an external source.

Maybe you can sprinkle some var_dump() statements into the script to try to follow the variables that way.  That is what I would do.

Sure would have been nice if the original author had given us some comments.
0
 
LVL 13

Assisted Solution

by:AielloJ
AielloJ earned 125 total points
ID: 38770160
brucegust,

Just a quick comment about the code quality based on Ray's comments.  Been down that road of "Let's try to fix the current mess as the expedient thing to do."  In most cases, the time spent to 'fix' poorly written code exceeds the time to restructure properly.  If, you manage to 'fix' the poorly written code you may either fix one thing and break another, or have a maintenance nightmare for years to come.

It may be job security, but very unrewarding and frustrating.  Tally ho Ray!!

Best regards,

AielloJ
0
 

Author Comment

by:brucegust
ID: 38770173
Gentlemen, I value the wisdom being disseminated here. If my best bet is to eliminate the dynamic that's causing the problem, I'm open to whatever represents a better approach. The long and short of it is, I'm not sure what he's doing. My guess is that the menu options are not displayed without a correct $control variable. But I don't see how or where I make that a moot point.

I'm not interested in others doing the work for me, but if anyone is willing to point me in the right direction, I'm willing to purchase them a digital Diet Coke...
0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 38770256
Try putting ?control=FOO in the URL when you run this script.  See what it does.  Perhaps "FOO" will show up somewhere in the output and it may give a clue to what is going on.  I wish I could point you in the right direction, but I have no way of knowing what direction that might be!

We have over 100 lines of code here, and there are a great many include statements for scripts that we do not have (I counted 22, but I may have missed some).  It's more of a project for someone who can get hands-on into the code and data base and spend a few hours injecting test elements.
0
 
LVL 33

Assisted Solution

by:Slick812
Slick812 earned 125 total points
ID: 38770302
greetings brucegust, , I am reluctant to get into this code of yours, as it seems to have too many Parts to try and understand what it may be doing as this single line -

include('systemclient.inc');include('mod_user/user.inc.php');include('mod_user/group.inc.php');include('mod_user/editself.inc.php');include('mod_image/image.inc.php');include('obj_pdf/pdffile.inc.php');include('mod_gallery/gallery.inc.php');include('obj_singleimage/singleimage.inc.php');include('mod_product/product.inc.php');include('mod_rep/rep.inc.php');session_start();

I noticed that the session_start(); was at the end of it, I missed it at first because It was so far to the right.

My two cents ,  
there is a code of -
if(is_object($_SESSION["SystemClient"]) && $_SESSION["SystemClient"]->HasAccess($control)){
    $main_control = explode(".", $control);


I am unable to see anywhere that this
$_SESSION["SystemClient"]
has been initiated as an OBJECT like this =
$_SESSION["SystemClient"] = new SystemClient();

there is this -
include('systemclient.inc');
which might could make that object, but it comes Before the session_start(); thing
from experience I have found that OBJECTs in the $_SESSION, usually do not go from page to page with good results, mostly you will need to re-create a $_SESSION object (with new) on each page. I try and NOT have objects in the $_SESSION at all;

if  $_SESSION["SystemClient"]  is not an object then This line -
$main_control = explode(".", $control);
may not be executed, so you get the "Undefined variable: main_control" error on the output

I know nothing about the code in  systemclient.inc    so I can not offer any way to test or fix this mess, sorry.
0
 
LVL 13

Expert Comment

by:AielloJ
ID: 38770360
brucegust,

Slick812's comment may have identified one of the most important issues here.  Even if it isn't it needs to be changed as it will most probably cause problems down the road.  The
session_start(); function must be the first line in the .php script file.

Aielloj
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 108

Expert Comment

by:Ray Paseur
ID: 38770500
What Aielloj said about the session_start() function.  But that aside, your quote, "I'm not sure what he's doing." might be telling.  From the look of the code, I would guess that the author was not sure what he was doing, either.  Putting session_start() at the top of the script is kind of PHP-101.  And who knows... It may actually be at the top of the script because it could be present in any of those other include() files.  PHP will only raise a Notice if the script calls session_start() more than once, and by default the PHP Notice messages are suppressed.  To see the Notices it is necessary to raise the error_reporting() level.
0
 

Author Comment

by:brucegust
ID: 38770567
I think I've found something. This may not be THE problem, but at least I think I'm unravelling  a little bit of the spaghetti...

The error right now is that $main_control is undefined. $main_control comes from $control and that's what I've been searching for and I think I just now found it, but I'm still not out of the dark and would love some input.

Below is the systemclient.inc file. Within that file is a function called SystemClient which is referenced on line 106 of the index.php file. This is the ball of snot that comes up empty where the $main_control variable is concerned...

      <?php
            if(is_object($_SESSION["SystemClient"]) && $_SESSION["SystemClient"]->HasAccess($control)){
                  //content switch will go here
                  $main_control = explode(".", $control);
                  include 'nav.php';
                  echo"<div style=\"position:absolute;top:100px;height:22px;left:0px;\">";
                  BuildNav($nav,$control);
                  echo"</div>";
                  //always display the logout option
                  //615
                  DisplayLogout(625,6,$_SESSION["SystemClient"]->GetName());
            }
            ?>

On line 31 of the systemclient.inc file is a query that's popping the hood of two tables: users and access. One of the column names in the access table is "control" and I'm thinking that's where the problem is.

Take a look at the systemclient.inc file and tell me if I'm barking up the right tree...
0
 

Author Comment

by:brucegust
ID: 38770569
<?php

/*This is the 'SystemClient' object
It will store infromation about a current system client in it's object structure
 */
 
 
 class SystemClient{
 	
	var $id, $name,$username,$email,$privileges,$group_type,$group_id;
	
		
 	function SystemClient ($user_id){
		if (strpos($_SERVER['SERVER_NAME'],"snowdogweb")){
		$user="seth";
		$pass="newguy";
		$datasource="heavy_duty";
		$server="localhost";
		}else{
		$user = "hdldba";
		$dbase_user="hdldba";
		$pass="";
		$datasource = "hdlighting_";
		$server="localhost";
		}
		
			
		$dbase_user = mysql_connect($server,$user,$pass);
		mysql_select_db($datasource, $dbase_user);
	
		$query_results = mysql_query("SELECT users.id,users.first_name,users.last_name,users.m_inital,users.email,users.username,groups.type,users.group_id from users LEFT JOIN groups ON users.group_id = groups.id WHERE users.id='$user_id'", $dbase_user);
		
		$data = mysql_fetch_array($query_results);
		//print_r($data);
		$this->id = $data["id"];
		$this->name = $data["first_name"] ." ". $data["m_inital"]  ." ". $data["last_name"];
		$this->username = $data["username"];
		$this->email = $data["email"];
		$this->group_type = $data["type"];
		$this->group_id=$data["group_id"];
	}
 
 	function NumPriv(){
	
	return count($this->privileges);
	}	
	
	function ReturnGroupId(){
		return $this->group_id;
	}	
	
	function Privileges(){ //uses the user id carried in the session
		$user_id = $this->id;
		//echo $user_id;
		if (strpos($_SERVER['SERVER_NAME'],"snowdogweb")){
		$user="seth";
		$pass="newguy";
		$datasource="heavy_duty";
		$server="localhost";
		}else{
		$user = "hdldba";
		$dbase_user="hdldba";
		$pass="";
		$datasource = "hdlighting_";
		$server="localhost";
		}

		$dbase_user = mysql_connect($server,$user,$pass);
		mysql_select_db($datasource, $dbase_user);
	
		$query_results = mysql_query("SELECT access.control, access.has_access from users LEFT JOIN groups ON (users.group_id = groups.id) LEFT JOIN access ON (groups.id = access.group_id) WHERE users.id='$user_id' and access.has_access", $dbase_user);
	
		$this->privileges =  array();
		
		while($row = mysql_fetch_row($query_results)) { 
			$this->privileges[$row[0]] = $row[1];
			$parts= explode(".",$row[0]);
			if(!array_key_exists($parts[0],$this->privileges)){
				$this->privileges[$parts[0]] = 1;
			}
		} 

	}
	
	function HasAccess ($the_control){ //checks to see if user has access to control
		if(array_key_exists($the_control, $this->privileges)){
			return true;
		}else if($this->group_type == "master"){
			return true;
		}else{
			return false;
		} 
	}
	function GetId(){
	
		return $this->id;
	}

	function GetName(){
		return $this->name;
	
	}
	
} 
 ?>

Open in new window

0
 

Author Comment

by:brucegust
ID: 38770572
BTW: The $pass variable has been intentionally omitted.
0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 38770592
Sigh.  

Please see lines 21-30 of the code snippet in the post at http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/Q_27993208.html#a38770066.  This shows that the $control variable is set in the HTTP request - either POST or GET.

This latest block of code looks like an ancient relic of the PHP4 days.  It really needs to be refactored.  The problem might be in the code or the data -- and without any error checking or data validation, you can't know.  The queries could be failing, or even running but finding no data, and there is no useful error-data visualization.

This is a "start-over" project, not a question with any good answer.  If you want to continue to work on this thing, start by using var_dump() to print out the contents of all of the objects and begin your learning adventure there.
0
 
LVL 33

Expert Comment

by:Slick812
ID: 38770627
I should have said this before, but if you are fixing (debug) code (not your code), For me I usually work in reverse, I take the old code and use comment
/*
$oldCode = getV($old);
if ($oldCode == 0) echo 'oldCode is Zero';
moreOld(44);
*/

to remove as much as possible of the old PHP to see what the HTML output will be, or errors.
The un-comment One section of php code to see what HTML output has been added (or changed) and errors. As you have many sections in this php code, this may be somewhat limited.
Because of this line -
<?php include "login_script.php"; ?>
I would guess that this is the FIRST page presented to a browser so the user can "Log-In"
if this is First page then there are NO SESSION values preset ($__session empty) ? ?
so things like -
$_SESSION['color_01']  may not have a value (unset) ? ?
no where is $_SESSION['color_01'] set to value in this PHP (did a search).

Looked at the   class SystemClient{   code, no where is there a SystemClient Object created, as -
$_SESSION["SystemClient"] = new SystemClient($user);

so if that object is initialized, it's not in that code.
Although there is a Table colunm named 'control, in access, I do not see any direct application of that (object value to $control variable) in the page code, the only place where control is set is -
$control="main.null.null";  (I am assuming that there are NO POST or GET for this page).


Sorry for you man, but there does not seem to be much hope of unwinding and fixing this, except to start with ZERO php code and code it from the start,
you don't even sound as if you are sure of what HTML display this page is suppose to have, ,  to be correct and fixed?
0
 

Author Comment

by:brucegust
ID: 38770767
I'm wondering if I'm even connecting to the database. I've tried several "print" configurations and I'm not able to get anything.

On the index page, on line 98 you have this:

	<?php
					$name=$_SESSION['SystemClient']->GetName();
					if (strpos($_SERVER['SERVER_NAME'],"localhost") && trim(strtoupper($name))=="MASTERa  CONTROL"){
						echo "width=\"1\"";
						echo $name;
					}?> 

Open in new window


I do an "echo $name;" and I get nothing.

How can I determine if I'm making a legitimate connection to the database?

class SystemClient{
 	
	var $id, $name,$username,$email,$privileges,$group_type,$group_id;
	
		
 	function SystemClient ($user_id){
		if (strpos($_SERVER['SERVER_NAME'],"snowdogweb")){
		$user="seth";
		$pass="newguy";
		$datasource="heavy_duty";
		$server="localhost";
		}else{
		$user = "hdldba";
		$pass="";
		$datasource = "hdlighting_";
		$server="localhost";
		}
		
			
		$dbase_user = mysql_connect($server,$user,$pass);
		mysql_select_db($datasource, $dbase_user);
		
		$query_results = mysql_query("SELECT users.id,users.first_name,users.last_name,users.m_inital,users.email,users.username,groups.type,users.group_id from users LEFT JOIN groups ON users.group_id = groups.id WHERE users.id='$user_id'", $dbase_user);
		print_r($query_results);
		$data = mysql_fetch_array($query_results);
		//print_r($data);
		$this->id = $data["id"];
		$this->name = $data["first_name"] ." ". $data["m_inital"]  ." ". $data["last_name"];
		$this->username = $data["username"];
		$this->email = $data["email"];
		$this->group_type = $data["type"];
		$this->group_id=$data["group_id"];
	}

Open in new window

0
 
LVL 33

Expert Comment

by:Slick812
ID: 38771082
You ask questions about this SystemClient  Class, , as I said I do not see any code that uses that class to create an object as -
$_SESSION["SystemClient"] = new SystemClient($user);

So if in the  login_script.php or other php file include, where it creates this object, you might do better there for research in how this code works for the SystemClient  Class.

if you modify the SystemClient  Class code as -

$dbase_user = mysql_connect($server,$user,$pass);
if ($dbase_user) echo "SC initialization has a Connect"; else echo "ERROR : SC initialization has NO Connect";

but that may cause problems if the HTML output is before the session_start();

you really should place Debug code outside of IF tests

 if (is_object($_SESSION["SystemClient"])) echo "session has Object<br>"; else echo "ERROR : session has NO object<br>";
$name=$_SESSION['SystemClient']->GetName();
echo 'GetName() return= ',$name;

lookin at this I would start with somethin like this -

<?php
error_reporting(E_ALL);
ini_set("display_errors", 1);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><title>Testing CMS</title>
</head>
<body>
<?php
include('systemclient.inc');
$sc = new SystemClient('does not matter');
$n = $sc->GetName();
echo 'GetName() return= ',$n,'<br />';
// do other test code for SystemClient here. maybe
echo '<pre>';
var_dump($sc->privileges);
echo '</pre>';
?>
<div>
<?php include 'main.php'; ?>
</div>
</body></html>

Open in new window


just to start some where with the first basic,
THis is some kind of CMS according to the title , so that CMS code may make this more of a challenge? this also has some Includes for a gallery and PDF , but I see nothing in the code about a gallery (images) and PDF, so why are they included??
0
 
LVL 108

Accepted Solution

by:
Ray Paseur earned 250 total points
ID: 38772230
I'm wondering if I'm even connecting to the database. I've tried several "print" configurations and I'm not able to get anything... I do an "echo $name;" and I get nothing. How can I determine if I'm making a legitimate connection to the database?
Please read this man page link.
http://php.net/manual/en/function.var-dump.php

Next please read this man page link.
http://php.net/manual/en/control-structures.if.php

When you put any piece of code inside an if() control structure there will be times when the evaluated expression (the part inside the parentheses) returns FALSE.  When that happens, the code inside the control structure {the curly braces} will not be executed.  Example: you'll look at the code and see an echo statement, but when you run the code, no browser output will be produced.  

You can use var_dump() to make the variables visible.  Do not use echo; use var_dump().  These instructions produce different output, and you want the output from var_dump().  The most important variables are the ones that get used in the evaluated expression of the if() statement, since these are the variables that control the logic flow in the script.
0
 

Author Comment

by:brucegust
ID: 38780865
The error turned out to be two columns that were incorrectly named.

I had imported the database from saw raw mysql files and some things got misspelled in the process.

And now we're running just fine...
0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 38781034
Great!  Thanks for the points and good luck with your project, ~Ray
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Both Easy and Powerful How easy is PHP? http://lmgtfy.com?q=how+easy+is+php (http://lmgtfy.com?q=how+easy+is+php)  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now