Jump to content

Scooby08

Members
  • Posts

    244
  • Joined

  • Last visited

Everything posted by Scooby08

  1. If I have a table with info like so: id user_id type status created_on 1 1 a pending 2011-02-14 23:26:26 2 1 b pending 2011-02-14 23:26:26 3 1 c pending 2011-02-14 23:26:26 4 1 c pending 2011-02-14 23:26:26 5 1 a pending 2011-02-14 23:26:26 Would there be a way to count the total rows, while making the type 'c' values count as only one row? So really there would be only 4 rows counted here.. Is there something similar to the below out there that could work? SELECT * FROM table WHERE status = 'pending' GROUP BY type = 'c' Thanks!
  2. This is more of a curiosity question.. Could somebody tell me if there are any differences between the following.. They all seem to perform the same for me and I can't find any differences.. .?* (.?)* (.?*) I'm just using it like so: <title>.?*</title> Thanks..
  3. I'm trying to figure out how to put this preg_match line into one: if (preg_match('/<meta name="keywords" content="(.*)?">/im', $file, $match) || preg_match('/<meta name="keywords" content="(.*)?" \/>/im', $file, $match)) { The difference is the closing part of the tag.. either this: > or this: /> How would I do an either or on that part? Thanks
  4. I'm just trying to find out if php has the ability to check if any file exists, with only part of the filename given.. I have this path: if (file_exists($dir.'/'.$c_file.'/templ_*')) { I added a little star.. That star represents whatever the rest of that file is named for this example.. It could be anything.. So can php match any files that start with "templ_", and say that it does or does not exist?? Thanks
  5. I did end up saying that a couple posts ago, but I didn't initially say that because I didn't know what the solution was going to do to the array.. I started with a sort($array) and then ran this function to compare.. The sort ordered them and the function scrambled them again.. Anyways.. Now it works exactly perfect and we even got a few different ways to do the function.. Thanks a bunch mjdamato!!
  6. Well I did finally figure it out.. This seems to do the trick for me: <?php function sortUnderscoreToFront($a, $b) { if (substr($a, 0, 1) == '_') { return -1; } if (substr($b, 0, 1) == '_') { return 1; } return strcmp(strval($a), strval($b)); } usort($testArray, 'sortUnderscoreToFront'); ?> It alphabetically sorts all the non underscore values alphabetically while still moving all the underscore values to the front.. It would still need some logic to alphabetically sort the underscore values if wanted..
  7. Yep.. This is working really well, but like you say, I would really like to order the non underscore values.. I'm gonna keep at it, but if you have any ideas I'd love to hear them!!
  8. Well the possible values could be any string without an underscore in front.. There won't always be one with an underscore, but if there is I'd like to move it to the front some how.. The one with the underscore will always start with the underscore.. It will not be in the middle or at the end..
  9. Sample array: array('one','two','three','_zero'); How could I sort this array so that _zero moves to the front.. Any items that begin with an underscore should be moved to the front of the array to get something like so: _zero, one, two, three Thanks
  10. Oh my goodness... Thanks a bunch AlexWD!
  11. If I have code that looks something like this: <?php $t = array('one','two','three','_four','_five','_six'); $u = 'five'; foreach ($t as $v) { if (substr($v,0,1) != '_') { // if begins with an underscore, remove it, unless it is equal to _$u echo $v.'<br />'; } } ?> I am trying to take out all array items that begin with an underscore except the one that is equal to this.. _five something like $v == '_'.$u So what should be echoed is this: one two three _five Is there any way to do this with only an if, and not an if/else?? Thanks..
  12. I'm looking for a simple way to remove the top directory from a path like so: /one/two/1.php Then I would like to remove "/one" so the path would now be like so: /two/1.php Thanks for any suggestions!
  13. Exactly!! Im not doing the second.. I want to call the database throughout the rest of all my files.. Well it doesent even have to be the database.. It is just globals I'm trying to get rid of..
  14. I'm trying to connect to a database using this code below, which works, but I just have a feeling that it is written incorrectly and was hoping someone could point me in the right direction to sorting this out.. <?php class Database { private static $db; private function __construct(){ mysql_connect(DB_HOST, DB_USER, DB_PASS); mysql_select_db(DB_NAME); } public static function instance(){ if (!self::$db){ self::$db = new Database(); } return self::$db; } } Database::instance(); ?> I seem to think my constructor might be written or used incorrectly.. Could anybody give some suggestions?? What I was originally trying to do was avoid the use of using global connections to the database and from what I've been reading I think this might be the right way to go.. Thanks..
  15. I had a query that was selecting the correct data up until daylight savings time a week ago.. Here is it: SELECT * FROM table WHERE (Time_TS BETWEEN NOW() AND NOW() + INTERVAL 24 HOUR) ORDER BY Time_TS Now I need it to select NOW() + 1 hour and I did this: SELECT * FROM table WHERE (Time_TS BETWEEN DATE_ADD(NOW(), INTERVAL 1 HOUR) AND DATE_ADD(NOW(), INTERVAL 1 HOUR) + INTERVAL 24 HOUR) ORDER BY Time_TS My question is can that be written some way to automatically detect when daylight savings is in effect and run the proper query, rather than having to change the code manually when daylight savings hits?? MySQL 5.0.90
  16. Will this help? CREATE TABLE `table` ( `id` int(30) unsigned NOT NULL auto_increment, `column` varchar(10) NOT NULL default '', PRIMARY KEY (`id`) ) This also seems to work: SELECT * FROM table WHERE column != '' Do you see any problems with that?
  17. I have been searching around and found that to select all columns from the database table that aren't empty I would need to use a query like so: SELECT * FROM table WHERE column IS NOT NULL It's not working out for me.. Shouldn't that do the trick?
  18. If I have 2 arrays, one that is my base array, and another that is the item to be removed array, and they are like so: Base array Array ( [0] => 608569 [1] => 608570 [2] => 608571 [3] => 608572 ) Item to remove array Array ( [0] => 608570 ) How would that be done? Is there a simple built in function for that, or do I have to foreach the arrays?
  19. Nice! I think that's working perfectly! I added one thing to get rid of duplicates.. $_SESSION['checked'] = array_unique(array_values(array_merge($_SESSION['checked'], $_GET['new_checked']))); That seems to work.. See any flaws with that?
  20. I'm trying to store an array of checkbox values into a session array, sort of like a shopping cart, but I can't figure out how to not overwrite the sessions array each time new checkbox values are added to the stored session... Here is an array that is created upon submitting with two checkboxes checked: Array ( [0] => 606613 [1] => 606614 ) And then my sessions array is now like so: Array ( [checked] => Array ( [0] => 606613 [1] => 606614 ) ) The code for that so far is this: <?php if (!isset($_SESSION['checked'])) { $_SESSION['checked'] = array(); } $_SESSION['checked'] = $_GET['new_checked']; ?> I know I probably need to add a loop that checks the arrays, but I just can't think how I should go about adding newly checked checkbox values, that are not duplicates, to the *end* of the session array "checked"?? Would anybody care to share some ideas? THANKS!
  21. Thanks so much for the reply gamblor01!! And what a great reply it is.. It covers all that could possibly be wrong! I gotta save this page to refer to for future use in case I run across any other problems.. I am just learning this stuff and did not know that it needed to be enabled on the server.. I had that enabled and it all works great now!! Thanks again!
  22. Hello.. I'm following the steps on this page: http://service.futurequest.net/index.php?_a=knowledgebase&_j=questiondetails&_i=539 If I try this line: ssh -l username host.com I get this error and don't know what to do: ssh: connect to host host.com port 22: Operation timed out I read that my firewall could be blocking port 22, but not sure how to check that out.. I'm on Mac OS X and have my firewall set to "Allow all incoming connections". Could it possibly be something with router settings? Could anybody recommend anything so I can get connected? I know very little about using the terminal and I'm attempting to get a cronjob set up following these steps: http://www.aota.net/Script_Installation_Tips/cronhelp.php4 I'm getting stuck on Step 4 with this problem.. 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.