Jump to content

ignace

Moderators
  • Posts

    6,457
  • Joined

  • Last visited

  • Days Won

    26

Everything posted by ignace

  1. Your best bet would be to sanitize all superglobals when they come in and then use extract() whenever you want them to become local/global variables. foreach ($_POST as $key => $value) { $_POST[$key] = sanitize($value); } extract($_POST);
  2. Has many similarities with Kohana. Besides that I think it's worth a shot.
  3. You can do something like: register_shutdown_function(function() { if ($error = error_get_last()) { header('Location: error.php?ser=' . urlencode(serialize($error))); } });
  4. You can use either register_shutdown_function or ob_start to register a function that will handle the resulting output. With error_get_last you can retrieve the last occured error (fatal error). I've used this on a few occasions with success. I always use register_shutdown_function in combination with error_get_last.
  5. PHP has no direct way of saying a property should be read-only. However you can emulate it when you use magic properties: // in case of an object: public function __set($key, $val) { return ; } // in case of an array: // implements ArrayAccess::offsetSet interface public function offsetSet($key, $val) { return ; } This avoids any property being overwritten (object or array).
  6. I wish I have had such simple assignments... instead I had to create a game where a user turns 2 pictures and if they are the same they stayed or were turned back around again. Extra credits for those able to create the MP part too.. all in VB !! Life is not FAIR !
  7. Do a var_dump before placing it into the INSERT INTO statement. My guess is that it contains spaces after the T or F.
  8. 1. Put all your code in [ code]your code comes between these brackets[/code ] without the space in front and after code as in my example. 2. Why PHP? The user is going to have to wait for the page to load every time he clicks on a button..
  9. Increase only. Don't forget to add a date_voted column to the voting table or otherwise you'll have newly added photos competing against photos with a million votes. You should have different kind of rankings (this week, this month, this year, all-time). Maybe categories too if you are going to get a lot of photos.
  10. Yes. I have no idea what you mean by this.
  11. If you use PDO then you can set the result to FETCH_GROUP this will automatically do what you want: http://blog.stealth35.com/2011/08/17/pdo-fetch-group.html
  12. Did you read PFMaBiSmAd's post? You should take note to what he said and apply it!
  13. That won't do what you think it will: var_dump(strip_tags('[b]foo?[/b]')); // Output: [b]foo?[/b]
  14. Yes. But to make the querying easier you can add a votes colum to the images table and increment it everytime it receives a vote. The voting table then keeps a record of which user's voted for the image. To select two random images from your table I would suggest you read: http://jan.kneschke.de/projects/mysql/order-by-rand/
  15. Try: if (trim($line['action']) == "wow_displayed") { Edit: Do as instructed by PFMaBiSmAd
  16. Try this: global $wpdb; $aPost = array(); $sDB = $wpdb->get_results("SELECT my_title, my_content, my_order FROM my_table"); foreach ($sDB as $sDBOutput) { $sATitle = $sDBOutput->my_title; $sAContent = $sDBOutput->my_content; $sAOrder = $sDBOutput->my_order; $sCompiled = '<div class="title">' . $sATitle . '</div><div class="content">' . $sAContent . '</div>'; if (isset($aPost[$sAOrder])) { // debug line echo 'overwriting existing key ' . $sAOrder . ' original: ' . $aPost[$sAOrder] . ' new: ' . $sCompiled . '<br>'; } $aPost[$sAOrder] = $sCompiled; }
  17. If both do the same then use str_replace instead of preg_replace. The former is considered much faster.
  18. Selecting month/year: SELECT * FROM sometable WHERE MONTH(STR_TO_DATE(`date`)) = $month AND YEAR(STR_TO_DATE(`date`)) = $year Selecting a specific week: SELECT * FROM sometable WHERE WEEK(STR_TO_DATE(`date`)) = $week AND YEAR(STR_TO_DATE(`date`)) = $year Like pikachu already mentioned you should add a new column with the proper date format (and data-type) and use that onwards.
  19. Download TextWrangler: http://lmgtfy.com/?q=TextWrangler
  20. $aWords = array(1, 2, 4, 5, 7, 12, 15); $aTranslate = array( 1 => 'bread', 2 => 'piza', 3 => 'water', 4 => 'cornflakes', 5 => 'word5', 6 => 'word6', 7 => 'word7', 8 => 'word8', 9 => 'word9', ); foreach($aWords as $key => $value) { $alt = ''; if (isset($aTranslate[$key])) { $alt = $aTranslate[$key]; } echo '<img src="http://example.com/imagepath/' . $value . '.jpg" alt="' . $alt . '"><br>'; }
  21. IMO that LEFT JOIN should be just JOIN. Since you are selecting only games.* related info you'll end up with a result row that has NULL** as value for both columns when a game does indeed end up in the basket yet managed to disappear afterwards. To the customer it will end up as an empty order line in the checkout. ** Assuming the OP did not use INNODB with a referential ON DELETE constraint.
  22. Pick up a good book on PHP and start reading. PHP has a very low level to entry.. (Imagine the blank page in front of you is your main() body and the full set of library functions pre-#import'ed). Something any .NET vet should pick up in a weekend. Just because it is out of your confy zone doesn't mean you have to add unnecessary layers like Phalanger to avoid to actually have to learn a new language.
  23. Here's a very simple example using jQuery: http://jsfiddle.net/BqEDF/1/
×
×
  • 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.