Jump to content

btherl

Staff Alumni
  • Posts

    3,893
  • Joined

  • Last visited

Everything posted by btherl

  1. Can you show us the code that creates the username and password? Also, it's a good idea to use mysql_real_escape_string(), in case someone uses funny characters. $userid_esc = mysql_real_escape_string($userid); $userpw_esc = mysql_real_escape_string($userpw); $authenticate = "SELECT username FROM userlist WHERE username = '$userid_esc' AND password = PASSWORD('$userpw_esc')";
  2. What output do you get and what are you expecting? Also, do you have duplicate products? Or did you add the DISTINCT for another reason? If you do have duplicate products, what are the conditions for considering them to be "duplicate"?
  3. basename() doesn't mangle filenames like that. That sort of mangling is to shrink files down to 8 characters, like on the old dos systems and Windows 95/98. dangeorge, can you see if it only occurs with filenames of a particular length, or containing particular characters?
  4. Actually, setting the variable won't interfere with sending the email. Phlash, have you tried a simple script which sends an email only, without any added headers? Does that fail too?
  5. Hmm.. perhaps mysql can't join with a subquery. That's a problem... How about this.. CREATE TEMPORARY TABLE dups AS SELECT lastname, firstname, title, email FROM tbl_data GROUP BY lastname, firstname, email, lastname HAVING (COUNT(*) > 1); SELECT recordid FROM tbl_data NATURAL JOIN dups; That's the same thing, rewritten to use a temporary table.
  6. That's because you used the old variable name after imploding: $search = implode(',', $search_cid); array_push($whereParts[], 'species LIKE %$search_cid%'); That $search_cid in the second line should be just $search
  7. You can use either $whereParts[] = 'blah'; or array_push($whereParts, 'blah'); What you have there is a mixture of the two.
  8. Magnetica, how do you tell if someone has two or more accounts? The system I've used in the past (with mixed success) is to find the users coming from the same ip, and to ask them why they are on the same ip. If they give a good explanation, then I let them be and monitor them for signs of cheating. If no response but they are still logging in, then ban them (and allow them to message me to request unbanning).
  9. According to the docs: "If you want to determine all possible values for an ENUM column, use SHOW COLUMNS FROM tbl_name LIKE enum_col and parse the ENUM definition in the Type column of the output." http://dev.mysql.com/doc/refman/5.1/en/enum.html
  10. Have you read through the docs here: http://dev.mysql.com/doc/refman/5.1/en/enum.html You're right that using integers and a join is more flexible. Changing the enum requires changing the table definition. As for speed, I wouldn't expect much difference.. but as always, you should benchmark it if it's really important. As for joins.. the enum has the advantage of not confusing you as much On the other hand, joins are important to understand for using databases. Maybe it's good to learn about them in a simple context like this. Joining in the way that you are for the types is the simplest kind of join there is.
  11. That's a job for php. To do it in SQL is just too messy, and probably quite inefficient. I would start by converting the timestamps into an easier format to work with (perhaps with strotime()), and then have a loop going through all the results, checking if the location is the same as the previous one. If it's the same, then update the time for that stop. If it's different, then finish the previous stop and start calculating for a new stop.
  12. Check this thread: http://www.phpfreaks.com/forums/index.php/topic,125759.0.html The simplest method is just "ORDER BY RAND() LIMIT 1", but that isn't efficient for large data sets. Try it out and see if it's fast enough for you. If it is, no need to do any more
  13. btherl

    Output

    I think it's the arguments to mysql_result().. http://sg.php.net/manual/en/function.mysql-result.php Try mysql_result($result, 0, "greeting") to fetch the greeting column from row 0. To display all rows (if you're expecting more than one), you'll need a loop. Usually I do this: while ($row = mysql_fetch_assoc($result)) { $greeting = $row['greeting']; $imagone = $row['imageone']; $imagetwo = $row['imagetwo']; # Do something with the data here }
  14. Aha, I gave the column a different name. The "group_concat(user_name) AS usernames" means "Name the column usernames". So you would just replace user_name with usernames, and it should work fine Edit: Replace $data['user_name'] with $data['usernames'], I mean.
  15. Naturally he will be reviewing each case manually, not automatically banning the ip If you're using mysql, you can use SELECT user_ip, group_concat(user_name) as usernames FROM fusion_users GROUP BY user_ip HAVING count(*) > 1 That should give you something like: user_ip usernames 1.2.3.4 btherl,btherlseviltwin
  16. Does your table contain one entry for each "usage" of an IP? And do you assume that each ip is only used by one user?
  17. The column is called name, not name_match
  18. btherl

    Output

    What output are you expecting and what are you seeing?
  19. Try adding ini_set('display_errors', true); to the top of your page (in php mode). If you have a syntax error, then you will need to fix that first though.
  20. Is this what you're looking for? SELECT DISTINCT member FROM table
  21. If you use this query and mysql_fetch_assoc, then you can use asort(): SELECT sum(jim) as jim, sum(bob) as bob, sum(bill) as bill FROM tbl Then fetch the result with mysql_fetch_assoc(), and use asort() or arsort() to sort http://www.php.net/manual/en/function.arsort.php
  22. Try Y-m-d format instead of m-d-Y. Computers don't like m-d-Y because it's not in order.
  23. Actually, best is $_POST['f_name']. Although it works without quotes, it's risky as your variable names may clash with defined values. And single quotes are slightly faster than double quotes. But that's not causing your error. Try changing your num_rows() line to this: $check_row = mysql_num_rows($result); Adding the "or die" to mysql_num_rows() doesn't work, and in fact makes things worse. You should keep the "or die" on the other mysql calls. If you still get a blank page, add ini_set('display_errors', true); at the top of your code (I am not 100% sure that is right, but the goal is to turn on display of errors)
  24. Is what you really want the recordid of each row which is a duplicate according to the other 4 columns? Try this: SELECT recordid FROM tbl_data NATURAL JOIN ( SELECT lastname, firstname, title, email FROM tbl_data GROUP BY lastname, firstname, email, lastname HAVING (COUNT(*) > 1) ) If your mysql doesn't support subqueries, then it'll need to be changed.. you didn't say which version of mysql you are using.
  25. You are trying to sort the columns? SQL isn't designed for that. Instead, you can do the sorting in php after fetching the data. If you want to sort by name, then you should design your database like this: score_id name score 1 jim 20 1 bob 30 1 bill 15 2 jim 20 2 bob 35 2 bill 15 Then just do SELECT name, sum(score) FROM scores GROUP BY name ORDER BY sum(score) DESC
×
×
  • 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.