Jump to content

obsidian

Staff Alumni
  • Posts

    3,202
  • Joined

  • Last visited

Everything posted by obsidian

  1. Run a cron job with the following query: DELETE FROM entry_table WHERE entry_date < CURDATE() - INTERVAL 2 WEEK;
  2. Check out the sleep() method. This will cause your script to delay continuing execution for X number of seconds, but it literally freezes the execution of the entire script that long, so it will appear that nothing is happening. This may not be the action you are seeking, so feel free to clarify further.
  3. Great! Thanks for the clarification. I was definitely not making any accusations, but without more comment than "hack this", I just wanted to make sure. Good luck!
  4. Lamez, this is your own site, correct? Just wanted to clarify.
  5. For this type of thing, AJAX is really overkill. He is simply trying to generate his JavaScript with PHP, and conceptually, he has it right. Let's try to help with the syntax and where the error is actually occurring in the code. I think that if we can see the source code of the rendered page, we may be able to assist in a better way. Out of curiosity, are there any JavaScript errors being thrown if you view the page in FF with the Firebug plugin?
  6. There are really a couple things that may be happening, but most likely, it is an issue with quotes or some other character interfering with your JavaScript code when your PHP spits it out. Try cleaning up your code some with this type of thing: Change this: <?php $disp .= "SlideText[$j] = \"$faqQ<br />$faqA\";\n"; ?> To this: <?php $disp .= "SlideText.push(\"" . htmlentities($faqQ, ENT_QUOTES) . "<br />" . htmlentities($faqA, ENT_QUOTES) . "\");\n"; ?> Also, it would be helpful to debug if you could provide us the text that is actually getting echoed out, too.
  7. You really ought to read up on the overviews of what the language does, and some of your questions may be answered: XML Namespaces These pages should more than explain your questions, and you should also have a great idea of what it can be used for as well. Hope this helps.
  8. First off, a question: why not? When you echo HTML entities into a textarea, they are interpreted, so you should be fine with storing them as that. Secondly, though, you shouldn't do any display parsing (htmlentities and such) on INSERT into database, only when you retrieve it for display. When you insert, you should only worry about data escaping and protecting against SQL injection. Then, when you output that data, you can parse or modify it as needed for the environment in which you are working.
  9. It really depends on what the type of your output is. If you are echoing to a plain text file, what you have will reflect the spaces in the output. On the other hand, if it is in HTML, you need to echo out the HTML entity for spaces: <?php echo " Just a simple text"; ?>
  10. CSS is not used to replace text directly. The determining factor to whether or not to use CSS in this case (to me, at least) is to determine whether you want the menu to have any change or rollover effect. If you are wanting to have the images replace the text and change on hover, I would definitely recommend having the CSS menu. If you are wanting the images to be static, I would recommend having them placed statically within <img /> tags on your page.
  11. That is not always the case. Sometimes, people achieve a sleek, fast rollover effect with CSS that otherwise would take quite a bit more markup and JS. Grant it, this is usually within anchor tags, but there are exceptions to every rule
  12. If it is a true image on your page, I would highly recommend using img tags for what they are intended. Doing so allows you to add alt attributes and other SEO items which would otherwise be unusable with CSS. Also, keep in mind that screen readers for the visually impaired will not pick up your styles, so if they are viewing your page without CSS applied, they will completely miss your images.
  13. My initial question is this: is the movement of your character restricted within the 11x11 grid, or is this grid only the viewable area of a larger map in which your character need always remain at the center? The approach for the motion would be different in those two scenarios, but the grid idea would be the same... Basically, think of the grid as a multi-dimensional array (very like a battleship board), where you have an x and y coordinates. Then, you can build a simple class to manage the grid itself and even a GridPoint class if you wanted, to help manage the contents of each point on the grid. Something like this should at least get you started: <?php class Grid { /** * @var array $coords; */ protected $coords; /** * @param int $x width of the grid * @param int $y height of the grid */ public function __construct($x, $y) { $this->coords = array(); for ($i = 1; $i <= $x; $i++) { for ($j = 1; $j <= $y; $j++) { // Load the positions with an empty value to be filled. $this->coords[$i][$j] = NULL; } } } public function loadPoint($x, $y, $contents) { if (!isset($this->coords[$x][$y])) { throw new Exception('Invalid coordinates provided!'); } $this->coords[$x][$y] = $contents; } public function getPoint($x, $y) { if (!isset($this->coords[$x][$y])) { throw new Exception('Invalid coordinates provided!'); } return $this->coords[$x][$y]; } } ?> Hope this is at least a good start for you. Good luck!
  14. Add a border="0" attribute to the img tag itself. Then, if you wish to style the border of the image with some hover effect, just do something like this: a img { border: 1px solid #000000; } a:hover img { border-color: #ff0000; } Good luck!
  15. What is your actual definition of the float column? For currency, I usually will use FLOAT(6, 2) where the "2" is the number of decimal precision you wish to store.
  16. This is "sticky forms," and a Google search will give you a world of help, but the gist is this: <?php $email = isset($_POST['email']) ? htmlentities($_POST['email'], ENT_QUOTES) : ''; ?> <input type="text" name="email" value="<?php echo $email; ?>" /> Good luck!
  17. I understand that, but I'm trying to show you that there is a difference between calculating based on day of the month and a true number of days. If you calculate solely based on the number of days in the month in which the client signs up, you are going to have people who have different length cycles. For instance, if you sign up someone in February, their cycle is only 28 days (unless they sign on leap year, and then it is 29); however, if someone signs up in January, they get 31 days per cycle. It's not a good business practice to have people with different length cycles for the same type of membership. On the other hand, if you simply define the fact that ever cycle is 30 days, you can easily calculate the billing cycles: <?php $length = 30; // in days $signup = '2007-01-15'; list($y, $m, $d) = explode('-', $signup); // Next 10 billing cycles for ($i = 1; $i < 11; $i++) { $cycle = mktime(0, 0, 0, $m, $d + ($i * $length), $y); echo date('m/d/Y', $cycle) . "<br />\n";; } ?> Also, I'm not posting exact code to solve your problem, but I am trying to give you a concept that you can apply to your own code and fix your problem.
  18. Is this also the case for February? If so, you have a shorter billing cycle for one customer than another. Now, on the other hand, if the rule is simply that the billing cycle is the same DAY of the month every time, it is extremely easy to calculate (except you need to account for the months with fewer days). So, let's assume you sign up on the 31st of January, when it comes to April, does your bill fall on April 30 (last day of the month), or does it fall on May 1 (31 days after April 1)? Here is how I would recommend finding out when the billing cycles would end: <?php $signupdate = '2007-01-31'; // January 31, 2007 list ($y, $m, $d) = explode('-', $signupdate); // Let's get all the billing dates for last year while ($m < 13) { // See what the last day of the month is $lastday = date('t', mktime(0, 0, 0, $m, 1, $y)); // If the last day of the month is less than the current day, use the last day instead if ($lastday < $d) { $billtime = mktime(0, 0, 0, $m, $lastday, $y); }ยทยท else { $billtime = mktime(0, 0, 0, $m, $d, $y); } // Print out this bill cycle echo date('M j, Y', $billtime) . "<br />\n"; // Increment to the next month $m++; } ?>
  19. An aggregate is any "grouping" of records, such as SUM, AVG, COUNT, etc.
  20. Just another thought... you could also just split up your queries with a loop, too: <?php $queries = explode(';', $sql); foreach($queries as $q) { $q = trim($q); mysql_query($q); } ?> This way, you can still set up your create statements in one file or variable and parse it out separately. Be careful, though, because this rudimentary illustration will break if you are inserting any values that contain semicolons.
  21. No, what I'm saying is that you cannot execute multiple SQL statements in a single query: <?php $sql = <<<EOQ DROP TABLE IF EXISTS mytable; CREATE TABLE mytable (...); EOQ; mysql_query($sql); ?> That does not work. You have to query each individually: <?php mysql_query("DROP TABLE..."); mysql_query("CREATE TABLE..."); ?>
  22. OK, for kicks, let's just ignore the line number for a minute, because who knows what the validator does to break up the code. From my quick Google search, it seems that your error is on the pound symbol on your pages. The following code supposedly puts out a valid pound symbol: <?php echo utf8_encode("\xa3"); ?> That's the value you're getting in your error, too... Anywhere you're trying to echo utf8 compliant characters differently? I know it's a shot in the dark, but it's worth a try.
  23. In PHP, you cannot send multiple queries to a single mysql_query() call. You would have to actually send each query individually. Other DBs, such as Postgresql, do allow this behavior, but the MySql connections in PHP do not.
  24. We have run into similar things with character and byte reading issues at work, because we have to keep all our stuff unicode compliant for our internationalization. Out of curiosity, what is contained within the comment block (non-alpha characters, specifically). If I remember right, /xa3 is a pound sign, but I can't remember for sure. It seems as though the output to the page is not utf-8 compliant. It is also possible that the W3C validator may have the wrong mapping for a specific character (unlikely but possible). If you don't mind posting the comment block, that may help some.
  25. You cannot have aggregates in your where clause that way, but you can sort on the time_posted column and limit to one: SELECT * FROM tablename WHERE post_number = $post_number ORDER BY time_posted DESC LIMIT 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.