+ Reply to Thread
Results 1 to 3 of 3

Thread: I need help.

  1. #1
    Shadow121's Avatar
    Shadow121 is offline x10 Lieutenant Shadow121 is an unknown quantity at this point
    Join Date
    Jul 2006
    Location
    Centerville
    Posts
    455

    I need help.

    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.

  2. #2
    hexusff is offline x10Hosting Member hexusff is an unknown quantity at this point
    Join Date
    Sep 2008
    Posts
    9

    Re: I need help.

    I've never used that library but apparently your declaration is wrong, the line
    PHP Code:
    $Registry registry::singleton(); 
    Should be something like
    PHP Code:
    $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 Code:
    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 Code:
    $sql "SELECT * FROM table WHERE " assembleConstrains(array("userID" => 1,"userPass" => 123 )); 
    Last edited by hexusff; 10-22-2008 at 08:49 AM.

  3. #3
    Shadow121's Avatar
    Shadow121 is offline x10 Lieutenant Shadow121 is an unknown quantity at this point
    Join Date
    Jul 2006
    Location
    Centerville
    Posts
    455

    Re: I need help.

    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.

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers