Jump to content

gizmola

Administrators
  • Posts

    5,945
  • Joined

  • Last visited

  • Days Won

    145

Everything posted by gizmola

  1. The query from the ISP is the "problem query" until the next "problem query". In terms of resources on your server, I have to disagree that you have a cpu problem. More likely what you have is an IO/Memory issue. If I understand correctly, you have a traditional LAMP stack server (Linux, Apache, MySQL, PHP). So out of the entire available memory of the server it is being spread like so: -Some allocation to the OS itself -Some allocation to daemons for the Email server, imap server etc. -Some allocation to MySQL -Variable per process allocation to Apache (the more traffic you have the more this available memory is used). Each apache child in a typical php installation will also need as much memory as the php script needs and this can often be 10's of megabytes per connection. Furthermore if you have a control panel like CPanel, then there is allocation to the apache that supports cpanel. If it was my server, I would run "explain extended SELECT userid,date,photo FROM pp_ipcache WHERE ipaddr='165.152.14.81' AND type='view' AND photo=45042" You can report back to us on that, along with "show create table pp_ipcache" and we will have enough information to tell you whether or not this can be fixed with an index as The Little Guy assumes. With that said, memory is king in most servers, and having a server with 16G is going to give you a lot more headroom before you hit the roof of what sort of load your server can support. Unfortunately along with the memory you also need someone who understands how to configure mysql to take advantage of that memory.
  2. Yes, that is showing you that the query in question, scans the entire table, reading 44310 rows, even though you provide a list of categories, and there is an index on cat that *could* be used. This could be a low cardinality issue, or the choice of the optimizer. Although you aren't in a position to do much else, you can and should run analyze on your tables, on the off chance that the statistics being used by the query optimizer have gotten stale, and the db is making bad decisions to not use certain indexes that could help. Doing database analysis and query optimization is something that requires a technical understanding of the application code, as well as how to read and understand explain plans. With that said, a database that is not overly large will run well, albeit in a non-optimized fashion, if the server has been resourced and configured adequately. In the scheme of things, tablescanning 44k rows, while to be avoided if possible, is not something that should be that big of an issue. You are running apparently on a shared host where the database resources being allocated might not be sufficient to run your system. Again however, you need a pro to help you go through your system, looking at some of the things being discussed (slow query log, report from the hosting company, explain on the individual queries, analysis of the database schema, indexes and queries being executed) if you are interested in having a performant system, that uses resources competently. Unfortunately there is no magic button (other than analyze) you can push.
  3. Yes, isset() returns true and false, not the value of the variable. If you wanted to combine them you would do: if (isset($_POST['unitsize']) && $_POST['unitsize'] == 'string') echo 'checked'; A couple of tips: php alternative syntax is nice for this type of inline mixing of markup and code when all you want to do is echo out a simple value, and the ternary operator is great for replacing if then else logic (even though you don't really need the else here). > 1 bedroom
  4. bugzy, There are any number of mysteries in your code that could account for your problem. -As pointed out, your code may never be reached because we don't see where $id gets a value. In your snippet it looks like it's undefined. -You do a mysql_query, but you do not check that $edit_result is valid. -You call mysql_result, with a row parameter of $i, which we don't see being assigned anywhere. It should be an integer, starting with '0' for the first row in the result set. Any one of these could be the problem.
  5. First off, yes you can use mysql_num_rows() or you can change the query to return a count(*) and check that value. Which you should use depends on what you intend to do with the data you queried. If you are going to fetch the data from the users table and use that in the script, then doing a SELECT * FROM users makes sense. If you only care if you find a matching row, then I would do a 'SELECT count(*) as countof FROM...' instead which will always return one row (so long as the query is valid), and which you can then fetch the value and use that in your query. As for passwords, the best practice is to hash the passwords, using an md5() or sha1() hash. You would also want to add a salt value to the input, but I think that even if you just sha1() the value, that would be great, considering it's an assignment. The idea of a hash is that it can not be decrypted, so when you save a user row, you save the sha1($password) to the password column. Then when you are checking you compare with the sha1($password) of the user input. Here's corrections for your code with the sha1() hashing. $password = trim($password); // Make sure they don't just enter a bunch of spaces. if (!empty($password)) { $password = sha1($password); $qry= "SELECT * FROM users WHERE password='$password' AND username='{$_SESSION['SESS_USER_NAME']}'"; $result = mysql_num_rows($qry); if ($result $errmsg_arr[] = 'Current password is not correct'; $errflag = true; } } else { $errmsg_arr[] = 'Password required'; $errflag = true; }
  6. Yes. $qry = "SELECT * FROM users WHERE password='$password' AND username='{$_SESSION['SESS_USER_NAME']}'"; Of course, insuring that there is a value in SESS_USER_NAME is up to you. I also would want to insure that $password and $_SESSION['SESS_USER_NAME'] have been escaped with mysql_real_escape_string() (assuming you're using mysql).
  7. A cascade of failure: - The script did not find a url parameter named 'id'. - Thus the query is not valid - Thus $result is false rather than a result set - Thus you can not fetch
  8. Yes, just repeat for each question. It is also possible to do this all in one big static definition, but might be harder to maintain, when you want to switch the order of questions, or edit them. Using your example: $questions[] = array('questioniID' => 2, 'questionNo' => 1, 'questionText' => 'Why did you start your own business?'); $questions[] = array('questioniID' => 5, 'questionNo' => 2, 'questionText' => 'What would you recommend that others make sure and do?'); //etc foreach ($questions as $question) { echo "{$question['questionText']} "; } I expect that what you're actually planning to do is display the questions in questionNo order, so what I'd probably do instead is this: $questions[1] = array('questioniID' => 2, 'questionText' => 'Why did you start your own business?'); $questions[2] = array('questioniID' => 5, 'questionText' => 'What would you recommend that others make sure and do?'); //etc Now your questions are automatically ordered: foreach ($questions as $nbr => $question) { echo "$nbr. {$question['questionText']} "; }
  9. I personally believe it is best to target the most specific element you can. In this case all you are trying to change is the image.src attribute. From a pure efficiency standpoint, it is much more efficient for you to return true/false than to return the html for the entire image, and to simply change the .src attribute in your javascript.
  10. $questions[] = array('questioniID' => 3, 'questionNo' => 5, 'questionText' => 'This is question 1'); This assumes of that you will have multiple questions, each of which you'd assign in a similar fashion.
  11. Please, no more caps. Just makes your post harder to read, and will cause people that would otherwise consider helping you to skip your question. Off the top, you do this: $paintFile = fopen("weeklyDataBoles.txt","r"); $year = fgets($weeklyDataBoles); Notice that you open a file and assign the file handle to a variable named $paintfile. Then you try and fgets() from an entirely different variable. Start there.
  12. Ok, so you have presented us with a function, and all we know at present is that is is "not working". Do you have more information than that? Are you encountering an error? If so, what kind? What is dynadot? We need more information if you'd like help with your problem.
  13. There is no performance issue at all. There wouldn't be a performance issue if you had 100x that many questions. You are talking about a really small amount of data, that will be cached, even without the use of additional caching. If you're using innodb the data would be in the mysql server data cache 100% of the time. The execution of the php script itself represents far more overhead. However, these questions are highly academic in most cases. Unless you have a site where you have a reasonable expectation that you will be encountering more traffic than that server can reasonably handle, there is no reason to consider these questions. Functionality, flexibility, potential reuse, and data analysis are all far more important considerations. It's also a really bad approach in my experience to start over thinking problems, and trying to hypothesize your bottlenecks when you don't have substantial real-world experience to point to as a basis for your opinions. Even for experienced people, it's dangerous, because you often find that your performance issues are a moving target, and can only be addressed through monitoring and profiling. In general and as a rule of thumb, one database can front a number of frontend webservers -- 4 or more in my experience, because memory and network bandwidth are the first places you encounter bottlenecks in a web stack. If you do have database bottlenecks, it is typically because your data set has gotten extremely large, or you are trying to have a mix of unoptimized queries or analytical queries that are being run against a server that is at the same time being asked to perform a lot of transactions. These are problems that can be mitigated in various ways, long before you get down to philosophical questions about a database. With that said, we really don't have the salient information needed to provide you advise that is all that worthwhile, because the question is not whether or not database use is "overkill". The real questions are in regards, to what your requirements are, and why you need a Q+A form in the first place. The important questions are: -What requirement are you trying to fulfill -Does that requirement involve a Q+A? -If it does, what will be done with the responses? -Is this anonymous or will the Q+A be tied to people -Is it possible there will be further questionnaires in the future? -What type of reporting is involved? etc.
  14. The regex for the preg_* functions requires a delimitter character around the regex. Most people start with '/'. So for example, from the code, the first replacement would be: $pageed = preg_replace("/.*/", "", $page);
  15. Correct, the function is deprecated -- which means that the PHP team has decided to remove it entirely from the language in the future. For now, this is only a warning, and you can turn down the errorlevel to not display or log warnings. You could also find a corresponding preg_ function and recode to it if you want to correct the problem going forward.
  16. You might want to google for some user/member system tutorials.
  17. The html select tag makes a dropdown list. Display in list So you simply need to build the options in your foreach and echo out the data in the option tag. echo ''; foreach ( $users as $key => $value ) { $user_ids = implode(',', $value); if (!empty($user_ids)) { echo "$user_ids"; } } echo '';
  18. Thorpe pretty much summed up my thinking on the matter. thehippy also brought up a technique for passing data that many people use -- amfphp or zend_amf to pass data from the server to your flash movies.
  19. I'm simply relating to you what the error message indicates. You didn't provide the code that actually calls the error. If this is code you didn't write yourself, as it seems you indicated in your original message, you'll have to learn enough about it to actually debug the problem.
  20. The error is telling you that whatever query was executed generated an error rather than a valid result set.
  21. PHP is capable of generating xml files, just as it can generate images, pdf's, javascript and just about any type of data you can think of. Usually people will use a database structure to store the attributes that vary by user, and write some code that renders the customized xml as needed, once a user has logged in.
  22. str_replace works on strings. When you have an object that includes a string you need to reference the actual string to do the replace: $meta.name = str_replace("_", " ", $meta.name);
  23. It's a non-trivial schema, but in general terms, I'd recommend a standard normalized relational database design. -items table (one row for each possible item) -worldItem (a row for an item that actually exists in the world) -player (row per player) -playerWorldItem (relates a worldItem to a player/slot)
  24. If you have a fairly low end machine, kicken's suggestion works well. If you have a higher end machine, you might consider virtualization using either VMWare workstation or Oracle/Sun Virtualbox. There are numerous howtos and tutorials you can find on installing a distro of your choice. If you're hosted on a linux server, this has the added advantage of being a better simulation of your ultimate deployment environment, and also doesn't gum up your machine with a bunch of services -- the virtual server is exactly like your deployment target, and you can set it up just like your godaddy account, in terms of users/permissions etc.
×
×
  • 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.