Jump to content

3raser

Members
  • Posts

    815
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

3raser's Achievements

Advanced Member

Advanced Member (4/5)

4

Reputation

  1. Here is a picture of what I'm working with: http://puu.sh/1nlwf Any idea why it sorts decently, but when it gets down to the seconds - it doesn't seem to be right. It is an array and each key is a timestamp (time()[/time]). I then call: //now sort them krsort($list, SORT_NUMERIC); On my array (list). Any ideas?
  2. I'm creating a list that shows all of a user's recent posts and threads. I want to have all the threads/posts mixed together in one list, all descending by their dates (decided to go with dates and not IDs). E.g: Newest [THREAD] Oct/11/12 Oct/10/12 Oct/8/12 ..and so on [THREAD] [THREAD] Latest
  3. It's hard to explain. I want the results combined, then ordered. I don't want a "segregated" list.
  4. Each table has the field id. Is there any way to do something below (code provided doesn't work): SELECT threads.id,threads.title,posts.id,posts.thread FROM threads, posts WHERE threads.username = ? AND posts.username = ? ORDER BY `id` DESC
  5. I have several units (days, weeks, years) I'd like to add to the current date in MySQL. How would I go about doing this? I tried: ADDDATE(CURRENT_DATE(), INTERVAL {$length[0]} YEAR INTERVAL {$length[1]} MONTH INTERVAL {$length[2]} WEEK INTERVAL {$length[3]} DAY) But doesn't work. Can you even add multiple intervals?
  6. I have index.php: http://paste2.org/p/2394784 And then I have a file called post.php - Is there any way to get the file from the input field in index.php to go through the AJAX request? I attempt something like so: when the file is selected in the html field, set the var file equal to it image.change(function(){ extension = image.val().split('.')[1]; if(extension != 'png' && extension != 'jpeg' && extension != 'bmp' && extension != 'gif'){ image.val(''); displayError('#image', 'That file extension is not allowed.'); }else{ file = this; } }); Then when the user is done, and they click submit - send the file through POST: $.ajax({ type: "POST", url: "post.php", data: { t: title.val(), c: content.val(), image: file} }).done(function(msg) { alert(msg); if(msg != "success"){ split = msg.split(','); displayError(split[0], split[1]); }else{ alert(msg); } });
  7. Ah, thanks. Fixed that. I've also gotten everything to work: however, it still doesn't seem to support multiple lines. Any ideas?
  8. I've checked all variables, and they are set correctly. However, no matter what - I can't seem to get the following line of code to actually replace the [donator][/donator] pattern with the contents within it. input [donator] this is a test[/donator] //show content within [donator] tags only to donators $content = preg_replace('#\[donator\](.+?)\[\/donator\]#im', (($user->isDonator($user->getUsername($_COOKIE['user'], 2)) || $rank > 1) ? '<div class="donator_only">$1</div>' : null), $content);
  9. \w(.+?)@\w(.+?)\.\w(.+?) Is my RegEx to verify someone has their email in the correct format. It always leaves off the last letter, however. Any idea? Example: input: test@gmail.com matched: test@gmail.com (notice m is not matched)
  10. Sorry about that <?php class server{ protected $database; function __construct(){ self::$database = loadClass($database); } public static function loadClass($class){ if(self::$class == null){ if(file_exists($class.'.php')){ include($class.'.php'); self::$class = new $class(); }else{ self::throwError('class '. $class.' does not exist'); } }else{ self::throwError($class. 'already loaded.'); } } public static function dropClass($class){ self::$class = null; } public static function runMethod($class, $method, array $params = array()){ if(self::isLoaded($class)){ if(count($params) != 0){ $par = ''; $i = 1; foreach($params as $key => $value){ $par .= ($i == count($params)) ? $method : $method.','; $i++; } } self::$class->$method(($par != null) ? $par : null); }else{ self::throwError($class .' is not loaded.'); } } protected static function isLoaded($class){ return (self::$class == null) ? false : true; } protected static function throwError($error){ die('<link rel="stylesheet" href="css/error.css" media="all" /><div class="error"><img src="img/error.png" width="45" height="40"><br/><h4>Error!</h4><div class="err_msg">'. $error .'</div></div>'); } } ?>
  11. The below function worked just fine when it was in a non-static format. However, whenever I put it into static format and called the function this error was generated: Fatal error: Access to undeclared static property: server::$class in C:\wamp\www\rsplaypages\structure\server.php on line 11 Any idea whay self::$class isn't working? public static function loadClass($class){ if(self::$class == null){ if(file_exists($class.'.php')){ include($class.'.php'); self::$class = new $class(); }else{ self::throwError('class '. $class.' does not exist'); } }else{ self::throwError($class. 'already loaded.'); } } Thanks.
  12. I'm going for the most efficient setup I can get for my MySQL structure. Would you recommend making the field type of "lastlogin" (the last login for a user) a timestamp or date? Thanks.
×
×
  • 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.