Jump to content

HGeneAnthony

Members
  • Posts

    95
  • Joined

  • Last visited

Everything posted by HGeneAnthony

  1. I don't know if this is even an issue, but I was wondering with a public function of a class, do I need to test the arguments to see whether the data is valid even if I test the data before I pass it to the function? For example, I have a class to manage the users in my system. The class is responsible for checking the input it's passed to make sure it's allowed, only after it's done will it send the data to my seperate database class which handles the database details. The database class is set up with public functions so it can receive the data from the user manager class. Nothing else is set up to touch the database class. Do I still need to check the data? Can someone somehow access the database classes public functions in ways I hadn't planned for? I can't think how they would but I'd like to know if this is something I should worry about because I'd like to put a lot of the logic in the user manager class and keep the database class simple. Also this system makes it much easier to use mock objects which I can't do nearly as well otherwise.
  2. I've been reading up on MVC and I have a few questions. I'm already familiar with splitting the data from the view but I don't know if with MVC if the controller handles the logic of checking to make sure the data is allowed or if this is handled by the model. IE. If someone tries to add a new record should the controller check the data before it passes it to the model to make sure it's within allowed ranges or should the model handle this? If the controller checks this should I also check it in the model? If I don't check it in the model can this cause security issues with a public function of a class?
  3. Sorry I wrote that wrong. The people aren't connecting to my db. I plan to use a localhost user for all connections to the database but with users surfing my site at the same time I might have quite a bit of objects loaded into memory at a time if I'm saving bulk results. Granted I plan to release the objects after I use them so it might not be bad. But short term it will eat up more memory. I don't know though. I've done desktops more than websites and with a desktop I wouldn't be concerned but with a website I don't know.
  4. Thanx for the quick reply. I kind of thought so myself. My only concern is with having multiple users connecting to my server and available memory.
  5. I have a list of items to return. The list will be accessible through my object (each field with a function call) so I need to store results before I can display them. I was wondering is it better on performance to store the results into an object array so I only need to call the database once or should I only store 1 result at a time and make multiple calls to the database? Right now the results returned could be between 10 to 100 at a time with 5 or so fields a record. I would think doing bulk operations would be best but with memory usage and multiple connections I don't know. Suggestions?
  6. Does a constant take up as much memory as a variable? I was wondering this because I didn't know if it just worked like a reference to the line that called it or what.
  7. I was wondering if anyone knows of any good free code snippet managers for personal use. I know there are some community ones but I just want one for my desktop where I can search through quickly. Anyone know of any.
  8. As far as user/passwords accounts you plan to use for others login to your web site you'll want to use the crypt feature to create a one way hash of the password. When someone tries to login you hash the password they provide against the one in your db. If they're the same it's an identical password. Here's the code: $password1 = crypt("12345"); $password2 = crypt("12345", $password1); if ($password==$password2) echo "Passwords are the same"; else echo "Passwords are different";
  9. Most people who set up databases in PHP set a username and password for the database to be localhost only. So even if they get access to your user/pass unless they can get into your server they can't use it and if they do you're screwed anyway.
  10. Sorry, I don't work with PHP enough I'm used to Java with its limitations. Thanx for the reply though.
  11. I have an external js file. I also use frames. In the main frame I include the js file. However, when I call a function that's in the js file, say to modify the contents of a div tag, I can't. Example: document.getElementById('test').innerHTML = "This works"; I assume I need to reference the frame that holds the document I wish to modify. However, when using: top.frames['main'].document.getElementById('test').innerHTML = "This works"; Nothing seems to happen. How can I make this work?
  12. One more question though I didn't see this listed on tutorial sites but can you use custom tags/elements and attributes with xhtml (like xml) or do you need to stick with the standard xhtml tags? Also is it possible to use xhtml files with css and highlight custom tags or do I needs xslt? In Forefox it doesn't seem to matter but IE's a different story.
  13. So there's no problem using xhtml in a php page with IE? Does this apply to 6 as well. I decided I'm honoring browsers going back to ie6 but no farther. Too restrictive limiting my pages for people still using IE 5.5, etc.
  14. On XHTML in IE, as far as I know with 6 and 7 if you try to name your page xhtml it won't load it will give you a download page instead. As far as my code being broken if I'm correct xhtml specifies all lower case tags, all tags must be closed, all attributes need to be in parenthesis either single or double, and all attributes need a value. You should also not use any tags that affect layout like <b> or <i> or <i> and should be replaced with descriptive tags like strong. You also shouldn't use <br>. Now I thought xhtml has a preset amount of tags and you can add your own tags like xml. With a stylesheet you can then specify rules for these tags. I would assume this would be allowed: <html> <head> <style type="text/css"> name { color: red; } </style> <title></title></head> <body> <div>My name is <name> Gene</name></div> </body> </html> In Firefox Gene would be in red color in IE it doesn't do anything I didn't expect it to cut down on the download time but I thought since it was taught to render the page using strict rules it would treat the page as complete and not try to fix it which I believe would increase actual rendering performance.
  15. I like the concept of XHTML but I was wondering is it possible to use XHTML markup inside of a PHP page and is it possible to use it with Internet Explorer? I tried creating an XHTML document one time and XHTML only worked with Firefox. I was able to use the xml like tags using PHP pages under Firefox but they were ignored in Internet Explorer. Does anyone have any suggestions how I can used xhtml like pages with IE? Also I heard using the xhtml declaration at the top of a page can make it load quicker because it assumes the tags are good and it doesn't try to fix broken tags it just assumes they're good. Is this also true?
  16. They didn't always own it. Google bought them for something like a billion. I can't figure out how they make a profit though and why Google would want them. Anyone else got any idea?
  17. I was wondering how do video sites like youtube manage to pay for the bandwidth costs that it must have let a lone make a profit. I don't see a ton of advertising on the site. I'm interested in adding video to my site but my issue is bandwidth. Are there tricks these sites use to drop their bandwidth consumption down a lot?
  18. I develop on the desktop for the most part. I've made dynamic sites before but on rare occassions. The thing is the two worlds are very different. With a desktop app you typically have one or a few users using an app at a time and almost all the processing is done on the client end. With a web site you have multiple connections to a server and you have to worry about the end user pulling data down especially with dial-up users and resource depletion. I'm typically torn with which way to go with my sites. For example, I tend to like to use classes heavily to manage data. On the desktop modular design is important and the classes should do what they need to do and nothing else, handle their data accordingly, and create methods to work with data. This is important when writing any app of any real complexity however even though it seems to be similar on the web it's not always. For example, if I was going to pull data from my database I would typically throw it into a collection of some sort (rather than displaying it outright) and I would create functions to access it. This way the class is only responsible for the data, it doesn't work with the form, it makes it easier to manage the data if I change things later, it keeps things clean, etc. However, with a site I don't know how bad holding the data could be on the server. It creates cleaner code but it could be heavier on resources since the servers creating variables to hold data rather than just shooting it out. So how should I handle the data, shoot out at once or hold.
  19. I'm not looking for the php interpreter to handle the xml. The php interpreter handles the script and returns pure HTML (I'm aware of this). What I would like to do is have the returned html returned like xhtml so I can use xml elements with the style sheet. Under Firefox this works but under IE 7 the style sheet isn't being applied to the xml elements so I wonder if the document needs to use an .xml extension or an .xhtml extension for IE 7 to acknowledge the xml elements.
  20. What I'd like to do is use xml in my php file for use with my css. I noticed php can read from xml files to get data but can I use xml in my php file like how xhtml uses xml. As in can I use xml with css for presentation rather than as data entry. If you know what I mean.
  21. I was wondering if it's possible to group items by text that can appear in multiple fields. I don't want to combine them but if textA appears in field1 in the first record and textA appears in field2 in the second record I would like to group them together. I don't know if this is possible. When I try to use group by field1,field2 it seems to group items where field1 and field2 are equal to other records. Any help?
  22. Thanx for the tip. I'm always apprehensive though of using client-side scripting for anything that can break functionality. If someone doesn't enable JavaScript the page won't work. Question though, does Flash use JavaScript to run or is it considered something else?
×
×
  • 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.