I need help.

Shadow121

Member
Messages
901
Reaction score
0
Points
16
I have my config file set-up like so:
Code:
<?php
session_start();
require(/*$_SERVER['DOCUMENT_ROOT']*/"/home/xxxxxx/public_html/joe_new/FileLibrary/Classes/registry.class.php");
$Registry = registry::singleton();
$Registry->storeCoreObjects();
$Registry->getObject('db')->__Connect('localhost','user',pass', 'db',false,true);
define('DB_PREFIX', 'cdev_');
$Registry->getObject('db')->ShowErrors = true;
$logged = $Registry->getObject('db')->fetchArray($Registry->getObject('db')->sqlQuery("SELECT * FROM `".DB_PREFIX."users` WHERE `username` = '$_SESSION[username]' AND `password` = '$_SESSION[password]';"));
$settings_query = $Registry->getObject('db')->sqlQuery("SELECT * FROM `".DB_PREFIX."settings` WHERE `id` = '1';");
$settings = $Registry->getObject('db')->fetchArray($settings_query);
print_r("Settings: ".$settings);
die();
?>

When I go to my site it just shows Settings: when i try to var_dump(); it says null. Any help?

Also,

I have a security questions type thing and I want to know how to submit an array as from a series of textboxes then read, and compare them to the answers in MySQL.
 

hexusff

New Member
Messages
9
Reaction score
0
Points
0
I've never used that library but apparently your declaration is wrong, the line
PHP:
$Registry = registry::singleton();
Should be something like
PHP:
$Registry = new registry();

Your line is executing a static function called singleton from the class registry. What you need is to declare an instance of the class registry because you're calling methods of that class when using the -> operator.

Edit:
For the security, maybe some function to assemble the SQL constraints for that behavior.
A simple function that comes to me now is:
PHP:
function assembleConstrains($array = array())
{
	//we will receive an asociative array
	$flagForAnd = false;
	$returnValue = "";
	foreach ($array as $name => $value)
	{
		$value = str_replace("'","´",$value); //this line is to prevent SQL injections
		if ($flagForAnd)
		{
			$returnValue .= " AND";
		}
		$flagForAnd = true;
		$returnValue .= " " . $name . "='" . $value . "'";
	}
	return $returnValue;
}
That should be called like
PHP:
$sql = "SELECT * FROM table WHERE " . assembleConstrains(array("userID" => 1,"userPass" => 123 ));
 
Last edited:

Shadow121

Member
Messages
901
Reaction score
0
Points
16
I'm creating my own framework type thing and in the Registry class i have storeObject(class name, key) and getObject(key)

But, I'll try that.

The singleton is so no one else can duplicate the class from off-site.
 
Top