Jump to content

KevinM1

Moderators
  • Posts

    5,222
  • Joined

  • Last visited

  • Days Won

    26

Everything posted by KevinM1

  1. @Hall of Famer: again, OOP is not inherently superior than procedural. @OP: The real question is what do you want to do with the language(s)? C is generally used for close-to-the-metal programming where speed and efficiency are paramount. The linux kernel is written in C, for example. C++ is generally used for mainstream apps.
  2. Yup. That's one of the reasons why C# added the 'var' keyword. It's syntactical sugar that forces the compiler to infer type based on the rvalue of an assignment. It's awesome, as you get static typing under the hood (compiler errors/warnings if you do something dumb) but it reads a lot like non-horrible JavaScript. Something like: var articles = _repo.GetAll(); Is far better to read/write than: IQueryable<Article> articles = _repo.GetAll();
  3. In PHP 5, objects are already passed by reference by default. It doesn't look like they are, due to the lack of '&' in the syntax, but they are. All you need for your scenario is dependency injection, which is merely wiring up any dependencies an object has to that object itself. That's what everyone does when their object has a private $db member and assigns it an actual database connection or object via constructor or other method (as an example)
  4. To get back to Psycho's comments about design, you're making the classic beginner mistake of embedding PHP code within your HTML. Well-formed scripts do all of the PHP processing upfront, which separates the brains of the script from its output, much like how CSS and HTML should also be separate. By keeping each component separate, you make it far easier to debug, edit, and maintain your code. A rough sketch of how you should write scripts: Pure PHP to handle requests, form submissions, db queries, etc. Results are stored in variables. l l l V About 90%-95% pure HTML, with just enough PHP to to display the values you stored in the variables in step 1. You should limit yourself to echo, if/else, and simple loops. Nothing else. Output should always be fairly brainless.
  5. ...? What script? Whose script? What are you talking about?
  6. I feel like I've critiqued this site before, but couldn't find it when looking through the topics of the last few months. That said, I'm not a fan. It's just amateurish across the board: All of the useful stuff is jammed together at the top of the screen. It's like a stack of pancakes, which is great for breakfast, but not for a website. Unaltered hyperlinks, stacked on top of a search box (which is jammed next to its accompanying button), stacked on top of a boring image that looks like text on top of a photo found on Google Image Search, stacked on top of bold hyperlinks, stacked on top of login (also jammed together), stacked on top of a register link is just bad. There's no other way to describe it. You waste a lot of vertical space, and hardly use the horizontal. You need to strike a balance. Modern monitors are wider than they are tall. You have a ton of horizontal real estate that's sitting there, unused. So, some suggestions with all that: Move the login/register stuff to its own location. Create a proper header. Your little image does nothing to break up the sea of yellow it sits in. You need something to create separation between your site name and navigation, and the rest of it, and more empty space is not the answer. Padding, padding, padding. Elements need to breathe. Especially if they're on the same line. Think about your navigation. Do you want the alphabet to be visible on every page? Why are those links more visible than the top-level links? Element placement and size denote importance, so be absolutely clear with what you're trying to do. Other stuff: Are you sure you want your background to be yellow? I'm guessing that it (and the darker box on the right) are supposed to imply beer. Maybe it's just me, as a non-drinker, but when I see those colors I think of urine, illness, and get just an overall queasy/sick vibe from it. --- Okay, so all that said, it's not the worst site I've seen. It's just very amateurish, and needs a fair amount of work to be pleasing to look at/use. If you're looking for the site to become a thing, you'll need to work on it some more.
  7. This topic has been moved to Application Design. http://forums.phpfreaks.com/index.php?topic=361943.0
  8. KevinM1

    PHP 5.4

    Uh... http://www.php.net/manual/en/pdostatement.rowcount.php
  9. I'm just gonna leave this here....
  10. This topic has been moved to PHP Applications. http://forums.phpfreaks.com/index.php?topic=361795.0
  11. How are these arrays being created? Because that's a very convoluted way to represent dates and times.
  12. No, extending a class is a completely different thing. Can you give us the print_r of $data_stats?
  13. You need to decouple logging an error from displaying an error. While both fall under the general heading of error handling, they're opposite sides of the process and (as you're now seeing) not necessarily dependent on one another. You should be able to stick the code that logs the error in a function. That way, you can log errors without a redirect. results.php should only serve as an error screen when needed.
  14. Okay, well your returned $totalVisitors will automatically give you true, assuming that number will never be 0.
  15. Are you saying the Function would return TRUE + VisitorCount on success? Debbie Does your function currently return anything? I don't see you doing anything with $visitorCount. That said, remember our last conversation about how boolean true can be represented. Any value that can be represented as a non-zero integer will be true.
  16. A design question, not a code error. This topic has been moved to Application Design. http://forums.phpfreaks.com/index.php?topic=361698.0
  17. True would mean the query (and therefore the function itself) executed correctly and you were able to get the visitor count. I'm not sure why that would be odd/confusing. Boolean flags are quite common. IMO, you should, at the very least, log errors of this nature.
  18. Why not make the function return true/false, and then redirect to an error screen based on that? if(!visitorCount()){ // redirect to error }
  19. Just give both forms unique input names. submit1 and submit2 would work. Just be aware that you'll need to do two checks, and handle one form or the other based on that check.
  20. Yeah, we tend to meet in the bunker.
  21. TecTao, forget about sub-directories. No, really. Purge that idea from your brain. ... all good? Okay. You need to understand how websites actually work under the hood. When a user enters in a URL, they're sending an HTTP GET request to a server in order to retrieve certain content. This GET request can have extra key-value pair data sent along with it. That's done via a query string. What does a query string look like? Take the following URL: www.example.com/index.php?user=1 Everything after the '?' is the query string. You can pass along multiple items in a query string: www.example.com/index.php?user=1&profile=edit&puppies=awesome In PHP, you can grab that data using the $_GET superglobal array, like so: $user = $_GET['user']; $profile = $_GET['profile']; $puppies = $_GET['puppies']; So, how does that relate to you? You can have ONE script that displays user information based on data that's sent in via GET. An example: <?php $userID = $_GET['id']; $query = "SELECT * FROM users WHERE id = $userID"; $result = mysql_query($query); $row = mysql_fetch_assoc($result); ?> <!doctype="html"> <html> <head> <title>User Profile</title> </head> <body> <table> <tr> <td>Name:</td><td><?php echo "{$row['name']}"; ?></td> </tr> </table> </body> </html> Just to be abundantly clear, the (canned, not secure, example-only) script above generates a different user profile (in this case, only their name) based on the data sent in the query string. So, www.example.com/profile.php?id=1 Will display different data than www.example.com/profile.php?id=337 Even though you're accessing the same script.
  22. You should do whatever you feel best balances ease of use and readability.
  23. I was thinking the same thing. Though, I'd like to implement one of those infinite scrolling pagination techniques. I wouldn't recommend that, since it's a catalog/store. For people who may make frequent use of the site (contractors?) it'd be better if they could bookmark a particular page rather than always scroll through a bunch of items every time they visit the page.
  24. Much better. Some crits: 1. I'd make the images in the home page slide show as wide as the context block below it. There's a noticeable size difference in width between the two. 2. Pagination. Especially with the prefinished solid floors. There's just too many to comfortably scroll through. 3. Check your capitalization with the Sundries. With the first item in the first location, you have CHERRy. Why not run all of the data through strtoupper if that's the look you're going for? 4. The footer is hard to read. The gray font blends in with the wood grain. All that said, I think you're 95% there. Some tweaks are all that's needed.
  25. Yes, it's okay to have functions that don't return a value. In statically typed languages, they're often denoted with the 'void' keyword.
×
×
  • 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.