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. Changing your error reporting levels WILL give you these errors. The reporting level is set to low for you to get the message. Changing your php.ini or using the ini_set() function will help: Ini_set('error_reporting', -1);
  2. This is due to error reporting settings. You'll get an E_NOTICE warining you about "Strict standards" and calling a static method in an object context. This blog post might clarify http://www.lornajane.net/posts/2010/declaring-static-methods-in-php For the second question, you need to read the part about visibility modifiers one more time. A protected method/property is only callable within the declaring class and classes that inherits from it internally. You cannot call a protected method via application code no matter why. To clarify, you wouldn't be able to use Pet::getCount(); when
  3. It's a little bit hard to understand the difference. I really like the way one of my teachers explained it. When you assign something to a variable, a memory slot is reserved for the piece of information. Think of it as a drawer in a cabinet. Each drawer is labeled, and inside you find the data. - When you pass by reference, you are sending the whole drawer and it's content. Any change to the drawer's contents will change it for anyone knowing the drawer. When you pass by reference, you are referencing the slot in memory. - When you pass by value, you are taking out the content and se
  4. I think almost anything that's supposed to be a HTTP GET request both could and should have visible IDs. There's nothing wrong, in theory, getting a user profile by a call to profile.php?id=X. The same holds true for any actions that should be publicly available to do against a user. message.php?user_id=X is totally OK in my book. That said, editing information or permission restricted actions is another case. That's pretty obvious though. To talk concretely, I would say adding a user to a private list through a ID GET param is a good solution. As long as the user should be able to add
  5. I've moved a lot of sites over the years, and most problems seems to come from php.ini settings. It's a huge pain in the butt until you figure it out. My last longstanding problem was due to bad Apache config from hosting provider though, so you never know. I usually just throw dirt at the wall and see what sticks. No method to it for me. Glad you got it sorted.
  6. Everyone goes "code blind" after a while looking at the same code. These sort of problems are so much easier to solve with a fresh pair of eyes. The debugging steps I gave you are a safe guard against that. Glad you worked it out.
  7. Take another look at your link. You've probably looked at it for too long to notice the obvious error. You are not looking for activate.php, but for activate.php12. (Where 12 would be the last inserted id.) My guess is that the link should be .php?x=12&y=MD5(). A good general tip is to use very simple debugging steps for problems like this. Don't assume $x or $y holds the correct value, print them to screen along the way. Apply a print_r() to $_GET to make sure you get the correct data, and stick some simple echo statements inside your IF/ELSE-statements to follow the flow of logic. Th
  8. No question is stupid. Everyone has to start out somewhere. The script is actually just for testing your encoding. If you can see 'Iñtërnâtiônàlizætiøn', that means your encoding is correct. If you used an older encoding - like ANSI - you would see weird characters instead of the text. The encoding basically represents your "alphabet" and characters to use. The old ANSI does not support the characters in that text. That's the whole point, really. Does that make sense?
  9. One way to "keep" files names is to insert the file/upload information into a database. That way, you can rename the actual file and just display the file name you saved to the database. Use the ID as the primary key for the information and save the image path, uploaded file name and anything else you might want to that way.
  10. The full script? This is just HTML code. Do you mean that this is the result after running the script, or are you missing all the PHP code? If this is your full script, the translation cannot happen automatically. You must add the PHP code to your script.
  11. We have very little to go on here, Adrian. No code, no link (even relative for your site) or other info needed to help you out. It will be purely guesswork. To actually guess, I would double check your assumptions are true. Is the file there? Is it Chmodded like the rest of your files (You can often check this with FTP - try right clicking the file and look for CHMOD/Permissions) and does the link actually point to the directory the file resides in? If non of that does help, please provide some more info.
  12. I came to think about this thread once I finished writing the following code. Haha! $productId = isset($_POST['sku']) ? $_POST['sku'] : isset($_GET['sku']) ? $_GET['sku'] : false; What do you guys think? Is nesting ternary operators ALWAYS bad or would you let something like that slide? To make a case for the line, an if/else statement would take way more space, and take focus away from the more important code. It will be interesting to see what you guys think.
  13. I think you are using the type "Date" instead of "DateTime" on your DB columns. NOW() should return both date and time when using DateTime.
  14. Welcome to the forums. Keep in mind that lots of error sources can be searched for. This error is a common one, and happens because PHP can't find config.inc.php at the path you specified. Make sure the file exists and that the path to it is actually correct. The last fatal error is because of PHP's include path. If a file is NOT found at include path, PHP will search in a folder named by the constant include_path. You can mostly ignore the last part and focus on the main error.
  15. One of the caveats of Larry's ability to translate Geek into English is that some of the geek gets left out. (willingly) Way to many writers are too hung up in definitions and technical phrasing that their explanations gets unnecessary complicated. Don't get to hung up in that the phrasing might be slightly different than the common technical terminology. That is often what drives the point true. ---- 2. You are correct about $this. You can choose to skip this.property or this.method() in both Java and C#. The same applies to constants and static methods and members. I would've liked t
  16. I demand "voice-to-code" functionality, Larry. And I demand it for early next week! Jon: You can often find your post in the forum cache. There's a "restore post" option somewhere. My workflow is always to press CMD + A and CMD + C to save the post before positing. You are the problem here, old man! If anyone didn't get that, I'm only joking of course.
  17. You need to follow these steps to implements such functionality: 1. Keep track of views. This can be saved in your post/article/etc table along with other info, or in a separate table with a foreign key to the article ID. Each time an article is loaded using PHP, simply update the views column in the table. (You might also use flat-files, the principle is the same) 2. Query for articles based on views. The basic query looks something like this: SELECT * FROM articles ORDER BY views DESC LIMIT 10
  18. I also love ternary. My "rule" is that I replace a ternary with a normal IF-statement when the logic is pushed to far right. Legibility is often the most important for me, so I keep that in mind. I also love the "replace logic with query" refactoring, and use that often for legibility both in if-statements and when using the ternary operator: public function something( $value ) { if ( self::SOME_MINIMUM_CONSTANT < $value && $value < self::SOME_MAXIMUM_CONSTANT ) { return self::SOME_CONTANT_VALUE; } return self::OTHER_CONSTANT_VALUE } // Too long Ternary publ
  19. They are both multidimensional arrays, yes. There's a big difference on how you structure your array, though. You assign each value for a single student to three keys in the base arrays. They are thus not logically connected to each other. You basically create three separate value arrays assigned to $arr[0 -> 2] instead of creating three students in $arr[0 -> 2]. The array you create would look like the following in "Larry's style": $arr = array( 0 => array(256, 2, 9), 1 => array("Jon", "Vance", "Stephan"), 2 => array(98.5, 85.1, 94.0) ); A structure more compara
  20. Good luck, Edward. Dealing with money is serious business, but I love the peace of mind Stripe provides. You know at least the actual payment logic is provided for you.
  21. I do that myself. You could possible use Strings too, but I wouldn't like the need for conversions. As stated, when it comes to money, you'd want as few possibilities for errors as possible. I'm also currently using an unimmutable Money class that I trust for interactions with Stripe. That way, I can perform addition and subtraction (Vouchers, shipping, summing totals for products, etc) in a Checkout object instead of using changable primitive types. The only place I use the amount as an integer is in a Stripe class that handles the actual payments. That way, what I put in stays in. Yo
  22. Save it as cents and write formatting functions for displaying dollars. Less room for errors to occur that way is my view.
×
×
  • Create New...