Jump to content

KevinM1

Moderators
  • Posts

    5,222
  • Joined

  • Last visited

  • Days Won

    26

Everything posted by KevinM1

  1. No, don't put entire HTML pages in a database. Databases are for data. The basic idea is this: You store data in a database. Requests for that data are handled by PHP, which queries the database for that data. PHP then puts the data in the correct template so it can be viewed. These templates are PHP files, but are largely HTML. There's just enough PHP within them to echo the data at the appropriate spot in the markup.
  2. This topic has been moved to Application Design. http://forums.phpfreaks.com/index.php?topic=362573.0
  3. This topic has been moved to Miscellaneous. http://forums.phpfreaks.com/index.php?topic=362554.0
  4. Ah, some of it was my my mistake. I thought you wanted to echo the user's name if found. To simply see if database rows were returned, do: $query = "SELECT * FROM users.userdata WHERE username = $name"; $result = mysql_query($query); if (mysql_num_rows($result) > 0) { // found } else { // not found } Of course, you still need to ensure that the query itself worked. I'll leave that for you as homework. If you actually want to do something with the data, then you need to fetch it: $query = "SELECT * FROM users.userdata WHERE username = $name"; $result = mysql_query($query); $row = mysql_fetch_assoc($result); echo $row['username'];
  5. You actually have to fetch the data. mysql_query returns, as you can see, a resource. You need to use one of the fetch functions (mysql_fetch_array, mysql_fetch_assoc, or mysql_fetch_object) to actually get at the data.
  6. OOP - not just the syntax, but the methodology. If you think that OOP is merely stuffing functions in a class definition, you're doing it wrong. Form handling - sticky forms, how to handle check boxes and radio buttons, how to handle POST data in general, validation/sanitation. Databases - queries, injection prevention, efficiency. Data structures - learn to love arrays, as they're the base of PHP. Script design/organization - well-formed PHP scripts follow a particular pattern. Jumping in and out of HTML in the middle of a script is a symptom of doing it wrong. Learn to use templates, learn to separate your concerns, learn the difference between GET and POST and when to use them. File handling - IO, looping through a directory, uploads, etc.
  7. In the future, please place all code within tags. I took the liberty of adding them for you this time.
  8. I wrote my layout/site design thoughts in your thread in the Website Critique sub-forum.
  9. It looks sloppy. Just looking at the index: 1. A whole bunch of white without a lot to distinguish and separate areas. In particular, the blurb with the site description suffocates the little FAQ and testimonials below it, which in turn smother each other. 2. Layout issues. It's very disjointed. Login/register sticks out awkwardly, and doesn't really belong in the area where you pimp your latest hunts. The heading "RushHunt: Online Scavenger Hunt For Free Prizes" sits unevenly on the dashed border below. The previously mentioned main blurb/FAQ/testimonial issue. Your images in the FAQ don't line up with the text. 3. I don't get the logo. I mean, I get the linked "H's", which is clever, but why is there an orange silhouette of a man with his arms crossed staring at me from above the last "T" in RushHunt? Maybe it's supposed to represent something else, but it looks like a stern authority figure who's not pleased with me. Here's a quick MS Paint rundown of suggestions: http://www.mpphp.com/rushhunt.JPG And the explanation: Move your login/register to the top-right of the layout, where the arrow points. Make it fit in that black border area (so the textboxes would be side-by-side). Put a small remember me button and register link there, too (they can be on the line below, but still in the black). Move your testimonial area below the FAQ. You'll need to get/fake more interesting testimonials, but testimonials that merely say "This is fun!" don't have much value anyway. Now that I think about it more, if you can get sponsor testimonials, that would be great. It would be a great way to help your case with future sponsors. Just be sure to NOT fake those. You don't want to ever mislead potential business associates. The key is to let the main blurb, FAQ, and testimonial area breathe. Since everything will fill the content area horizontally, you gain readability, but at the cost of needing more content to fill the emptiness. Remove the "Leave a comment" form from the index. Create a separate form that you link to from the testimonial area. It's kinda chincy to have it like you currently do. To that end, don't blindly throw up whatever people write. Only display your very best 4-6 testimonials. You really don't want "fuck yo momma" or other comments of the same flavor to wind up in there. Do more with your borders. Color never hurt anyone. 1-3 px solid of the royal blue used for the background would likely look a lot better than black or gray dashes.
  10. More to the point, like scootstah said, what do sponsors get out of the deal? You're in a bit of a catch-22: the prize needs to be valuable enough so the business generated by its publicity outweighs its cost. Your best bet would be to contact local businesses that offer easily replaceable/reproducible products/services. A free pizza from the local pizza shop, a free cut and/or color from the local salon, that sort of thing. You'll need to convince them that what they give away for free will be more than made up for by the extra publicity. And, at the beginning, you may need to foot the bill for that yourself until your local partners actually see a rise in business. Long story short, no one is going to give you something for free. It needs to benefit them as well, and you'll need to convince them that the arrangement is mutually beneficial.
  11. This topic has been moved to Application Design. http://forums.phpfreaks.com/index.php?topic=362400.0
  12. On that note, every freelancer should watch:
  13. AFAIK you can't. Dynamically created object members default to public. Why? Any members that don't have an access modifier (one of public, protected, or private) default to public. Since you can't create an access modifier dynamically, they'll be un-labeled, and thus public. More to the point, what are you trying to do? In most cases, objects are defined upfront, with their fields declared.
  14. Line 114 should be $state = 0
  15. It doesn't work because you're looking at it with a browser, which anticipates HTML. \n is meaningless to a browser (at least, in terms of what it renders to the screen). Your normal white space characters won't work. Instead, use <br />, the HTML tag for a line break.
  16. (potential) Clients can be assholes. I once had a client chew me out after I presented a layout that she agreed to the day before. We had spent hours going over the structure, color palette, overall 'look', etc., and the next day, when I showed her the layout in full, she explicitly claimed that I betrayed her. Fun times.
  17. But I look like a badass with them.
  18. Even in well-lit rooms, I've felt a bit of eye strain recently with light/white backgrounds, so I've been changing everything I can to the reverse.
  19. beeker, once again, use tags. Note that IS NOT THE SAME AS <code></code>. The square brackets are intentional.
  20. Very good explaination, KevinM1. Thank you! So here's another question, would it be better to use __construct for my database connection and put it in a class? Unless you're familiar with OOP as a methodology, I wouldn't. Your $mysqli is already an object. And there's a lot more to OOP than merely stuffing things related by theme in a class and calling it a day. So, unless you feel like you're going to gain something by doing that, just leave it procedural. Also, what xyph said.
  21. I figured it would be fun to see what themes everyone uses with their favorite IDE(s)/editor(s). Maybe it will inspire people to try a new one, or make their own, or whatever. For PhpStorm, I use Friends of Symfony: http://phpstorm-themes.com/theme/friends-of-symfony/ For Visual Studio, I use Dark Bliss: http://studiostyl.es/schemes/dark-bliss
  22. As to why globals are bad, they create an implicit connection between a function and the environment it's being invoked in. A connection that's easy to change/erase/not know about. This kind of connection is known as 'coupling' and the tighter that connection is between the function and its external environment, the harder your code will be to maintain, debug, and even understand. What's more, the entire point behind functions is to create reusable, loosely coupled bits of code that can be used in a multitude of situations. Using globals negates much of that. Functions have what's known as an argument list. It's a list of values that are supposed to be passed into the function to allow it to work, and is located in the () of the function definition like so: function example($arg1, $arg2) { echo "$arg1 - $arg2"; } How is that different than using 'global'? Functions are supposed to be black boxes. Material (variables) go in, some sort of result comes out. To the script at large, what happens within a function doesn't matter. So long as the right kind of result is returned, the script can go about its business. This kind of arrangement - a function's name, its dependencies, and what it returns - is known as the function's signature. Since functions are supposed to be black boxes, all raw material that it requires needs to be present up front and explicitly passed in. Globals blow the black box analogy apart by creating a hidden requirement. There's nothing in a function signature that gives evidence to the required global(s). Your functions now have knowledge about the outside environment, yet the script itself is essentially blind to the fact that the requirement exists at all. This might not seem like a big deal, especially if you never have others use your code, but it's really a bad way to do things. Given how easily globals can be overwritten, and how deep those kinds of dependencies can be nested, using them creates very fragile, very confusing code. In short, there's never a good reason to use globals, and it's generally a sign that the person who wrote that code didn't know what they were doing. If the resources you're using to teach yourself PHP uses globals, get better resources. Use the argument list instead. That's why it's there.
  23. Specifically, look at the end of your $_GET.
  24. You're describing ASP.NET webforms which sucks. ASP.NET MVC is pure server side, and is pretty good, aside from the Microsoft bloat. It's not as to-the-point as something like Symfony, but it gets the job done. Client side stuff is left up to the developer's discretion, although it ships wiith jQuery. It's really just a C# or VB (developer's choice) MVC framework.
×
×
  • 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.