Jump to content

gizmola

Administrators
  • Posts

    5,945
  • Joined

  • Last visited

  • Days Won

    145

Everything posted by gizmola

  1. $_SERVER['REMOTE_ADDR'] works in most cases.
  2. For AUTO_INCREMENT columns you should always set them to be UNSIGNED because you'll never have a negative value, and you're wasting half your range on negative values you'll never use. Otherwise, you can alter the table and in most cases, you won't lose any data in the process. For the table that is a mediumint, you stated that the range was 0-9999 so I suggested the downgrade to a smallint (which can go 0-65767 for UNSIGNED) would be overkill. Even if not UNSIGNED, you still have plenty of room. I tend to look at the use case for the column and pick the smallest datatype that supports it. Often for "lookup" tables like departments, account numbers, or small lists, I'll use either a tinyint (0-255 unsigned) or a CHAR[1], or a smallint. For your main data tables which you expect to grow over time, it makes sense to use an INT. I've also worked on a number of "needs to scale" applications, where there was a design goal that included some sort of sharding algorithm, so the primary keys of those tables were often GUIDs or large hashes. Without a doubt, however, the smaller the table the better performance and scalability. Every byte counts when you consider that caching is used, smaller means more data that will fit in cache rather than having to be read from disk.
  3. Or you can go with ZF or Symfony, which were written from the ground up under php5. Look, I have nothing for or against CI, but if you're going to suggest that someone should consider it, you should provide some reasons why.
  4. How about print_r($result->GetWorkOrdersResult)?
  5. I implemented rss and atom feeds recently using the Zend library, and it was pretty darn simple. There are other libraries out there which do rss as well.
  6. Is student_name a class variable? Post your full class definition for us to look at.
  7. PHP would typecast the 2 to a string, since that was required, but it's ok that you're making it a string AFAIK. Try print_r($result) and see what you have. I think there's a structure there you may have to unbundle, based on the wsdl you provided.
  8. First off, you have to define what you mean by sanitation. The class you were looking at did almost nothing, other than to escape values assumably for insertion into a database. If that's what you want, there are functions for at least some of the databases that are specific to them. In the case of mysql, there' mysql_real_escape_string() which is what you should use for escaping.
  9. The error you got is because $array is not an array. I noticed that at minimum, you don't actually assign $result to anything so naturally it's not an object. Also, not sure why you are calling __soapCall here, when you should be able to do: $result = $client->GetWorkOrders(2);
  10. Did you look at fopen() in the php manual?
  11. Take a look in your error log. Could be any number of things related to your database connection. We don't have enough information but I would make the general comment that your code doesn't check for errors. For example, you do a mysq_query() and store the result to $result, but don't check to see if $result if valid before you try and fetch.
  12. Yeah, in php4 when you would create an object with new and assign it to a variable, the assignment itself would make a copy of the object. In many cases that didn't tend to matter much, but if the constructor was doing a lot of heavy duty stuff, or was creating resources, you would use the =& to get around the quirk. In php5 all objects are passed by reference, so you no longer have to worry about this issue. There are of course still lots of php4 libraries out there, and you are apparently using one of them. If there's a way you can find a newer one, I'd recommend it.
  13. I want to clarify one other thing from your original message. A mediumint in mysql refers to the number of bytes used. For a mediumint that is 3 bytes. So the values allowable is the range of 3 bytes, which can either be signed or unsigned. The column would have to be declared UNSIGNED to get the unsigned behavior. So the range of numbers that can be stored would be 24 bits, or -8388608 to +8388607. If your value truly fits in the range of 0-9999 then you could downsize that column to a SMALLINT and save a byte per row. In regards to the mediumint(4) people are often confused as to the function of the (4). It has nothing to do with storage. Per the mysql manual: In other words, those numbers do absolutely nothing, unless one is to also declare the column with the unusual 'ZEROFILL' attribute, and in that case it will pad numbers with leading zeroes up to that length. I typically omit those specifiers, since people so often mistakenly believe that they constrain the values in some way.
  14. Seems your question has now morphed into a javascript question. I can't tell you what the problem is, since you're using some sort of validation library I'm not familiar with, but I'd suggest you start a new question in the appropriate subforum for javascript questions.
  15. Sure if you want a framework that is basically dead, was written in php4 oop, and has been forked to Kohana.
  16. The answer to your questions as I understand them, is yes. The only thing I would clarify is that there is no "going to the top." As I stated, your next/prev buttons have to either execute javascript, be regular anchor tags, or submit a form. I don't know why things need to be complicated, but you mentioned checking the $_POST. Regardless, the target should be the same script. At this point the script isn't complicated enough to warrant seperate parts, although maybe a function or 2 wouldn't hurt much. But if you really want to, you can have some of the code included. It doesn't really matter, because the include() acts as if the included code were part of that script. Since the inclusion itself seemed to be something that was causing confusion for you, I'd recommend just having all the code in one script initially, and you can break things out later when/if it makes sense. Typically that occurs when you've established the need to reuse parts of the code, and at this point, you haven't established that from what I can see.
  17. Often sites do things like set cookies or perform redirects. Simulating a browser is non-trivial. This is one of the reasons that people often use the curl library which has a rich set of client features. Firebug is one tool that can help you explore what the site is actually doing in the case of each of the url's.
  18. Once a session is started you can set session variables. They are like any other type of variable. Your code does an assignment to a session variable when a db query succeeds in finding someone: $_SESSION['id'] = $id; That line sets the session variable "id".
  19. You certainly are confused. There is no reason for you to be calling the header() function. Just have your script emit the image with the next/prev buttons and have those be anchor tags that point back to the same script with url params, so what one would expect is something like: MM_Output2.php?img=...&direct=prev For the previous button, and direct=next for the next button. Not knowing where the images come fron, it's hard to say what the img= param should be, but clearly it needs to indicate the current image. At the top of your script you can look at the parameters using the $_GET[] superglobal array, and take whatever action is necesary. Of course initially those params would be empty, so you need to have default values that setup the default image.
  20. I see people going 2 ways: A CMS/Framework (and of these, the one that has the most traction is Drupal) or a Framework with MVC. Of these some were written in php4, and while many have been updated since php5, they still have php4 oop in them. This group includes Codeignitor and CakePHP. Some people argue that this is a benefit because they are more "lightweight" and in the case of CodeIgnitor, there's a fork called Kohana that much of the CI community migrated to, AFAIK. The two heavyweight frameworks written post PHP5 come down to Symfony or Zend Framework. Symfony was designed to be a ruby on rails for PHP, which is to say, that it relies on things like database reflection to provide object-relational mapping classes and batch code generation. When you look at some of the demos they have, it's pretty slick stuff, and the people in charge of the symfony project eat their own dog food, so you know that things are actually being used by people, which in comparison to ZF is not always as clear, as I'll explain i a second. With that said, Symfony requires in my opinion a major investment in getting up to speed, and is not a good candidate for converting or adapting it to an application that has already been written. ZF is much better suited to that, because it is both a class library and a framework. You can use pieces of ZF easily and for the most part, it will work by itself. So ZF is completely viable as a dropin for an existing application, where you want to migrate it over a period of time to a more robust MVC application. The flip side of that, is that ZF sometimes has classes where it's not clear that anyone is using the class, or whether it actually works the way the docs say it does. In fact, for ZF and Symfony, although there's a lot of documentation, it often isn't up to date, and you sometimes have to read code, experiment and haunt the forums and mail lists, but then again, this is open source, so that's practically a given. In my opinion, the most popular modern frameworks are ZF, Symfony and Drupal, and I'd recommend that you evaluate all 3. The best way to do that is to have a spec for a small but functional application, and do a proof of concept in all 3 in order to determine which feels right for your shop. It's not even important that you actually complete the full application -- you need to do enough that you get the shell up, and have at least a few working forms with some db interaction, which will reqiure you to get the frameworks or CMS installed, and enough pieces in place for you to interact with the community and the documentation.
  21. For all intents and purposes this script is calling this cpanel script: $request = "/frontend/$cpanel_skin/subdomain/doadddomain.html?rootdomain=$domain&domain=$subd"; So it appears that doadddomain.html and it's parameters are the key to this. Cpanel does things the way Cpanel wants to, and I don't think that reorganizing the way it wants to create subdirectory structures is something you can do. You could perhaps alter the way this works, but you would probably find that something else broke.
  22. A join is preferable to a subquery, but your query won't work regardless, because DTIME is not a column in the friend2 table, which is why a join is needed.
  23. Inner join status and friends2, so you have a single query, ordered by dtime desc.
  24. Why do you think that you're entitled to "URGENT" help here?
  25. What you're complaining about is the design of the checkbox form element in HTML. Checkboxes only get sent when checked and have no associated value. I didn't check this, but chances are the browser doesn't even send them to the server.
×
×
  • 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.