Jump to content

ManiacDan

Staff Alumni
  • Posts

    2,604
  • Joined

  • Last visited

  • Days Won

    10

Everything posted by ManiacDan

  1. Specify which columns of the target table you're trying to insert into: INSERT INTO table1 (table1ColumnName1, table1ColumnName2) VALUES (SELECT col1, col2 FROM table2) -Dan
  2. You have a comma at the end of your SELECT list.
  3. What part of my initial solution was unclear? Nobody is going to do this for you, it will take you 10 minutes to figure it out on your own.
  4. Create a new table called _xcart.table3. It will be temporary. INSERT INTO _xcart.`table3` (SELECT _xcart.address_book.id, _xcart.address_book.userid, _xcart.address_book.firstname, _xcart.address_book.lastname, _xcart.address_book.address, _2xcart2.address_book.city, _xcart.address_book.state, _2xcart2.address_book.zipcode, _xcart.address_book.country FROM _xcart.address_book JOIN _2xcart2.address_book ON _xcart.address_book.firstname = _2xcart2.address_book.firstname AND _xcart.address_book.lastname = _2xcart2.address_book.lastname AND _xcart.address_book.address = _2xcart2.address_book.address AND _xcart.address_book.state = _2xcart2.address_book.state AND _xcart.address_book.country = _2xcart2.address_book.country) Then, once you verify the data is correct, overwrite the old table with the new one. -Dan
  5. The MySQL functions MONTH() and YEAR() will allow you to filter the date fields. -Dan
  6. You've still given us zero information, but at least it appears to be working now.
  7. More accurately, you probably want fgetcsv Once you have the timestamp in a string, you need to use explode to break it into its parts. You will have to use explode multiple times. Then, once you have the parts, you will use mktime[/code] to make a timestamp out of the parts. Once you have the timestamp representing the log file time, use time and subtract to get the difference. -Dan
  8. Your first one is more accurately: SELECT COUNT(venue) as total FROM theTable WHERE venue = 'New York'; or SELECT venue, COUNT(venue) as total FROM theTable GROUP BY venue; The second one will produce all your counts at once, for every venue. The second one might be handled by this DevShed thread I wrote a couple years ago. It's very difficult to generate a "Streak" value straight from a database table. I get the feeling there's a way, but the SQL for it is beyond me. -Dan
  9. Use a recursive function. Every time you encounter another array, call the function. Otherwise, just print the <li> tags. -Dan
  10. What have you tried so far? $nav[$loc] will give you the array inside the key "title4", just use a loop to print it out. -Dan
  11. Use explode or preg_match to grab the bits of the string, and mktime() to construct a timestamp out of the string, then simply use subtraction to get the answer. -Dan
  12. Have you tried that? Add output to your script so you know it's working right. Then run it, and see if the output is what you expect. You don't need us to tell you if PHP will run a script properly, that's why you have the PHP interpreter.
  13. You've still forgotten to describe the problem. Describe the problem. Don't say "it doesn't work." What doesn't work? Does it email your grandmother? Does it launch nuclear weapons? Does it format your hard drive? -Dan PS - You cannot interpolate variables inside single quotes. Had you debugged this and echoed the query, you would have seen '$q' instead of the contents of $_GET['q'].
  14. Having 5 facebook accounts is a violation of facebook's TOS. Even so, "use an array" is the answer. Specifically, use an array and a loop. If you need more than that, "learn how to program" is good advice. There are plenty of threads on how to do that. -Dan
  15. Yeah...we generally don't help people crack passwords, especially when it's so trivial.
  16. The MySQL manual page on Indexes is a good start. Indexes should do nothing but speed up your queries, but too many indexes will slow down inserts. If there aren't a lot of inserts, indexing these columns won't have any adverse effects. Put a "normal" index on dbase.id and letters.maindatabaseid. Indexing those columns will lock the tables while the index is formed, so you may want to create a copy of the tables to play with while you work on your index knowledge. Or you could work with the person who created the application, or a DBA if one exists for your organization. -Dan
  17. I could have sworn I replied to this before I left on Friday. Fenway is right, there are no keys. The database isn't using the indexes to filter the rows in the tables, so it has to take EVERY row of table1 and compare it to EVERY row of table2, row-by-row, one at a time. This is called a cross-product and it takes forever. If you set up a foreign key or an index on the fields that you're using to join the tables, your query time will be cut down to a few milliseconds. Yes, it matters that much. -Dan
  18. Look into normal forms. Your database should be properly indexed and in third normal form. If you're having speed issues and index tweaking doesn't fix it, you may need to make denormalized search tables, but that's a discussion for once you hit tens of millions of rows. -Dan
  19. And yet you claim the function is succeeding. So you're uploading a fresh picture, one you've never used before, and you're seeing it in the directory? But you don't see an echo or any more errors? That's not really possible. -Dan
  20. Sub-classes override their parents. class a { function doSomething() { echo "Hello!"; } } class b extends a { function doSomething() { echo "Goodbye!"; } } $class = new b(); $class->doSomething(); //echoes Goodbye! Now, take that theory and look into the factory pattern, which allows your code to dynamically decide which class to use. -Dan
  21. SELECT SUM ( IF ( comments = 'pass', 1, 0 ) ) AS withComments, SUM(1) AS total FROM dsgi_serval ORDER BY SUM ( IF ( comments = 'pass', 1, 0 ) ) DESC -Dan
  22. Ok, go back and try to understand the error messages. They're designed to be human-readable. Notice: Undefined offset: 0 in flash_upload.php on line 32 Notice: This is the error LEVEL. A notice is less severe than a warning or an actual error. Undefined offset: You are using an array, and you are trying to access an offset that doesn't exist. 0: The offset you're using. Look for the zero in your code. in flash_upload.php on line 32: The location of the error. You pasted code that contains an array access using the number zero on those lines. That's the problem. The array that you expect to have an element zero doesn't have one. Print_r, find out what it does have. Find out which of your assumptions are wrong, and why. jdavidbakr already gave you the answer, this is just general advice for debugging. You could have solved all your problems yourself if you had turned on error_reporting and understood the messages. -Dan
  23. Use foxit reader to open and view PDFs, it's 1/8 the size of adobe's PDF reader.
  24. Note that there's a comment on the manual page for preg_replace_callback that basically parses bbcode output recursively. -Dan
  25. And make sure you read my post, you're not submitting this form (since you have no submit button)
×
×
  • 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.