Jump to content

Alex

Staff Alumni
  • Posts

    2,467
  • Joined

  • Last visited

Everything posted by Alex

  1. This is no longer a PHP Coding problem so instead you should head over to this forum and create a topic about your problem describing what you've attempted to do and the errors you're receiving.
  2. I still have a game cube and tons of games for it, but I haven't touched it in a while. I got it about 7-8 years ago and loved it when it was new.
  3. You need to use double quotes because single quotes do not have variable interpolation. And just to nitpick, you're creating a table, not a database. $query = "CREATE TABLE $newdbname ( user_id int(30) NOT NULL AUTO_INCREMENT, username varchar(20) NOT NULL, password varchar(41) NOT NULL, PRIMARY KEY (user_id) ) ENGINE=MyISAM";
  4. Please don't bump topics that are several months old; instead just make a new one.
  5. You can just use date_default_timezone_set to set a timezone and everything will be adjusted for you. If you want to do it manually your way you'll have to take the current time and add one hour. What you supplied date with was 1 hour past January 1st, 1970. date("Y-m-d H:i:s", time() + 3600);
  6. Just Google "AJAX Tutorial" and you'll get plenty of results. Here's a good one from w3schools: http://www.w3schools.com/ajax/default.asp
  7. Are you sure it's even getting to the part where the query is executed? If it is, you should print out of the query to make sure it contains what you expect.
  8. Please don't create multiple topics for the same issue. Just posting the additional information in another post within the same topic is completely fine. I've merged the two topics for you.
  9. Which part isn't working? What's the output you get? Any errors? You haven't provided enough information.
  10. Alex

    Questions.

    Yes, as long as that's in double quotes (as single quotes do not have variable interpolation). "/^$string$/"
  11. You might want to check that you're not doing something else wrong somewhere else. The supplied code works fine for me.
  12. What does the formula look like in excel?
  13. To be honest, I'm not really sure what you're trying to do. But ^ is a bitwise operator; if you're trying to use exponents you need to use pow.
  14. You need to have the GeoIP extension installed.
  15. This topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=308349.0
  16. AJAX can request a PHP file and the PHP on it will execute, so yes.
  17. It would be much easier to use an array and do it like this: function mythings($id) { if(!isset($_SESSION['items']) { $_SESSION['items'] = array($id); } else { array_unshift($_SESSION['items'], $id); if(sizeof($_SESSION['items'] > 6)) { $_SESSION['items'] = array_slice($_SESSION['items'], 0, 6); } } } And then to print it out: foreach($_SESSION['items'] as $key => $item) { echo "Item " . ($key + 1) . ": " . $item . "<br>"; }
  18. You don't need to use that AJAX method unless it's necessary that stats are updated that fast, which in most cases it's not. You can just set the timeout to something like 5 minutes. Every time the user requests a page store the time of that request. If the last time they visited the page is over 5 minutes (or whatever you set your timeout value to be) then you can assume they're offline.
  19. That can be simplified and made a bit cleaner. $searchterm = "red blue green"; $sql = "SELECT * FROM `table` WHERE `column` LIKE '%" . str_replace(' ', "%' OR `column` LIKE '%", $searchterm) . "%'";
  20. small update echo $staff[((time()+3*24*3600)/(7*24*3600)) % count($staff)]; Another small update to sasa's solution: The array will need to be ordered like this: $staff = array('Tara', 'Tom', 'Branda');
  21. You can't use PHP like that. PHP is a server-side language. It runs the code, sends the output to the browser and has nothing to do with anything after that. nethnet's solution is much better (it actually works ).
  22. Right, I did that on purpose knowing that Tara is thier most competent person. I deduced that the company would liek to end the year on a high note and start the year off running. Ha, good one
  23. I was assuming he meant before it's uploaded to a more permanent place on the server. Most of the time when talking about this kind of thing people don't consider a file in a temporary folder to be uploaded, although technically it is.
  24. mjdamato, there's a small problem with your code. I ran into the same problem which is why I have this: (date('W') == 1) ? 2 : date('W') So that if it's the first week of the month it uses 2 instead of 1. Otherwise you run into a problem where Tara is assigned for the last week and first week of the year. This only happens because 52 % 3 is the same as 1 % 3. Example output in your script from that point: [December 29, 2010] => Tara [January 5, 2011] => Tara
  25. Also known as the ternary operator. You can read more about it on this page: http://php.net/manual/en/language.operators.comparison.php (scroll down to "Ternary Operator").
×
×
  • 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.