Jump to content

BLaZuRE

Members
  • Posts

    104
  • Joined

  • Last visited

    Never

Everything posted by BLaZuRE

  1. I'd go with a unix timestamp or a DateTime class.
  2. I'm going to create a cron job to automatically backup my databases using --all-databases. Since I'm paranoid about security, what do I need to grant the user? I know I'm granting SELECT and LOCK TABLES, but I've noticed that some people say to add RELOAD or SHOW DATABASES. What do you recommend? Also, I haven't studied closely how mysql is backed up, so how do RELOAD and SHOW DATABASES work for it? This is for version 5.1
  3. Moodle's an entire framework/application for teaching environments made from PHP and MySQL. I thought maybe your code was from it. Anyway, your error is telling you exactly what's wrong (for once ). Your function insert_student_course() accepts 4 arguments, function insert_student_course($id, $id, $grade, $comments) { but you send 3 $numofrows = $db1->insert_student_course( $sql = "SELECT STUDENTS.SID, STUDENTS.SNAME, STUDENTS.PHOTO, STUDENT_COURSE.CID, STUDENT_COURSE.GRADE FROM STUDENTS, STUDENT_COURSE WHERE (STUDENTS.SID LIKE '$SID%')", $grade, $comments); Also, there's an ambiguity in your function. There are two arguments that accept $id. Which is the real $id? I'm not sure what the rules are for PHP, if any exist, for that scenario.
  4. This worked for me SELECT (DATE_ADD('2011-01-01 23:01:02' , INTERVAL '5:01:02' HOUR_SECOND ) ) FROM test So try SELECT (DATE_ADD(date_posted , INTERVAL expiry_time HOUR_SECOND ) ) FROM comments Both should be used as strings, so you shouldn't need the single quotes.
  5. That's your error. You're making a query of the result or the error. Also, you should be checking whether your query returns FALSE (if not a valid query, which is different from returning 0 rows), that way you know whether your result is a valid resource or a boolean value. I'd say echo out the query where or before it errors and test for yourself directly (in MySQL or phpMyAdmin) and see what it returns.
  6. I have tons of ideas, but then I'd spend hours of coding and GIMP'ing and I would probably end up with a flashy website I'd probably want to keep for myself . Try http://php.net/manual/en/reserved.variables.get.php, http://dev.mysql.com/doc/refman/5.0/en/select.html, http://php.net/manual/en/function.echo.php. You have to get the variables (sanitize and validate if you know how), query the game you want by using your id variable, echo out the title and content using PHP. If those pages don't make sense to you, then look up MySQL and PHP tutorials on the Internet. Update us if you have more specific questions.
  7. Maybe use php date() function to determine which day returns the weekday you want. Then, you'll be able to increase the date by 7 days and use that day in your queries and count which week of the year it is. I don't see a real need for anything like that except if you're doing workweeks. In that case, you might building a full fledged application that needs to worry about DST, leap years and seconds, salary vs hourly, pay periods vs work weeks, etc. Sorry, venting
  8. I never allow users to delete rows. They may delete something they shouldn't and whine later. Yes, I would set a column to deleted with tinyint. I don't see it as a big performance hit. If you have hundreds or thousands of rows, consider exporting them to another table or database or deleting them if it's reasonable every X days/weeks/months. It such a scenario, I'm worried more about code performance than database performance. i.e., if you connect multiple times to gather the same data.
  9. Okay, so make sure that column allows NULL values and make it NULL. Well, check the id. If it's less than 10, echo out a leading 0. Also, your form action leads nowhere. I think you're trying to send to the same page, so put your page in there. What happens if you don't submit an ID and what happens if that's the first time you visit that page? Is that elsewhere in your code?
  10. Post code around line 50. Just because it says line 50 means it's line 50. The interpreter is making its best guess. Also, post what's in insert_student_course() (and what calls it?). Use the # (Insert Code) button from the toolbar above the smilies so the code is more readable. Also, try running the query on line 50 on your own in phpMyAdmin to see whether it works or gives you an error. This wouldn't happen to be for Moodle would it?
  11. Yes, it'll work. Though, if I had the time, I would see what mayhem would occur by looking at the source code, copying the javascript page it redirects to, and see what renders without the javascript. But that's just me.
  12. No idea on your first one. Post code to clarify. For your javascript: yourVar = <?php echo $i+1; ?>; You missed your semicolon in the php code you posted. Also, php will execute before your javascript, so $i will evaluate before yourVar is assigned.
  13. I've never tried substr with something besides the English alphabet. When I viewed the source code, though, I got HTML Entities. Could that be the problem, one of the entities being sliced?
  14. Also, something to remember about using single and double quotes that may confuse some people. When including a variable in double quotes, i.e. echo "Hello $name[key]"; , no quotes around key. However, if you use single quotes or no quotes: echo 'Hello' . $name['key']; or echo $name['key'];
  15. Yeah, that'll look too, but I like to think my way's fancier
  16. Since you know what type of data you're going to get, I suggest using RegEx to validate the ID and key. For example, [0-9]{4} should work for a 4-digit number. That way, you know you're never being given anything besides a 4-digit number. Substituting {1,4} would test for 1 to 4 digits. Look into preg_match and learn about Perl Regular Expressions. I'd error on no match rather than on empty var. As it is right now, your code only helps prevent from SQL injection and may be vulnerable to HTML or PHP injection (though there is a limit on $_GET parameter length).
  17. Sorry, but I got confused by your use of 'above'. Above the page = Stuff not on the page but on top, like an address bar or a toolbar. The top of the page = Stuff on the page at the top. Above the content = Stuff not in the content, but on top of it (but still on the page). AJAX involves the client (the person/computer browsing your page) to allow JavaScript. I personally turn off JavaScript because I don't want to hassle with its vulnerabilities, pop-ups, or pages that won't close. Also, I prefer functionality over 'flashiness' and don't believe in requiring proprietary add-ons or plug-ins. So I'd recommend having a page without AJAX navigation or if you go the AJAX route, provide an alternative. It'll also score you brownie points with search engines.
  18. Go down your code and add exit(); If it's not the problem area, you'll probably load instantly and have only the output to that point, if any unbuffered. If you've past the section with the problem loading, you'll probably stay loading as it is right now. You should be able to track it down by adding exit(), testing, and removing and regular intervals in your code. If not, you'll at least know which few lines of code may be the problem.
  19. You need to correctly tab your code so your opening and closing brackets align. You'll probably see your error that way. I think: array_push($e, $fulldisp); may be the problem. It's outside the if,then section, meaning it is not checked whether it is an array or not. Can you tell us which is line 40, the line it errors on?
  20. Use Google Webmaster Tools. Go under a section called something like HTML Suggestions or Errors similar. You'll be able to see that it doesn't like duplicate titles and probably has a tip on that.
  21. Depends. If you're going to have a static list or one that doesn't change much, I'd suggest making a static unordered list (using CSS) with HTML. I don't know why you would load XML. If your links change for some reason (though I don't really see this), you can load from a database.
  22. Relative paths don't work the same way in PHP as they do in other languages. Paths are tracked at runtime and are not relative to the executing script. You can add and concatenate dirname(__FILE__) to your path instead in front of ../ Edit: mistyped. You still need to change directories. Anyway, I forgot about the new constant: __DIR__ which is the same as the code given above (php 5.3+ only)
  23. You say you have a posted date and expiry date. Please elaborate. Date is different from datetime which is different from time. Also, you have a syntax error for the interval of date_sub. I'm not sure if date_sub will work the way you want it to. Timediff is giving you a negative time. Try troubleshooting yourself. Make sure you're getting the values you want by 'echo'ing them throughout the code.
  24. I don't know what you mean by 'keywords', but you can try PHP DOM http://php.net/manual/en/book.dom.php
  25. http://www.w3.org/TR/html4/present/frames.html#h-16.5 You can adjust the width and height of the iframe, but you can't make it a 'mini-browser window'. If you have access to the framed website, however, you can make some of the measurements percentage instead of fixed. That way, it conforms to its windows better. Experiment by just resizing your browser window. You'll see it's impossible to not have a vertical scroll on some websites at certain widths..
×
×
  • 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.