Jump to content

ThePsion5

Members
  • Posts

    203
  • Joined

  • Last visited

Everything posted by ThePsion5

  1. ThePsion5

    help me

    You should also use mysql_real_escape_string to prevent SQL injection attacks as well.
  2. Also, i would advise that you escape your input variable before you run the query...don't want some hacker destroying your site, lol.
  3. Unfortuantely, it's not a function issue as much as an object handling issue...I always use alot of OO in my design and I want to make sure that it'll work on PHP4. On top of the pain of not being able to create interfaces, abstract classes, and type hinting, heh.
  4. Hi guys,I'm developing on a machine that is currently running PHP5, but the product i'm developing for will be a PHP4-exclusive one; sadly, switching PHP installations on this machine has proven a significant pain in the arse so I was wondering if there was some way i could force PHP5 to look and act like PHP4. Any ideas?Thanks in Advance,Sean
  5. I wouldn't say that conclusively...after all, look at how much closer to Java and C++ PHP5 is compared to PHP4...give it a few years and I bet it'll catch up. I've actually toyed with the idea of using javascript written by PHP code...havn't tried it yet though.
  6. Sure, I realize now that I should have clarified.Normally, if I want to create a class that uses other classes, I would create an interface for those classes. I'm going to create a better example here: interface Cargo{ function getDimensions($format); function isFragile(); function getWeight($format);}class CargoCarrier{ function addCargo(Cargo $Added) { $Weight = $Added->getWeight('metric'); ...(do other stuff)... }} This way, using the (Cargo $Added) line, i'm specifying that the variable $Added must contain an object that conforms to the Cargo Interface. However, i want to use a static class the same way: turns into To do this, I need to change the CargoClass section of the code, but i have no idea how to do that. Does that explain my problem a bit more clearly? Thanks!
  7. Hi guys,I'm creating a class that I would like to be able to switch out particular implementations for by making it conform to an interface. Normally I would just do this: class UsesIt{ function DoSomething(MyClass $Class) { ... }} But the class I want to switch is a purely static class - I can't create instances of it. How do I change what static class I want something to use? Thanks in advance!
  8. Right...the concept of tight coupling between objects is that two classes are explicitly aware of each other and know about each other's internal implementations...for example, tight coupling would be something like this: $variable = $Class1->getsomething();$Class2=>internalVar = $variable; This doesn't sound so bad except when you need to change the $Class2 object to a different class that may not have the same variable name, loose coupling is more like this: interface IClass1{ function getSomething();}interface IClass2{ function setThatThing($thing);} so the code is now this: $var = $Class1->getSomething();$Class2->setThatThing($var); And you can change out $Class2 for a different type of object as long as it conforms to the interface. Hopefully I didn't just confuse everyone alot.
  9. I think there is a simpler way you can go about this. How about a schema resembling the following Then, have the first entry in your database be a "global" category that acts as a parent for all the primary categories, and simply references itself as the ParentID. All other primary categories would have the global category as their ParentID, and subcategories would have the regular CategoryID, like so:CategoryID | CategoryName | ParentID--------------------------------------------------1 | Global | 12 | Category A | 13 | Category B | 14 | Category A-1 | 25 | Category B-1 | 36 | Category A-2 | 2 I also think you may be able to simplify the process of having a different table for every single type of product as well, although that may be a slightly different problem. I think you need to find several (2-4) categories everything on your site would fit into and create a table for each. Then use optional or text fields to hold the details of each item - although as a database admin, this solution seems a bit "dirty," storing each product's detailed information as a serialized PHP class may provide a much easier solution than creating a database with 30+ tables...
  10. Hi guys,I was wondering if anyone here knew some good active forums on object-oriented programming and or software design patterns; I have a question that's been puzzling me for some time now. I'll post it here just in case anyone's interested:The Factory design pattern is meant to reduce tightly-coupled objects by separating the code that instantiates particular classes from the code that implements them. So instead of having code like this: $Crawler = new Crawler('http://www.google.com');$Crawler->setStrategy($Something);$Crawler->setErrorHandler($SomethingElse); You have something like this: $Crawler = CrawlerFactory::makeCrawler('http://www.google.com', $Something, $SomethingElse); Therefore you can change what the makeCrawler() method actually creates without having to change the code in the instantiating classes. Here's where my question comes in:By using the factory method, aren't you creating tight coupling between the classes that instantiate the Crawler class and the CrawlerFactory (since the classes using the Crawler class must know about the CrawlerFactory directly)?
  11. And since I like to hijack threads, I was wondering something related to Object Oriented-ness too. Does anyone know of some good, active forums on Object Oriented design? I have a few questions about a design I'm implementing that I would like some assistance on.
  12. Ah, I wasn't sure if that would copy the object or just reference it. Thanks! Aside from that, does the code look clean and/or valid?
  13. I'm trying to create a function in javascript that allows additional HTML elements to be added to a document by calling the function (preferably a button). I'm relatively new to Javascript but I think I have most of the code here correct. However, I'm not sure how to make a copy of a DOM object in javascript. How would I go about doing this?P.S. Also, if anything else is screwy, let me know var num = 1; //Tracks the number of fieldsvar containerID; //The ID of the html element that contains the fields to be addedvar firstID; //The ID of the first field elementvar addID; //The ID of the element that calls the functionvar maxEntries; //The maximum number of elementsfunction addFields(){ num++; if(num < maxEntries) { //Retrieve the container's HTML var ContainerHTML = document.getElementById(containerID).innerHTML; //Retrieve the HTML code for the first element var EntryObject = document.getElementById(firstID); //I need to make a copy of the Entry object here, how would I do this? //Set the ID of the copied element appropriately Copy.id = firstID + '_' + num; //Add the new section to the container's content document.getElementById(containerID).innerHTML = ContainerHTML + Copy.outerHTML; } else { document.getElementByID(addID).style.display = "none"; }}
  14. Doh! I was afraid of that, lol. Javascript it is.
  15. Hi,I'm designing a standards-compliant webpage, and this page has external links that i'd like to open in a new window. But according to the xHTML standard there is no longer a target attribute of anchor tags. Is there another tag or attribute that simulates it's functionality now or is it just no longer supported, and if so is there another way I can create the same effect without breaking the xHTML standard (without javascript if possible)?
  16. Ah hah! That's actually exactly what I need! I appreciate you finding that for me.
  17. Sadly, I can't use that functions without enabling it in the PHP.ini file, which is my problem (If I had administrative access i'd just use the PECL extension, lol). I wonder if I should go through the arcane profess of using binary to determine the MIME type? *gulps*
  18. Perhaps you should look into a javascript debugger, or post an example of what you want it to do and your code? Just telling us to go to the page and figure it out for you suggests you aren't willing to do any actual work.
  19. Well obviously I can't depend solely on javascript for validation, but the idea is that most validation errors I can handle on the client-side with javascript, saving the users time and me some bandwidth. Regardless of whether the javascript validation is functioning or not I'll still validate everything on the server-side as well, this is used mainly as a convenience to potential users. Personally, I've found that Javascript validation done properly can be helpful and unobtrucive since the users are presented with the error upfront instead of sending their information to the server and waiting to find out what may have gone wrong and possibly having to re-enter information.
  20. As in, I don't want to exclude files that way specifically, as the logic designed to filter files is located in a different object...What I do want to do is exclude non-text-based files because that is a universal specification. As in, i don't want to say "no .pdf, .wmv, or .avi files" or "only .htm, .php, and .html files" but no non-textual files. Perhaps I could use something with MIME types for this?
  21. Hi,I'm trying to use the file_get_contents() to crawl websites, but i'd also like to screen what kind of files i'd be opening using the 'context' option (to exclude .pdf files, for example). I believe this is possible, but I don't really know how. Any ideas?
  22. Well, the reason that's the way things work is because how the content is presented is very dependant on header information, which includes letting the browser know what it's supposed to be displaying. If output began before the browser knew this information, it could do things like try and render a movie file as HTML (which has actually happened to me before), and do other things that are generally undesirable and maybe even dangerous to your computer's health, lol.
  23. Very true, but I'm interested in using a single PHP system to validate code on the client and server through a unified interface. Plus, it saves one bandwidth, especially on a large, potentially confusing form.
  24. I'm defining the required field name statically...so the actual function would be containing a series of if...else statements that would alert the user if a required field was not filled on or some other chriteria isn't met. If all the requirements are met, the function would then return true and the form would be submitted. This is actually part of this grand scheme I have to dynamically generate form validation javasript using PHP and GET values, lol. the formfield.value is actually going to be defined by the PHP script based on what's passed into it from the GET field. Whether this will actually work in the end...who knows, heh.
  25. Well the Idea is that i'd have several function so validate, one for each type of validation. For example:function isBlank( stringValue ){ var isBlank = false; if( stringValue.replace(/(^\s+)|(\s+$)/g, '').length < 1 ) isBlank = true; return isBlank;} So then I would create a script like so: function validateForm(formName){ alertValue = 'Please Enter a Value For: '; isValid = false; if(isBlank(formfield.value)) alertAndFocus(formName, 'formField', alertValue); else isValid = true; return isValid;} Granted, that's a simplified (and probably syntactically incorrect) version of it, but that's the general idea.
×
×
  • Create New...