Jump to content
Larry Ullman's Book Forums

Antonio Conte

Members
  • Content Count

    1084
  • Joined

  • Last visited

  • Days Won

    126

Everything posted by Antonio Conte

  1. Regarding this whole thing... I think this issue is seriously overblown in the media. What matters is what consequence any login details someone picked up would have for you. If someone found my Gmail credentials, I would be in serious trouble. Loosing access to something like my IKEA wishlist would however not affect me in the slightest. Two-factor auth is something anything with critical information should have.
  2. Everything else aside. If you use the function PagePostArrayComma() on the submitted JobSkills, you'll see all skills as comma-separated values saved to the DB. Your biggest problem is that you mix all logic into a single file. The logic here is way to tangled and all over the place, and the result is very unreadable code. You also place all your HTML in PHP echo statements, while there's no need to do that. You should work to get that issue resolved before doing anything else. Here's an concrete example. You have a function: function EmitMETAData($PageTitle) { echo("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\">"); echo("<meta name=\"author\" content=\"Stubbs Transport Management\">"); echo("<meta name=\"generator\" content=\"Stubbs Transport Management www.wcrltd.co.uk\">"); echo("<title>$PageTitle</title>"); echo("<meta name=\"description\" content=\"Driver and Transport jobs - Fitters and Mechanics Jobs - Agencies - Driving Schools - Breakdown - Search and Post return loads - Search and Post empty vehicles and trailers - return loads - CPC - International - Multi-Drop - PSV - Coach \">"); echo("<meta name=\"keywords\" content=\"LGV (HGV) driving jobs - Hiab - Multi-Drop - Coach - PSV - PCV and van driving jobs - Fork Lift - Warehouse Jobs - Agencies - Freight Fowarding - Freight Exchange - Return Loads - Transport Manager - Drivers CPC - Transport Manager - Traffic Clerk - HGV Fitters - UK - Nationwide - Long Distance - Overnights - CPC National - International - Breakdowns - Class 2 - 7.5 Ton - Drivers Mates - HGV Training - LGV Training - Truck Driver Training - HGV Driver Training - Fuel Cards - Diesil - Tacograph Training - Digital Tacos - Tanker Drivers - Removals - Storage - Haulage - Scania - Garage - Scania Agent - Daf Garage, Daf Agent, Truck Drivers, Employment Agency, Employment Agencies, Recruitment Agency, Recruitment Agencies, Job Agency, Job Agencies Driving Agency, Drivers agency\">"); } All it does is allowing you to set the page title. Why not do this instead? // includes here... include_once "../main.php"; include_once "../functions.php"; include_once "../conn.php"; // Set variables $page_title = "A great title"; $some_other_content = ""; // Fetch content with DB function $user=PageGet(user); $verify=PageGet(verify); // Logic here // ... // Include html files include 'views/main/header.php'; // This is now the new "header file" include 'views/something/page.php'; // HTML for this specific content include 'views/main/footer.php'; // A footer file // The new file views/main/header.php <html>.... <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <meta name="author" content="Stubbs Transport Management"> <meta name=\"generator\" content=\"Stubbs Transport Management www.wcrltd.co.uk\"> <title><?= $PageTitle; ?></title> <meta name=\"description\" content=\"Driver and Transport jobs - Fitters and Mechanics Jobs - Agencies - Driving Schools - Breakdown - Search and Post return loads - Search and Post empty vehicles and trailers - return loads - CPC - International - Multi-Drop - PSV - Coach \"> <meta name=\"keywords\" content=\"LGV (HGV) driving jobs - Hiab - Multi-Drop - Coach - PSV - PCV and van driving jobs - Fork Lift - Warehouse Jobs - Agencies - Freight Fowarding - Freight Exchange - Return Loads - Transport Manager - Drivers CPC - Transport Manager - Traffic Clerk - HGV Fitters - UK - Nationwide - Long Distance - Overnights - CPC National - International - Breakdowns - Class 2 - 7.5 Ton - Drivers Mates - HGV Training - LGV Training - Truck Driver Training - HGV Driver Training - Fuel Cards - Diesil - Tacograph Training - Digital Tacos - Tanker Drivers - Removals - Storage - Haulage - Scania - Garage - Scania Agent - Daf Garage, Daf Agent, Truck Drivers, Employment Agency, Employment Agencies, Recruitment Agency, Recruitment Agencies, Job Agency, Job Agencies Driving Agency, Drivers agency\"> <head> <body> By doing this, you'll be able to get much cleaner looking logic that is easier to understand. This same principle applies to CSS and javascript too. Place the code in their own files, and don't mix everything together. Remember that all variables you declare before an include is available to the included source as well. $page_title would therefor be set her.
  3. How do you want to save JobSkils? You might want to rethink your database design a bit, as your users seems to be able to select multiple skills at the moment. While saving all skills in a single field is possible, it'll leave you a lot more job in the end. Things like searching users for specific jobSkills might be very performance heavy. It will also be very hard to debug should anything go wrong. That said and done, what is the function PagePost doing? You are sending it an array now, and that might be your problem. Unless the function breaks it down into comma-separated values, or you save it as JSON (or similar) you should get no values saved to the db. You need to work with that array somehow. (And it's not shown if you do here, so I assume that's the problem) Given the above, I would create another table just for job skills. You then assign each skill selected by the users into a multi-value insert query and insert it after you create the user. Is that enough info and does it answer your question? Good luck.
  4. I really recommend you to do some command line training. A Mac is just another Unix box in the end, and you should treat it like one. I would recommend you looking up Homebrew for installing PHP, as it makes it a lot easier to add new extensions to PHP.
  5. Any of you read the book yet? I would recommend it, even if you are not a Steve Jobs or Apple fan. It's a great biography of a very interesting man with a lot of passion and great stories. I found it really hard to put it down, resulting in a few sleep-less nights — a great sign for any book. I'm really curios to see how Apple will do without Jobs, as they currently beat every single laptop rival by a long shot. I've never touched a laptop without flaws, in comparison, since I bought my first Apple machine three years ago, and I think I'll end up buying my third later this year.
  6. I'm currently occupied with studies and begin the job in June. The function should work pretty much out of the box. It will return false on failure and true of DateTime accepts the input.
  7. Write a function where you create a DateTime object inside a try-catch, return true inside the try and return false if an exception is thrown. That is what I use to do. function isValidDate( $date ) { try { $dateTime = new DateTime($date); return true; } catch ( Exception $e ) { return false; } } if ( isValidDate($someDate) ) { // valid }
  8. Assign values to the super globals by key. I.e $_SESSION['user'] = $var. you also need to call session_start() before the session is available.
  9. I prefer to save all dates as UTC and use DateTime objects with DateTimezone objects to display it correctly in PHP. Is that a possible solution for you?
  10. If the file doesn't exists, you might have to create it first. Try running the following to create it: touch ~/.bashrc or just cd into the location to make sure the file's there. cd ~ ls -laG If that command still doesn't work, textmate isn't available as a command. You can try nano or just find the file in finder and open it however you like.
  11. Given the number of threads about installing HTML_Quickform lately, I begin to find the name kind of misleading.
  12. My trick for permission problems (needing to be root user) is prefacing commands with sudo and entering my password. Is there a better way I don't know about? The reason why I like seeing hidden files is it makes the two-step folder-by-folder navigation I talked about in my first post a lot easier. There's no need to be a command line ninja if you can learn the folder structure an easier way.
  13. I think that command was changed between some of the OSX updates. Try searching google for "view hidden files OSX {YOUR-VERSION}". It shouldn't be hard to find. Dump the thread if you need any more help.
  14. Your if-statements probably needs brackets. Hard to determine by watching code on this forum, but you need brackets unless your following commands are single-line. The echo statement makes them span more. I suggest an IDE like Netbeans to automaticly catch these errors, btw.
  15. Those folders are hidden on your computer. To be able to see them, you need to run the following commands: defaults write com.apple.finder AppleShowAllFiles -boolean true killall Finder If you want to hide them again (you shouldn't need to) run these commands: defaults delete com.apple.finder AppleShowAllFiles killall Finder When that is done, you should be able to find them both using Finder and the command line. The easiest way to move using the command line is to do it small steps. Use "cd .." to go back a directory, "ls -laG" to show it's content and "cd {DIRECTORY}" to go into a folder. This is much simpler than writing the fulls paths until you get used to it. Next, you want to do something called simlinking or moving the binaries to execute them without the directory path. The easiest way to do this, in my opinion, is to create a .bashrc file. This file should be placed in your user directory to influence your user. Use this command (or open it using finder - this is a hidden file, so do step one first) to open the file in textmate: textmate ~/.bashrc In that file, you can create several aliases for convenience. With the following lines, you should be able to use mysql and mysqliadmin without the full path to it. You can do the same with PHP, Sublime or anything else you want. alias mysql=/usr/local/mysql/bin/mysql alias mysqladmin=/usr/local/mysql/bin/mysqladmin # Add your own here. Google for more info Hope that helps you out. The command line is pretty easy, but you need to be familiar with the basics. You can also use the .bashrc file to enable colors, etc. PS: Keep in mind you need to close and reopen the command line for changes in .bashrc to take effect. PPS: I'm not on my MAC now, so I haven't tested any of this. Ask if you have any questions or google if you get any error messages.
  16. I really like learning by attacking specific problems. When I've gotten it to work, I reorganize/rewrite code, comment it thoroughly and try to simplify it as much as possible. When the code "feels right" and your happy about it, you move on. In the beginning, these problems where really simple. How do I insert anything to a DB? How do I load that data, place it in forms, and update any changes? How do I upload images? The key to anything you learn is to break it down into manageable parts. As for design patterns, object-oriented programming or frameworks, all of those are organizational tools, work-kits or best practices, and little more. There are tons of things to learn in the programming world, but very little of that is strictly necessary in every application. Most of these things are rooted in economics as productivity of workers and maintainability of code can be larger costs than the actual development in itself. Fixing a bug on popular code three years down the line can be a huge expense. Adding small features to crappy code written five years ago might be double the price of the original project. The point is that you should not be scared of the huge amount of knowledge that exists out there. Most of it you'll likely never need, and as with most fields you need to understand the stepping-stones to understand the advanced part. When you are ready for it, not even the advanced parts will feel that hard to learn. Challenge yourself! That is the best tip I can give you. When you've written a small application you are happy with in procedural code, try learning how to do it object-oriented. Always look for improvement and be critical of your work. Make sure to appreciate the travel, and not only focus on the goal. Programming should be fun, not stressful.
  17. It surprised me, but PHP no longer generates an E_STRICT when you call a static method through an instantiated object. (Like it used to do, and is pretty much the center of debate) I really believe it still should, but it turns out I was wrong. I don't agree with the change, but it is what it is. I still stand by all of my opinions, but I like to admit it when I'm wrong. You can "legally syntactically" call a static method though an instantiated object, but you still shouldn't as it's bad grammar and wrongly reflects the logic you are trying to communicate. I think this is a PHP flaw that will only help confuse the difference about procedural code (as static code is) and object-oriented programming.
  18. There are design and syntax reasons for not allowing it, as it doesn't make sense logically. It grays out important destinations between objects and classes. I don't think the change is a good one, but that is beside the point. As long as you fully understand the difference between objects and classes, that's really what is most important. I'm sorry if I pushed any buttons of yours along the way. It turns out PHP did change along the way, and while I don't agree with it, you where right. I try never to be to proud to admit when I'm wrong.
  19. That is mostly phrasing. This is a syntax and design oriented debate more than an anything. You can't write code like that without experts raising their brows at you. You can't write code like that without breaking object oriented syntax. You can't write code like that without raising warnings. Can you write code like that in practice? Yeah, but then you don't get the point... You might've picked upon some of my irritation explaining in previous post, and the proper answer is actually just that. You can write code like that, but then you really can't. - Not if you want to be a proper programmer and follow the rules and abstractions of object-oriented design. Code is just expression of logic, so your grammar would be wrong. Nothing in your quote nor your link contradicts anything said by me or Larry in this thread, btw. I agree with Larry that you focus too much on the lack of a PHP warning. It's still wrong according to syntax, or grammar if you like that analogy better.
  20. My new boss was already familier with you as a writer and have read several of your books. He where seriously imperessed I was asked to give you feedback on your work, no matter how small the task was. I'll send you personal updates when appropriate.
  21. I'm telling you. The error is obviously related to error reporting settings. I even tried it in practice to confirm the behavior. You CAN call a static method by object syntax in PHP, but it WILL raise a warning. You SHOULD still see that output, but PHP will warn you about the usage when you report in accordance to strict standards. The problem might be an old PHP version where those strict standards are not yet applied, but that's merely a guess.
  22. You should be able to change to joins instead and use ORDER BY then. Everything is very good. I accepted my first full-time job as a Web Developer yesterday. I'll by working with the Symfony2 Stack, EZPublish, some front-end coding and some customer meetings and sales. It's the total dream job for me. How's life treating you?
×
×
  • Create New...