Jump to content

akitchin

Staff Alumni
  • Posts

    2,515
  • Joined

  • Last visited

    Never

Everything posted by akitchin

  1. indeed it should be, provided you have fixed your queries.
  2. let's see if i can guide you through this in simple steps: 1. $regdate holds a value, in days, of `nextduedate` from the table `tblhosting`, 2. once you fix your queries, $duedate will hold a value, in days, of `duedate` from the table `tblinvoiceitems`, and 3. subtracting one of those variables from the other will give the difference, in days, between the two dates. based on those facts, how do you think you could check whether the difference between those two dates is 32 days or more?
  3. if you're using MySQL, you can use their date/time functions as well, which are quite robust and handy: http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html
  4. this section: $hosting_get = mysql_query("SELECT TO_DAYS(nextduedate) AS age_in_days_due FROM `tblhosting` WHERE domainstatus = 'Active'"); while ($hosting_pull = mysql_fetch_array($hosting_get)) { $userid = $hosting_pull['userid']; $orderid = $hosting_pull['id']; $billingcycle = $hosting_pull['billingcycle']; $regdate =$hosting_pull['age_in_days_due']; $username = $hosting_pull['username']; is flawed. you're not SELECTing anything other than the `age_in_days_due` column, so `userid`, `id`, `billingcycle` and `username` won't be defined. that causes the second query to grab nothing, since $orderid is not defined. add those other columns to the SELECT query. second, this condition: if($duedate >= $regdate) { just checks if the $duedate is greater than or equal than $regdate, with no mention of your 32-day delay.
  5. TO_DAYS() converts the given DATE into the number of days since year 0. in order to get the difference in days between `nextduedate` and `duedate`, SELECT the TO_DAYS() of both of them and take the difference. therefore, change your SELECT expressions from: TO_DAYS(NOW()) - TO_DAYS(datefield) to: TO_DAYS(datefield) you can use the same alias if you want.
  6. there has obviously been some miscommunication here. are you looking for the difference between `nextduedate` and `duedate` in number of days?
  7. if you're storing the dates as a DATE in MySQL, you can use their date functions. in particular, look at TO_DAYS(): SELECT (TO_DAYS(NOW()) - TO_DAYS(date_column)) AS age_in_days FROM table
  8. this is pretty much the most straightforward method - i can't think of anything that would be more efficient. if you want a strict weekly quota (that is, they can log in once per week, every week, rather than forcing a week between logins), you should use WEEK(). this would be useful in the scenario that the user logged in Friday, but should be allowed to log in the following Monday as it is a new week. if you're comparing the straight difference between current date and login date, they won't be allowed back in until next Friday. by using WEEK(), you can boil the dates down to which week they are in.
  9. one way would be to split by the space characters, and then run an array_intersect against the results: $first_sentence = 'Does the do jump over the lazy sheep or the spotted cow?'; $second_sentence = 'The dog jumps over the lazy sheep.'; $first_components = explode(' ', $first_sentence); $second_components = explode(' ', $second_sentence); $duplicate_words = array_intersect($first_components, $second_components); print_r($duplicate_words); note that this won't take into account periods and will be case-sensitive. to avoid case sensitivity, you can use strtolower against the original string, as well as str_replace to replace any characters you don't want interfering such as punctuation. have a look in the manual at the other intersect functions if you want to play around with key preservation.
  10. have you tested whether this is the case? if it is, then technically after you use splice() that same index should echo a different value: for (stuff) { alert('pre-splice index is '+i+' with a value of '+arrayName[i]); arrayName.splice(i,1); alert('post-splice index is '+i+' with a value of '+arrayName[i]); } EDIT: if this is the case, then one way around it is to set that value to null rather than splicing it out, and ignore any null values in all future loops. alternatively, you could try the following syntax for the for() loop: for (var i in arrayName) not sure if that will alleviate your issue if you continue to use splice() though.
  11. the LEFT OUTER JOIN will cause each set of data from the person_data table to be appended to each individual cemetary. this is terribly inefficient, since you don't need that data, you simply need the count. a subquery would most likely be markedly faster. admittedly i am not totally up to snuff on my subquery syntax, but give something like this a shot: SELECT c.cem_name AS cemetary_name, (SELECT COUNT(*) FROM person_data AS p WHERE p.cem_id=c.cem_id) AS total_victims FROM cemetary_data AS c WHERE SUBSTR(c.cem_name,0,1) = 'A' AND c.cem_county = 'Smith' ORDER BY c.cem_name ASC
  12. pull the array length out of the for() loop, and instead put in a static variable: for_loop_length = arrayName.length; for(var i=0; i<for_loop_length;i++ )
  13. what do you mean by duplicate lesson - do you mean the same user_id on the same day? and how are you storing the times? in the XX:XX format? if so, you'd be wiser to store them as integers without the colon, as this allows for more straightforward calculations. you should also store your dates in DATE format, because this offers a lot more flexibility in how you SELECT your data.
  14. what does your table look like? and how are multiple bookings handled with regards to s_time and e_time? do you simply extend them? what about gaps in the timetable?
  15. i think you may want to make english and communication skills a bigger priority than learning the latest and greatest development trends...
  16. your calculation should be that either both proposed new booking times are less than the start time of the other, or greater than the end time: WHERE request_date = '$request_date' AND ($s_time < s_time AND $e_time <= s_time) OR ($s_time >= e_time AND $e_time > e_time) it's a bit redundant to check whether the proposed booking end time is greater than e_time in that second time clause, since if the starting time is after the end time of the other booking is sufficient (presuming $s_time < $e_time).
  17. in addition, $sitename will not exist in change_nick()'s scope because you aren't passing it to the function or declaring it as global.
  18. this would be a fairly quick test - echo the session ID before using session_id(), then echo it afterward and see if it has changed. i have a feeling it would not work in the case of autostart being on, but it never hurts to check.
  19. we certainly can. it's this little site called "google," and it works phenomenally well . ask google about it
  20. i would say you can store any information on your own servers (provided you let users know and you have a privacy policy they can read) except credit card numbers, verification codes, anything to do with financial identifiers.
  21. google the paypal IPN and have a look through their developer's resources. regardless of what method you choose, you should NOT be storing the user's payment information in your own database. that should be left to the credit card processors, who can guarantee the safety of that information.
  22. why exactly is the form sending to enemy.php and redirecting? how are you trying to process the forms on fcenter.php? if the first form is sent, then $_POST['choose'] will be set. to execute the code for form1 on submission, use: if (isset($_POST['choose'])) { // form1 execution } if the second form is sent, then $_POST['confirm'] will be set, but not $_POST['choose']. for the form2 code execution, you can use: if (isset($_POST['confirm'])) { // form2 execution } these can easily go on the same page in the header, and only one statement will process on any given page submission. in fact, to make it all streamlined, you could go: if (isset($_POST['choose'])) { // form1 was submitted } elseif (isset($_POST['confirm'])) { // form2 was submitted } else { // nothing was submitted } perhaps i'm missing something here.. EDIT: note that if you want the information from form1 to post along with the information selected/posted from form2, you will need to add hidden inputs into form2's code to plug that information in.
  23. that's correct. except when magic_quotes_gpc() is on, this has already been done to your data. you are obviously doing it a second time when you run addslashes() on your data prior to inserting it, and so all those backslashes end up being double-escaped: // say O'Reilly was submitted via the form echo $_POST['data']; // echoes "O\'Reilly" echo addslashes($_POST['data']); // echoes "O\\\'Reilly" you seem to be inserting the second one into your database, and so actual backslashes (rather than simply escaping ones) are being inserted. to correctly match the string to the database, you will need to run addslashes() twice. as pfmabismad says, the ideal solution is to fix the code that inserts the data in the first place so that only one set of escaping slashes has been added.
  24. if the value itself in the database has a backslash before the single quote, it means it was inserted with two sets of escaping slashes - and the slash is technically a real character. to search against the database and grab that value, you'll want to run addslashes() against the value (since magic_quotes has already applied the first set of escaping slashes).
  25. resetting the primary key, or filling in gaps, ruins the referential integrity of the database. the whole reason that gap is there is because there once was an entry, and is no more - that points to the fact that any other records using that key in their entry are orphaned. it's important to know these things, and if it isn't, then having that key is a little pointless in the first place.
×
×
  • 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.