Jump to content

gizmola

Administrators
  • Posts

    5,945
  • Joined

  • Last visited

  • Days Won

    145

Everything posted by gizmola

  1. To do this for a specific game... for this example, I'm going to use gameID = 5. You would need to provide the right GameID for the game in question. SELECT gamerID, count(*) as countof FROM yourtable WHERE gameID = 5 GROUP BY gamerID ORDER BY countof DESC LIMIT 3
  2. When you call move_uploaded_file, just specify the name you want the file to have in the destination parameter along with the path.
  3. You'll have to provide more specifics about the table and what you are after. Count is a summary operator, so when you say: "3 highest counts" that is confusing. 3 Highest counts of what? The only way you will get more than one count() is if you are grouping the rows in the table on some set of columns using GROUP BY.
  4. We need to know more about what problem you are having. You should remove the @ symbol from the front of the functions you are calling, as they suppress ordinary error handling.
  5. You have 2 options that I can see. The first is to change your Series table so that it includes a "LastAirDate" column that has the date of the most recently aired episode for that series. This could be kept up to date with a trigger or with your frontend code, whenever you do an INSERT into Episode. At that point, you simply join Series to Episode on seriesId and order by LastAirDate, seriesId, id. You could also create a View that in essence creates this column. Based on the names you provided: CREATE VIEW series_view as SELECT s.seriesId, MAX(date) as lastAirDate FROM Series s JOIN (Episode e) ON (e.seriesId = s.SeriesId) GROUP BY s.seriesId ORDER BY MAX(date) desc; Once the view exists, it's just like a table, so you can join Episode to it, and do the order by you need for the result set you wanted SELECT v.seriesId, v.lastAirDate, e.id, e.date as aired FROM series_view v JOIN (Episode e) ON (e.seriesId = v.seriesId) ORDER BY lastAirDate desc, e.seriesId, e.id;
  6. The type of data you're inserting needs to match the datatypes of the columns in your table definition. With that said: "INSERT INTO user (username,password,email) VALUES ($name, $pass, $email)"; Is clearly wrong, assuming that username, password and email are char or varchar columns. You need quotes around these in the VALUES statement. "INSERT INTO user (username,password,email) VALUES ('$name', '$pass', '$email')";
  7. Perhaps it's because XP is not a server platform? Your ping test clearly shows that the machine itself has to wake up out of some sort of network slumber. Is it possible that you have not disabled all the power management settings and some or all of the machine is going to sleep? That might explain why it seems to have to wake up, but once it does it's ok. In all seriousness though, if this is in anyway important to the company, you ought to have it running on a real server operating system -- either a windows server, linux or bsd etc.
  8. Joomla has easily 10 or more man years invested in its design, not counting the scores of plugins, modules and templates. The same could be said for some of the other leading CMS/blog packages like Drupal and Wordpress. There is actually a substantial learning curve involved in any of the CMS packages, however they also were designed to let people with no programming exprience add content and do some rudimentary management of their websites. It's also good old php code so you can look at it and learn a lot about php by picking it apart, looking at plugins or templates or modules, and you can always write your own. If you're just learning PHP however, a lot of that code might be over your head. I don't think there's a right answer, although writing your own system is always a great learning experience.
  9. Did you read the directions for configuration of phpMyAdmin? There is a config file that has settings you need to make that controls things like what server it connects to, what administration user to use, and how you want to authenticate (or not) users.
  10. These guys make some excellent low cost templates: http://www.joomladesigns.co.uk/ Their themes have administration systems so you can learn a lot from them. If you do buy one, I'd recommend going the extra bucks for the template club so you can get support from them in their forums. Also if you google for joomla free templates (in Joomla parlance, they call the site skins templates rather than themes), you might have better luck. Look in K2 for your blog as it has some really nice enhancements -- things like nested categories and tags, as well as user defined fields. The Joomladesigns guys have built in support for K2 in some of their templates as well. Even base joomla will handle the groups security, but if you do use K2, you get a built in user system that also works fine for what you describe. As for links you have a couple of options. Search through extensions.joomla.org for links modules. One that might work for you is: http://extensions.joomla.org/extensions/directory-a-documentation/weblinks/11971 The other option is to use K2. Again because K2 is a CCK (custom content kit) implementation, it's ability to allow you to define special fields, not to mention being able to handle the nested category means that it gets used by sites that need to provide customized directories a fair bit from what I've seen. The page title gets set programmatically. If you use K2, each article title will become the page title. Otherwise, since menus control navigation, the setting of an individual page title for a menu item can be set when you edit that menu item. Open up the Parameters (System) tab on that screen and you can edit it there. Same goes for any other pages you want to override defaults for.
  11. gizmola

    MySQL queue

    I'm not sure your code will still require any selects, but you did have this: "UPDATE `".$d_userinformation['username']."-".mysql_real_escape_string($_GET['type'])."s` SET since='".mysql_real_escape_string($since)."',lastclick='".mysql_real_escape_string($lastclick)."',clicks='".mysql_real_escape_string($values[3])."',average='".mysql_real_escape_string($average)."',lastimport='".mysql_real_escape_string(date("Y-m-d"))."',status='active' WHERE name='".mysql_real_escape_string($values[0])."'" So in that case your WHERE name='some name' query, you want the "name" column of that table to have an index on it. Indexes can be setup either using the KEY statement when you create the table or with a seperate CREATE INDEX statement.
  12. As your traffic increases, apache will need to fork child processes, so apache itself will take up memory. There will be a pool of these child processes and they will use up whatever chunk of memory needed to be allocated to run the php script. To say that PHP doesn't use up much memory, is highly dependent on what your scripts are doing. You can minimize this by getting apache down to as lean a footprint as possible, but it can still be significant. I've worked on apps where even when we did a lot of memory footprint optimization we still had 30-80mb child processes. These get cycled through and killed after a bit, but it's not unusual that you'll have a script that uses a lot of memory and that stays in the child pool to service other requests. For this reason a lot of people use minimal servers to serve images and javascript and other static resources. At any rate, the more traffic you have, the more memory apache will eat up. As for memcached, the main reason people use it is because it is a distributed cache that they can add new machines to as load rises and the size of the dataset increases. You'd do just as well to optimize the database cache if you're just going to invest in a machine that has a bunch of memory for cache in my opinion. For a small web cluster that you're just starting up with, I would still recommend that you have webserver + memcache for every frontend you need.
  13. Oops, yeah I glossed over that, although javascript has regex as well. You can setup a regexp object and then you call string.match(). There's a bit more to it, but it still comes down to a simple regex should work fine.
  14. It's in a php script so it's already protected in that it wil be parsed by the php interpreter. Also what mjdamato suggests is a good idea if you can manage it, however, again, being a php file, it will already be parsed, so executing it by itself isn't an issue. It's a good idea to make sure that the file is not writeable. to mjdamto's point, there is always a concern that running a single script might leak information or leave things in an inconsistent state. Some applications will use a global variable or constant to further protect scripts so that even though they are in webspace, they can't be executed out of context. For example, in their main/bootstrap script they might set a constant : define('MYAPP', true); Then in their include files they'll add at the very top: if (!defined('MYAPP')) die ('Not authorized.'); For the most part, simple initialisation scripts are not a major concern. Most frameworks utilize an initialization class and registry class to read in needed configuration variables and then to make them available in an application registry. Take a look at Zend_Config and Zend_Registry for examples of this. If you can do what mjdamato suggest then I would certainly do that, although on some host accounts you're somewhat limited as to where you can put files that can be seen by apache.
  15. I'm with btherl about beefing up your error checking. In terms of debugging, put an echo or var_dump() for every variable that gets filled by a function call, so that you are sure of what the parameters are before the function is called, and then what the return value contains.
  16. gizmola

    MySQL queue

    PFMaBiSmAd gave you great advice. The one thing you need to keep in mind is that if you are going to be doing a query using a WHERE column that specifies a column, like in your example 'name' then you need to have an index on that column for performance reasons, or the query will need to tablescan through looking at every row for matches of name. Also when you do inserts, you can batch them by repeating the values as he alluded to. This is a lot more efficient for the database when compared to individual inserts. INSERT INTO foo (name) VALUES ('apple'), ('banana'), ('pear') etc
  17. gizmola

    MySQL queue

    Why are you creating tables all the time?
  18. Yes, a regex would work great. Do you know about the "or" operator? For example (Hi, im |Name: )(.*) Try preg_match().
  19. Yes... that is the code that does the redirect. This code is executed inside the code after a login. You asked why it goes to showcategories.php and that is the reason.
  20. Did you look at this code in login.php? if($_SESSION['session_templateselectedfromindex']=="YES"){ Header("location:sitemanager.php"); }else{ Header("location:showcategories.php"); } } else {
  21. You gave us just a small snippet of code, so there's not much help we can give. You have a bunch of functions/classes that are unexplained, and variables like $user. Starting with that, what does $user contain prior to your $fbi = $facebook->api($apiGet)? After that call, what does $fbi contain? Then you do: $db->insert('users',$iArray,$iString) Apparently you have some wrapper class. What does $iArray and $iString contain prior to this method call. Is this method successful or are there errors generated, and how would you know it there were?
  22. Yeah, but what is your goal here. You have an ascii string in your example. Are you just trying to obfuscate the data? You could convert to base64 or something like that if you wanted to accomplish that. Usually people use these functions because they have to move data back and forth from php and some application that has a specific data format.
  23. In my opinion, the best solution if you have are deploying to linux and you have a workstation with adequate computing power and memory, is to run virtualization -- in the past I used Vmware, but the last few years I've been running sun's free Virtualbox. I have a complete howto on setting up Centos, but I've setup other distros, most recently debian. http://www.gizmola.com/blog/archives/blog/archives/95-Run-a-Centos-Lamp-development-server-on-XP-using-VirtualBox.html http://www.gizmola.com/blog/archives/97-Centos-Virtual-LAMP-server-Part-II.html Lots of advantages --- you can run the same environment as your server, you can run multiple VM's and simulate complex multi-server deployment environements, and best of all, you don't pollute your workstation with a bunch of software and services. When you want your development server(s) you start up your VM, when you don't want it, shut em down.
  24. Your first bottleneck will be lack of memory. In my opinion the micro instances are not designed for web servers or caching servers -- they are designed for people who want to run computation clusters. In my experience standard instances are the minimum you want to go with for a lamp server. Secondarily, I would suggest that you plan to run memcached on every webserver. That way there's a good chance that the web server will get the data it needs from memory on the same vm, rather than having to go out through the network and get the data from what could be another machine.
×
×
  • 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.