Jump to content

requinix

Administrators
  • Posts

    15,264
  • Joined

  • Last visited

  • Days Won

    431

Everything posted by requinix

  1. mysql_error("sql1 failed") That's not how you use it. die("sql1 failed: " . mysql_error())
  2. And that's where my brain stopped reading your post. What's this "position" column for?
  3. I got that much, but what is going on beyond what you've described? Does the cloned table need to look exactly the same as the "master" table, or you do only want to import information from it? Could the two tables every look different in the slightest? Oh, and are they on the same database server?
  4. You're calling mysql_query() too many times. Just once is enough.
  5. The only other meaningful difference is whether files are web-accessible, but that doesn't require putting them in any particular place (like outside the web root).
  6. Given what all you'd have to do to display a calendar on a page, your question doesn't make sense. You execute a query to pull everything during the month (or whatever time range) being displayed; as you're printing the calendar you're also walking through the list of events. When you're showing a day then you'll also know if there are any events for that day and, if so, what they are.
  7. Use a database. Even if you don't think you need one now, you do. What you start off with are just four separate criteria. You could construct a single query that would give you the results you want, but that's a hassle. So start easy. Go through the criteria and find the instruments that match each one. Level=Advanced finds five so give them each a point and hold onto them. With Bowing Style=Hard you get four, all of which you've found previously - give them another point. For Musical Style=Rock there's one familiar one and two new ones - give them points too. Finally there's Desired Tone=Dark and two more familiar instruments (and one new one). More points. You can easily weight each category too by giving more or less points. You could start with a baseline of 10 points and say that "very important" = 15 while "not important" = 5. With a bit more math you can rank matching as a percentage. Once you've gotten that working you can have a go at a single unified query. It's actually not that hard if you were to, say, use a few UNIONs. # level=advanced is of normal importance SELECT 10, instrument FROM instrument_table WHERE level = advanced # bowing style is of normal importance UNION ALL SELECT 10, instrument FROM instrument_table WHERE bowing_style = hard # musical style is very important UNION ALL SELECT 15, instrument FROM instrument_table WHERE musical_style = rock # desired tone is also very important UNION ALL SELECT 15, instrument FROM instrument_table WHERE desired_tone = dark Throw that in a subquery then SUM() + GROUP BY the results and you've got a bare minimum.
  8. What kind of clone? Copy or mirror? How much of it is cloned?
  9. Of how a question mark works? Sure. abc -- matches only "abc" abc? -- matches "ab" optionally followed by a "c"
  10. Hint: a ? means the thing before it is optional.
  11. Use a constructor or method. If you don't know what those are then read up on object-oriented programming.
  12. This topic has been moved very early in the morning to mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=359281.0
  13. array_splice lets you insert into the middle of an array (if you know the numeric offset it should go into). Can I ask why you have to insert into the array? You know that for most purposes the arrangement of the keys/values makes no difference at all?
  14. __DIR__ is the directory containing the currently-executing file (exactly like how __FILE__ is the full path to the file). So if you use require_once __DIR__ . "/header.php"; in /forum/views/*.php then it'll include /forum/views/header.php, and if you use it in /index.php then it'll include /header.php. Why's that? Are you serving the site out of a subfolder or something?
  15. No: it's relative to the directory of the first executed file. If that first file includes a file in some other directory, the include path will not "update" to reflect that other directory. Use absolute file paths to include files. // relative to the current file require_once __DIR__ . "/path/../to/../function.php"; // PHP 5.3+ require_once dirname(__FILE__) . "/path/../to/../function.php"; // relative to the web root require_once $_SERVER["DOCUMENT_ROOT"] . "/path/to/function.php";
  16. What does the marquee code look like?
  17. This topic has been abducted by aliens, probed, and dropped off in JavaScript Help http://www.phpfreaks.com/forums/index.php?topic=359251.0
  18. 1a. Viruses can't do anything unless they're executed. So to prevent viruses from doing anything, don't execute files. 1b. If you're actually worried about viruses being uploaded, install AV software on the server and manually scan files as they're uploaded. 2. Store uploads in a place that is not web accessible. Or prevent the webserver from allowing access to them. 3*. Have PHP create the upload folder: chmod 0777 the parent folder, use mkdir() to create the upload folder then chmod() 0755 it, then chmod 0755 the parent folder. 4. Use a PHP script to send (eg, show or trigger a download on) an uploaded file. Don't link to the files directly - though you could have URL rewriting make it look like you are. Don't forget access controls. * If the server configuration is altered and the PHP user changes, you'll have to do a little work. But this is pretty rare.
  19. Did you check to make sure you didn't accidentally add some emoticons in the configuration? What's in your .htaccess and how is the HTTPS site set up?
  20. No... That's kinda the point.
  21. Only use //s when you're writing the expression as an object, inline. pattern = /^handle\[\d+\]/; (that won't work, of course) If as a string then leave them out. pattern = "^" + handle + "\\[\\d+\\]";
  22. __destruct() needs to be public so PHP can call it. __construct() can be whatever you want. If public then anybody can instantiate the object; if protected then only it and its children can instantiate it (or in the case of child objects, call it in their constructors); if private then only the object can instantiate itself.
  23. What do you mean by "default main page"? Any examples? Does DirectoryIndex answer your question?
  24. What about nl2bring it, then replacing two consecutive s with a \n?
  25. Because there's something else going on. Or in other words, not enough information. Is this online somewhere we can see?
×
×
  • 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.