Jump to content

boralyl

New Members
  • Posts

    5
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

boralyl's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. This may help... If instead of calling $albums->Album_id->equals(5); I call addWhere directly such as $albums->addWhere('Albumi_id = 5'); The $this->whereConditions holds it's value.  It's calling addWhere from equals in the DataObjectColumn class that it isn't working.  Yet when I check to see what kind of object it is for both addWhere and equals it is the same type of object..Albums.
  2. I would use a salt with whatever hashing algorithm you use.  For example: [code] <?php $password = "bob"; srand( microtime( true ) ); /*Variable initialization*/ $salt_template = "0123456789ABCDEF"; $salt = ''; /*Create a random string with template of length 10*/ for ( $i = 0; $i < 10; $i++ ) { $salt .= substr( $salt_template, rand() % 16, 1 ); } $hash = md5( $password . $salt ) . $salt; ?> [/code] Then to compare it to the plain text.. [code] <?php //The user entered bob which is the variable $password $password = $_POST['password']; //get pw in db $pw = ...from db query... $salt = substr( $pw, -10 ); if(md5($password.$salt).$salt) == $pw) echo 'golden' else die() ?> [/code]
  3. Any pages you use $_SESSION start it off with session_start().  Then you can use variables across scripts.  So on script 1 you can store the array in say $_SESSION['errors'] = $errors;  Then on script 2 you can recall it simply by using the $_SESSION['errors'] variable.
  4. Well loading them into an array is as simple as [code] <?php $find = "SELECT ip FROM table"; $result = mysql_query($find); $ips = array(); while($row = mysql_fetch_assoc()) {   $ips[] = $row['ip']; } //View the ips print_r($ips); ?> [/code] sorry Barand I didn't notice you wrote almost the exact same code
  5. I tried to simplify it, but let me just post all of the major components of the code. First the code used to envoke all of these classes: [code] <?php $q = new Albums(); $q->Album_id->equals(3); $q->debugLevel(2); $q->find(); while($q->fetch()) { echo $q->Album_id.'<br />'; } ?> [/code] The important part of the Albums class: [code] <?php require_once("DataObject.php"); require_once("DataObjectColumn.php"); class Albums extends DataObject { var $Id = null; var $Album_Name = null; function Albums() {     $this->DataObject(); $this->clearObject(); } function clearObject() { $this->Id = new DataObjectColumn($this, 'Id', false); $this->Album_Name = new DataObjectColumn($this, 'Album_Name', true); } ?> [/code] The DataObjectColumn class: [code] <?php class DataObjectColumn { var $column = null; var $requires_quote = null; var $data_object = null; function DataObjectColumn(&$dataobject, $column_name, $requires_quote) {     $this->data_object =& $dataobject; $this->column = $column_name; $this->requires_quote = $requires_quote; } function equals($value) {     $sql = $this->data_object->quoteID($this->column) .' = '. $this->data_object->quote($value); $this->data_object->addWhere($sql); } } ?> [/code] And finally the declaration of vars, constructor and member functions used above I included in the DataObject class [code] <?php require_once("DataLayer.php"); class DataObject extends DataLayer { var $result = null; var $args = null; var $sorts = null; var $whereConditions = null; var $selectDistinct = false; var $debugLevel = 0; var $test = 0; function DataObject() {     $this->DataLayer(); $this->args = array(); $this->sorts = array(); unset($this->result); }                         function quote($data) { if(!is_object($data)) return '\'' . mysql_real_escape_string($data) . '\''; else return '\'' . mysql_real_escape_string($data->data_object) . '\''; } function quoteID( $field ) { return "`$field`"; }                         function addWhere($sql) {     if($this->whereConditions != null) { $this->whereConditions .= ' AND '.$sql; } else { $this->whereConditions = $sql; } }                   function find() {                              echo $this->whereConditions; ?> [/code] Now when I echo that variable it is null.  Even though if you echo it in addWheres it has the value of 3.  The DataLayer class just opens up a link to the database.  Any ideas as to what I am doing wrong?
×
×
  • 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.