Jump to content

Monkeymatt

Members
  • Posts

    35
  • Joined

  • Last visited

    Never

Posts posted by Monkeymatt

  1. I've got this weird error:

    [quote]
    Strict standards: Non-static method Forum::load_many() cannot be called statically, assuming $this from compatible context Forum in C:\Xampp\xampp\htdocs\ekinboard\v2\class\database.class.php on line 184
    [/quote]

    Here is line 184:
    [code]
    $this->has_many_data[$name]=call_user_func_array(array(self::$has_many[$this->class][$name]["class"], "load_many"), array(array(array(self::$has_many[$this->class][$name]["foreign_id"],'=',$this->id))+self::$has_many[$this->class][$name]["conditions"], self::$has_many[$this->class][$name]["order"], null, null, null, self::$has_many[$this->class][$name]["class"]));
    [/code]

    Here is Forum::load_many definition:
    [code]
    public static function load_many(array $where, array $order=array(), $in=null, $low_limit=null, $num=null, $class=null) { global $FINAL_CLASS; return parent::load_many($where, $order, $in, $low_limit, $num, $FINAL_CLASS[get_class()]); }
    [/code]

    parent::load_many is here:
    [code]
    public static function load_many(array $where, array $order=array(), $in=null, $low_limit=null, $num=null, $class=null) {
    $return=parent::load_many($where, $order, $in, $low_limit, $num, $class);
    if ($return === false) {
    return $return;
    }
    if ($class == null) {
    $class=get_class();
    }
    $table=self::$tables[$class];
    global $model;
    foreach ($return as $to_save) {
    $model->{$table}[$to_save->id]=&$to_save;
    }
    return $return;
    }
    [/code]

    last parent::load_many:
    [code]
    public static function load_many(array $where, array $order=array(), $in=null, $low_limit=null, $num=null, $class=null) {
    if ($class == null) {
    $class=get_class();
    }
    if (in_array($class, self::$disallowed_classes)) {
    global $error;
    $error->make_error(4, "Attempted to load_many() of '".$class."' which is not allowed");
    return false;
    }
    if (empty(self::$tables[$class]) || empty(self::$id_row[self::$tables[$class]])) {
    global $error;
    $error->make_error(5, "Missing information necessary for '".$class."' to initiate");
    }
    $results=self::$database->select(self::$tables[$class], $where, $order, $low_limit, $num, array('*'), $in);
    $return=array();
    foreach ($results as $resultnow) {
    $temp=new $class();
    $temp->load_array($resultnow);
    $return[]=$temp;
    }
    return $return;
    }
    [/code]

    Any help would be appreciated.

    Monkeymatt
  2. I have a [b]static[/b] function that needs to know the name of the class that was used to call it (waaaaaaay up the inheritance chain). get_class() only gives me the name of the class that the static function is in, but I need the name of the top class that was called. Is there any way to do this.

    Thanks,
    Monkeymatt
  3. A form name with [] after it will automatically fill an array on the PHP page - this could be used with javascript to get a dynamic number of dates.
    [code]
    <input type="text" name="dates[]" />
    [/code]
    would make an array:
    [code]
    $_POST['dates'][0], $_POST['dates'][1], ...
    [/code]

    Monkeymatt
  4. It works for me:
    [code]
    mysql_connect(db_host, db_username, db_password);
    mysql_select_db(db_database);
    $result=mysql_query("OPTIMIZE TABLE `v2_settings`");
    var_dump(mysql_fetch_assoc($result));
    [/code]
    outputs: (I have xdebug enabled)
    [quote]
    array
      'Table' => 'ekinboard.v2_settings' (length=21)
      'Op' => 'optimize' (length=8)
      'Msg_type' => 'status' (length=6)
      'Msg_text' => 'OK' (length=2)
    [/quote]

    Monkeymatt
  5. These lines:
    [code]
    $body2 = "
    Message from $_POST['fullname']

    $_POST['message']

    phone - $_POST['number']";
    [/code]
    Should be changed to something more like this:
    [code]$body2 = "
    Message from ".$_POST['fullname']."

    ".$_POST['message']."

    phone - ".$_POST['number'];
    [/code]

    As you cannot have arrays where the key is a string used inside of a string or PHP complains. It would also help more if you could point out which line is line 32.

    Monkeymatt
  6. What existing class? There is no instance of the class until you create a variable and define it as of that class. There is only a definition of the class. Think of it this way: what we have before we defined a variable to be the class is like blueprints to a house - you know what it should look like and what it will do when it is made, but it is not made yet. After the variable is defined and set to be the class, it is like the house is built and is now there and you can now do things with it.

    Monkeymatt
  7. For the first line, you could set a variable such as this:
    [code]
    $first_line=true; // outside of loop

    // Inside of loop
    if (!$first_line) {
    // Do everything normally done inside of loop on every line
    } else {
    $first_line=false; // next time through will be second line
    }
    [/code]

    As to the last line, you could check if the line with spaces trimmed is empty:
    [code]
    // after you have $line set, and before you do anything else with the line
    $test=trim($line);
    if (!empty($test)) {
    // do normal stuff
    } else {
    // line is empty
    }
    [/code]

    Monkeymatt
  8. On page 2, instead of using $drname, use $_REQUEST['drname'], as $drname will only be set if register_globals is set to on, which it is not in your case due to your problem. Simply make page 2 be this:
    [code]
    setcookie("drname", $_REQUEST['drname']);
    [/code]

    Monkeymatt
  9. You can actually call it like this:
    [code]
    $foo=new Foo();
    $foo->Variable();
    [/code]

    As to not using Foo::Variable(), then it does not have a $this var that is passed to the function, so it will yell at you for referencing $this because it is not defined. Foo::Variable() is for calling static functions that do not require an instance of the class, and cannot reference the current class using $this because there is not current class that it is under.

    Monkeymatt
  10. Your quotes are wrong. This line:
    [code]
    echo '<option value="$player_id">$player</option>n';
    [/code]
    needs to have double quotes or variables concatted for it to insert variable names and not what is literally there:
    [code]
    echo "<option value='$player_id'>$player</option>\n
    [/code]
    or
    [code]
    echo '<option value="'.$player_id.'">'.$player.'</option>\n';
    [/code]

    Monkeymatt
  11. Here is a function from a class I have that will return field names in an array.
    [code]
    function get_rows($table) {
    $result=mysql_query("DESCRIBE `".$table."`");
    if (!$result) {
    echo mysql_errno().": ".mysql_error();
    }
    $return=array();
    while (($array=mysql_fetch_array($result)) !== false) {
    $return[]=$array['Field'];
    }
    return $return;
    }
    [/code]

    Monkeymatt
  12. blear - He said "they don't create folders or anything themselves"

    This can be done with mod_rewrite to turn the url into variables for PHP - look at mod_rewrite, there's even a forum here to explore it.

    Monkeymatt
  13. Are you attempting to put the link in the image tag by simply making a long string with all of the correct values that has the HTML and then dumping that string into somewhere? You need to do it by creating and inserting new elements using the javascript function and then add urls and such:
    [code]
    var img=document.createElement("img");
    img.src=image_url;
    // then insertBefore or insertAfter into the main area
    [/code]

    Monkeymatt
  14. Instead of calling set_size(), you need to call $this->set_size(). You need to let it know that you are calling the function from this case of the class.

    Also, how are you getting the filesize to $this->size, as set_size() simply calls filesize(), but does not put the value in the variable $size. I think you would need something more like this:

    [code]
    function set_size() {
        $this->size=filesize($this->file_name);
    }
    [/code]

    Monkeymatt
  15. It appears that the directory walking is messing up - it should only be reading the files/directories that are not '.' or '..' (current or previous directory). This one is continously going to the same directory, most likely failing eventually because the path is too long.

    You need to add a check to only walk through the directory when the filename/directory name is not equal to '.' or '..'

    Monkeymatt
  16. I have made a tutorial page with easy to remember urls, that are the categories it is under followed by the tutorial name -- see http://monkeymatt.fusionxhost.com/tutorials/

    Here is the appliciable .htaccess code
    [code]
    RewriteRule ^tutorials/$ tutorials.php?cat_name=Main
    RewriteRule ^tutorials/((([^/]+)/)+)$ tutorials.php?cat_name=$1
    RewriteRule ^tutorials/((([^/]+)/)+)([^/]+)/examples/([0-9]+)$ tutorials.php?cat_name=$1&tutorial_name=$4&example=$5
    RewriteRule ^tutorials/((([^/]+)/)*)([^/]+)/([0-9]+)$ tutorials.php?cat_name=$1&tutorial_name=$4&page=$5
    RewriteRule ^tutorials/((([^/]+)/)*)([^/]+)$ tutorials.php?cat_name=$1&tutorial_name=$4&page=1
    [/code]

    The PHP code then takes the cat names, separates them, and finds the cat id (using all of the cat names allows for categories with same names, just not in the same category). Then it loads the necessary stuff using the names.

    Monkeymatt
×
×
  • 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.