Jump to content

roopurt18

Staff Alumni
  • Posts

    3,746
  • Joined

  • Last visited

    Never

Everything posted by roopurt18

  1. You might try using a GROUP BY clause in conjunction with MySQL's GROUP_CONCAT() function. So if an interview has the sources: Bob Jane Joe Instead of 3 rows of the same interview, you could coerce the source column to be a comma delimited list: Bob, Jane, Joe Another option if using MySQL 4.1 or above is using a sub-query. Instead of LEFT JOINing on another table, you can run a subquery and alias it to be used as another table. Within the sub-query you could use DISTINCT or some other DB functionality to cause an article to only appear once. SELECT i.*, s.* FROM `interviews`i LEFT JOIN ( SELECT DISTINCT `interview_id`, `fld1`, `fld2` FROM `sources` WHERE ... ) AS s ON s.`interview_id`=i.`id` I don't have the time or the patience at the moment to give you something tailored to your situation, but those are two database features you may not be aware of that might help you. If you get stuck post again and I might have a little more time later, or someone else might be able to give you something tailored to your exact tables. (edit) The fastest solution might be to just tack a GROUP BY `IntTable`.`IntId` onto your existing query.
  2. And you're not getting any errors or anything?
  3. Try changing: #echo $c5t_output; to echo $c5t_output; As long as you still have the changes from earlier in place the contents should go into the buffer and come out on the right place on the page.
  4. From http://www.djadamash.com/comments/docu/docu.html#_Toc151834613 Can you paste the contents of include.php into a reply?
  5. Just a suggestion, you might try seeing if vbulletin has their own support or user forum where you can ask about where that piece of code is. If I knew anything about vbulletin I might be able to help you, but I don't. If you were to ask me, "In general, how would I accomplish this?" then I could tell you. Most of the other users of this forum fall into that same general category.
  6. You're not stupid, just inexperienced. But learning how to read and decipher error messages will go a long way in helping you fix problems. And always, always make a good, honest attempt at figuring out what the problem you're having is. Not saying you didn't do that here, but by doing so you rack up experience points in regards to troubleshooting. If you can train your eye to notice subtle syntax errors and other things, you make those mistakes less or notice them quicker in the future. Don't feel bad, every programmer has lost a significant portion of their time looking for what turned out to be a misplaced semicolon or a lowercase letter instead of an uppercase one.
  7. Well what do the instructions say to do? Do they say, "Include() the file and then call a function?" Perhaps it's not enough to include() the file, perhaps after you include it you have to call some_mysterious_comment_function(). We don't know what you downloaded so we can't tell you how to use it. In any case your initial problem is resolved and it sounds like it is now a 3rd party script problem, for which we have a dedicated child board.
  8. Look at the error: mysqli_error() expects exactly 1 parameter, 0 given Look at your line causing the error: $result_facilitycode = mysqli_query($cxn, $facilitycode) or die(mysqli_error()); Look at your call to mysqli_error: die(mysqli_error()); How many parameters did you pass to your call to mysqli_error()? *Hint* You didn't pass any, but we already knew that from the error message: Warning: mysqli_error() expects exactly 1 parameter, 0 given So look at the documentation for mysqli_error() and find out what it expects as its first argument and then supply it. I'd guess that it's your $cxn variable.
  9. Do you have any mechanism in place to determine which users are currently online? If not someone was asking about that just today: http://www.phpfreaks.com/forums/index.php/topic,183085.0.html If you can already determine which user IDs are currently online, then it's a simple MySQL statement to connect them to their appropriate user names.
  10. If you can obtain a list of dictionary words you can load them into a table. Then break apart the search terms and determine which ones have matching results in the table. The ones that don't have matching results are misspelled and you can find similar words with SOUNDEX().
  11. I would think the first step would be to just spell check the search and offer up the correct spelling as an alternative. Google also likely compares each of the search terms for similarities to other popular search terms as well, thus giving it the ability to match abbreviations and / or acronyms.
  12. You should read the MySQL documentation on TIMESTAMP columns to figure out exactly how they work, but from what I recollect, the first timestamp column of a table will auto-update to the current timestamp any time you insert or update a record. Otherwise you want to change your code from finding the TIMESTAMP in PHP and just use MySQL's NOW() function: // I've dropped your $timestamp variable mysql_query= "INSERT INTO `online_users` (`userid`, `ip`, `last_active`) VALUES ('$x[iD]', '$ip', NOW())" or die(mysql_error()); Then if you want all the users online in the past 5 minutes: SELECT * FROM `online_users` WHERE NOW() - `last_active`>=300 Do you know how to use JOINs to connect the usernames to their IDs in the online_users table?
  13. Which MySQL data type did you give the column last_active? If it's anything other than DATETIME or TIMESTAMP then you goofed it up.
  14. Timestamps are just numbers of seconds, neither is in any format until you format them with a MySQL function or a call to PHP's date(). So perform your calculation before you convert them. Or convert them back to timestamps with PHP's strtotime().
  15. There is an error code for no file uploaded: http://us3.php.net/manual/en/features.file-upload.errors.php
  16. If the two dates and times are timestamps, then you just subtract them and that'll give you the difference in number of seconds. If they're in another format, such as 'yyyy-mm-dd h:i:s', then look into one of MySQL's date functions, specifically DATEDIFF(): http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html
  17. A call to session_start() must occur before any output is sent to the browser. It would appear that comments/include.php contains a call to session_start(); therefore it has to be at the top of your script, whether you want to put it there or not. Now if comments/include.php creates some output you wish to capture and insert further down in the page, you can do this: <?php ob_start(); include("comments/include.php"); $comments = ob_get_contents(); ob_end_clean(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/iframe page.dwt" codeOutsideHTMLIsLocked="false" --> <head> ... And then where you currently have your include() statement: <?php echo $comments; ?>
  18. If $keywords is an array of strings then you want to drop the (int). The (int) converts the value that follow it into an integer. So here's a couple questions for you. How do you convert the string '54' to an int? Just drop the quotes, right? Easy enough. How do you convert the string 'WUSA' into an integer?
  19. PHP navigation can occur through the URL, but it doesn't have to. There is nothing more or less professional about a site with URLs like: index.php contact.php about.php login.php vs. index.php index.php?page=contact index.php?page=about index.php?page=login They both accomplish the same thing and they both require the same amount of URLs to navigate around. After all if your site has 9 distinct pages it has to have 9 distinct URLs, no matter which method you choose. The difference is that the second example has only a single php script, i.e. index.php, that acts as the entry point for every page. This makes it easier to perform application setup, such as database connections. It has the trade off that index.php is now a more complicated file. If you try to shove the logic for every single page in your site into a single PHP script, you will quickly overwhelm yourself. The file will become quite large and difficult to maintain. You'll start asking how you can maintain such a mess and the answer is by better code organization, via functions and / or objects. Look at it this way, by using URL parameters you decrease the number of actual script files that reside on your server, but you still have to write all the code and logic. There's a certain threshold of site size where the first method is better, namely small personal sites. As your site starts to grow in size and complexity of functionality, the second method works better since when organized correctly, you can reuse a lot of code. Basically the site is more maintainable over a long period of time. The second approach also has the benefit of working well with mod_rewrite, which helps in creating search engine-friendly URLs. About security, neither approach is inherently more secure than the other. Security is something you have to build into your site, so no matter which approach you take if you don't add security features your site is insecure.
  20. SELECT * FROM `table` WHERE `search_field` LIKE '%search_string%'; % in a MySQL string represents a wildcard and matches zero or more characters.
  21. http://www.google.com/search?q=php+explode
  22. Look into sprintf(). You can force a string to a certain length and choose the padding string (such as a dot in your case). The solution won't be immediately apparent but you should be able to get it with some tinkering.
  23. No it's not required. But if the records in this table are going to be linked anywhere else then it can make joins faster AFAIK.
  24. The only way to increase database queries is with an index. Even if you have an `initial` field, it won't make anything any faster without an index on it.
×
×
  • 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.