Jump to content

Monkeymatt

Members
  • Posts

    35
  • Joined

  • Last visited

    Never

Contact Methods

  • Website URL
    http://monkeymatt.net/

Profile Information

  • Gender
    Not Telling

Monkeymatt's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. PHP is a scripting language and does not go through and replace constants first like pre-processor directives. To do such a thing, you would have to do it this way: $CONNECT="odbc_connect"; ... $this->con=$CONNECT($this->dsn,$this->uname,$this->password) or die(odbc_errormsg());
  2. You used include() wrong, as kenrbnsn said. You can do what I think you want to this way: [code] <?php $somenumber=file_get_contents("01-25-2007.txt"); $formatted=number_format($somenumber); echo "$formatted"; ?> [/code] Monkeymatt
  3. 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
  4. 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
  5. Just use debug_backtrace() to see what the line number and such were at the function call. http://us3.php.net/manual/en/function.debug-backtrace.php Monkeymatt
  6. 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
  7. 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
  8. From http://php.net/date: [quote] I (capital i) Whether or not the date is in daylight saving time 1 if Daylight Saving Time, 0 otherwise. [/quote] Monkeymatt
  9. 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
  10. [code] $plusone=$row_Recordset1[id]+1; $minusone=$row_Recordset['id']-1; [/code] The way you are doing it changes the actual value of the variable after its value is assigned to the new variable. The better way to do it is the way I have. Monkeymatt
  11. when you mysql_fetch_assoc($result) of that query, you should get values that look similar to theirs - array keys are Table, Op, Msg_type, and Msg_text, and array values are the other values in the table. Monkeymatt
  12. You [b]can[/b] assign $variable4, $variable5, $variable5, etc inside a loop: [code] $num=5; // number of variable(num) to extract for ($i=1;$i<=$num;$i++) {     $go="variable".$i;     $$go=$_POST[$go]; } [/code] http://us2.php.net/manual/en/language.variables.variable.php Monkeymatt
  13. 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
  14. Here's an example for 50 words: [code] <?php $temp=explode(" ", stripslashes($row['cmnts']), 51); // 51 is 50 words +1 (extra words) array_pop($temp); // remove extra words from end $text=nl2br(implode(" ", $temp)."..."); // add spaces back in and add '...' ?> [/code] Monkeymatt
  15. 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
×
×
  • 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.