Jump to content

awjudd

Staff Alumni
  • Posts

    422
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by awjudd

  1. Then that is the problem. BETWEEN will only work how you want it if the columns are DATETIME. You should do as Pikachu2000 said to insert the dates in then it should work. Assuming you change the data type to DATETIME. ~juddster
  2. http://php.net/string More specifically this piece right here: '$_POST[id]'. That will always return the same value. if you echo it you will see that it is saying $_POST[id] exactly how you have it. <?php session_start(); if ($_SESSION['cart']['content']['id'] == $_POST['id']) { $_SESSION['cart']['content'][$_POST['id']]['quantity'] = $_SESSION['cart']['content'][$_POST['id']]['quantity'] + $_POST['quantity']; } else { /* You were just appending it to the array but you are doing a search for it above so you need the actual id as the index */ $_SESSION['cart']['content'][$_POST['id']] = array ('id' => $_POST['id'], 'size' => $_POST['size'], 'quantity' => $_POST['quantity']); } echo '<DIV class="result">Added to cart.</DIV>'; ?> ~juddster
  3. Are you using a DATETIME column to store the date or something else? ~juddster
  4. You can't make a default value of a variable. In order to do what you want you should change it to something like this: public static function is_valid ( $method = NULL ) { /* Check if it is NULL, that means just use $_POST */ if ( $method === NULL ) { $method = $_POST; } } That said the variable name is very misleading. If I read a variable named $method, I would think it would be something like 'POST' / 'GET' however, you are using it as the array to validate. So I would change that accordingly to make the code more readable. ~juddster ~juddster
  5. You would replace that code with mine. ~juddster
  6. Oops, sorry about that user typo Please mark this topic as complete ~juddster
  7. 1 - http://php.net/ereg - an old regular expression match (RTFM) 2 - It would either make your current else an else if OR it would just consume the body of your else statement 3 - They are automatically defined for you. You just change the variable you are reading from, from $_REQUEST --> $_POST else if ( isset ( $_POST [ 'button' ] ) { // Required field error echo 'Required fields are empty'; // Lets fine out which one(s) $nameError = ($_POST['name'] == '' ? true : false); $emailError = ($_POST['name'] == '' ? true : false); $enquiryError = ($_POST['name'] == '' ? true : false); } else { $nameError = false; $emailError = false; $enquiryError = false; } ~juddster
  8. The query I provided and the one that you changed it to are two completely different queries. The one you changed it to does an ANSI JOIN without any conditions making it a CROSS JOIN. What part of my queries didn't work? Did they take too long to execute or what? I noticed a typo in my query: SELECT u.User_email, lt.last_time AS last_signed_in, r.last_time AS reminder FROM Users u LEFT JOIN ( SELECT User_id, MAX(log_time) AS last_time FROM log01 WHERE log_type = 3 GROUP BY User_id ) lt ON u.User_id = lt.User_id LEFT JOIN ( SELECT User_id, MAX(log_time) AS last_time FROM log01 WHERE log_type = 12 GROUP BY User_id ) r ON u.User_id = r.User_id ~juddster
  9. About which comment that I made since there are three ... ~juddster
  10. I would add in a check either with the ereg (deprecated - should be using the preg family of functions) to see if all of the required values have been set before attempting to send the email. If you want to keep it in your else, just put it in an if statement. For example: if ( isset ( $_POST [ 'button' ] ) ) { echo 'Required fields are empty'; /* Extra code */ } That said, you swap between $_POST and $_REQUEST. I would make that consistent because you don't want some things coming from the URL or a cookie and others from $_POST. ~juddster
  11. Please remove all of the extra whitespace because nobody is going to read the code if they have to scroll down pages and pages to read it. ~juddster
  12. Move the header function call to after the mysql_close call. This will ensure that it was successful before redirecting. ~juddster
  13. You have MD5 as your password however, in your INSERT query you are using SHA1(CONCAT(UPPER('$usr'),':',UPPER('$var'))) to insert the encrypted password. You need to be consistent if you want to pull the data back. ~juddster
  14. awjudd

    Better method

    Using JOINs makes it insanely easy. SELECT r.ItemID, it.ItemTitle, SUM(r.Rating) AS mr FROM dd_rating r JOIN dd_items it ON r.ItemID = it.ItemID GROUP BY r.ItemID, it.ItemTitle ORDER BY mr DESC LIMIT 0, 4 I'm not sure why iblood isn't a fan of JOINs but that is just crazy. ~juddster
  15. Something like this should work: SELECT u.User_email, lt.log_time AS last_signed_in FROM Users u JOIN ( SELECT User_id, MAX(log_time) AS last_time FROM log01 WHERE log_type = 3 GROUP BY User_id ) lt ON u.User_id = lt.User_id JOIN ( SELECT User_id, MAX(log_time) AS last_time FROM log01 WHERE log_type = 12 GROUP BY User_id ) r ON u.User_id = r.User_id Basically the problem is you are having is that effectively making a CROSS JOIN for the log table which is going to be bad ... Another approach is: SELECT Users.User_email , MAX(CASE WHERE lt.log_type = 3 THEN lt.log_time ELSE NULL END) AS last_signed_in , MAX(CASE WHERE lt.log_type = 12 THEN lt.log_time ELSE NULL END) AS last_reminder_sent FROM Users u JOIN log01 AS lt ON lt.log_usr = Users.User_id WHERE l.log_type IN ( 3, 12 ) Basically the first query will go against the log table and find the maximum log time for each user for the reminders and log in times and then just use that in the outside. This will be able to run quicker than yours is currently because each table will be returning up to 1 row per user. The second one which I think is a bit cleaner but could be slower. It is essentially just grabbing all of the rows where the log type is either 3 or 12 and then processing it in the MAX function (determining what to send) based on the log type. Does this make sense? ~juddster
  16. By using JOINS instead of IN SELECT p.product_num FROM products p JOIN tconversions t ON p.product_id = t.to_product_id to_product_id JOIN products p2 ON t.fr_product_id = p2.product_id WHERE p2.product_num = '$product_num'
  17. For the comments table join since it is a LEFT JOIN, if there are no matching results then it will return NULL. Because of that you should be adding your condition for the status on that table = in the ON clause instead of in there WHERE clause. Because if it appears in the WHERE clause it needs to find a comment to show up (you could just have the condition as: tblComments.comments_status = 2 OR tblComments.comments_status IS NULL). ~juddster
  18. Have you indexed your tables? Have you run EXPLAIN on your queries to see how it is actually being run through the query engine? ~juddster
  19. And by plugin I mean open source project / api. ~juddster
  20. Try the stuff from their documentation with their use of children? Or better yet: $visitior = $visitor -> find ( 'td a', '1') -> innertext; I have never used this plugin before so it is just a guess. ~juddster
  21. By having a LEFT JOIN and then following that up with a WHERE clause using where you are requiring a value of that field, you are removing the use for the LEFT JOIN. ~juddster
  22. I would go one layer deeper where you are looking for 'td' and actually look for the 'a' tag. Then you would be able to grab the innertext. /* An extension to your code */ $visitor = $visitor->find('td','1')->find('a','1')->innertext . "<br>"; ~juddster
  23. != is does not equal, not /= That said, there is a very much an easier way of doing this ... /* Check if the dice and roll match */ if ( $roll == $dice ) { /* They do, congrats */ print "Great Job, You're Good!"; } else { /* They don't, too bad */ print "Wrong"; } /* Print the dice number */ print "<img src='dice" . $dice . ".png'>"."<br />";
  24. Please use the [ php ][ /php ] tags for your code (minus the spaces). ~juddster
  25. Please mark this thread as resolved if we have resolved your issue. If you have any other questions please feel free to drop by the IRC channel. I am on all of the time (sometimes AFK) but there is always someone to help. ~juddster
×
×
  • 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.