Jump to content

ThePsion5

Members
  • Posts

    203
  • Joined

  • Last visited

ThePsion5's Achievements

Member

Member (2/7)

0

Reputation

  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)?
×
×
  • Create New...