Jump to content

MmmVomit

Members
  • Posts

    319
  • Joined

  • Last visited

    Never

Everything posted by MmmVomit

  1. Since GET variables are sent through the URL, you're going to be most limited by URL length. http://www.google.com/search?hl=en&q=maximum+url+length
  2. I've got a basic many-to-many relationsip set up in my database RECORD ------------- ID RecordData TYPE ------------- ID TypeDescription RECORD_TYPE_JUNCTION -------------- ID RecordID => RECORD.ID TypeID => TYPE.ID What I'd like to do is restrict the specific combinations of types are allowed. In general each RECORD will only get one TYPE, but there are certain combinations of types that I need to make possible. I've come up with a solution by adding a GROUP table. GROUP ----------------- ID Group TypeID => TYPE.ID The data in this table would look something like this. GROUP ----------------- ID Group TypeID 1 1 1 2 1 4 3 1 5 4 2 2 5 2 4 6 3 2 7 3 5 8 3 7 A valid combination of types would be (1, 4, 5), (2, 4), or (2, 5, 7). If a type does not appear in the GROUP table, it is a singleton and is not allowed in combination with any other types, e.g. 6. Any subset of a valid group is allowed, so (4, 5) is allowed, because it is a subset of group 1. Does anyone see drawbacks to this? Is there a better way of doing this?
  3. Here are two options. 1) You send everyone to the same page on login and alter what is displayed based on the user's permissions 2) Send everyont to a page the checks the user permissions, then redirects to the proper page.
  4. Not to mention some comments.
  5. What email? Your script doesn't send an email.
  6. What is the point of these two lines? <?php $rand_x=$rand_x; $rand_y=$rand_y; ?>
  7. You want to read one of the many pagination tutorials floating around the net. There are even some on this site. GIYF.
  8. My first instinct says use three queries, but others with more experience may know a better way.
  9. I think this could be solved using a dynamic programming or memoization approach. I'm rusty on my algorithms, though, so can't come up with much more than that.
  10. What are you doing? I'm genuinely curious.
  11. Are you doing something like this? <?php // lots of code omitted // query to grab a page worth of posts $result = mysql_query($sql); ?> <html> <?php // display posts while($row = mysql_fetch_assoc($result)) { // do error checking here // display post } ?> </html>
  12. <?php $alphabet = Array('a', 'b', 'c', 'd', 'e', 'f'); foreach($alphabet as $k => $v) { if($v == 'd') { unset($alphabet[$k]); } } ?>
  13. Why can't File A and File B be combined?
  14. I generally try pushing all output to the end of my script. I do all my calculations first before anything goes to the screen. Here's the basic structure. <?php // filter POST and GET data, if any // run queries based on filtered data // process all necessary information for output ?> <html> <head> <title> <?=$page_title?> </title> </head> <body> <!-- lots of html --> <?php // some php ?> </body> </html>
  15. Yes, you often have to make trade-offs between security and usability. The "safest account system possible" wouldn't have an option to remember people who have logged in.
  16. To make it safer, just don't have a "Remember me" option.
  17. #!/usr/bin/php5-cgi -q <?php //Sets working directory $dir = '/var/www/test'; //Scans the working directory and puts all information into an array function select_files ($dir) { if (is_dir($dir)) { if ($handle = opendir($dir)) { $files = array(); while (false !== ($file = readdir($handle))) { if (is_file($dir.$file) && $file != basename ($_server['PHP_SELF"])) $file [] = $file; } closedir ($handle); if (is_array ($files)) sort ($files); return $files; } } } //Connect to database, assumes database and tables exist mysql_connect ("localhost", "root", "root1234") or die(mysql_error()); mysql_select_db ("dbtest") or die(mysql_error()); //Insert directory array into Database function insert_record ($name, $mod_date){ $sql = sprintf ("INSERT INTO dbtest SET filename = '%s', lastdate = '%s', location = '%s', $name, $mod_date, $fdir); if (mysql_query ($sql)) { return true; } else { return false; } } ?> end
  18. I've never tried doing it that way, but have you tried putting in php tags? #!/usr/bin/php5-cgi -q <?php // your code ?>
  19. Tsk, tsk. echo "Finished"; } else { echo('No inactive online members found.'); } ?>
  20. That's because you're reassigning the value of $result on line 20. Use a different variable, or, since it's an update query, don't assign a variable at all and just add an "or die" after the query.
  21. You can use explode as is. explode(' ', $your_string);
  22. What you're doing is just fine, but you have to define $unset before you use it.
  23. Give us the full error text, not a paraphrased version.
×
×
  • 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.