Jump to content

Mr Hyde

  • Posts

  • Joined

  • Last visited


About Mr Hyde

  • Birthday 08/28/1982

Contact Methods

  • Website URL

Profile Information

  • Gender

Mr Hyde's Achievements


Newbie (1/5)



  1. I must not be understanding the question right... is there any reason why the string returned by the link I submitted above wouldn't work? just for reference: REGEXP '[[:<:]]some[[:>:]]' = 1 AND `` REGEXP '[[:<:]]words[[:>:]]' = 1
  2. Not to the best of my knowledge, but I do have a php query builder class that parses search strings like: this_is_treated_as_an_OR_string "this is a quote" +this_is_something_that_has_to_be_in_the_results -i_dont_want_this wildca%rd -"I don't want this quote in my results" and automatically converts them into a regex string. It's a module in what will be an open source searching class I'm building that I can send you. That would obviously have way more functionality than you require, but it's a nice little bit of code. I just whipped up a really basic interface to it here: http://fiftyoff.phpwebhosting.com/business/sql_search_query_builder.php?test I can't guarantee that I'll have that up permanently. I'd be happy to send you the code if you like. Otherwise, the style query that you are looking for is like this: SELECT * FROM `table` WHERE `column` REGEXP '[[:<:]]or1[[:>:]]' = 1 OR `column` REGEXP '[[:<:]]or2[[:>:]]' = 1
  3. Yeah, if you can use them, regular expressions are the way to go. I've given up on fulltext and %like% searches for the bulk of my searching for a while now.
  4. modify your REGEX statement to look like this: "WHERE $column REGEXP '[[:<:]]" . $number . "[[:>:]]' = 1" Using "[[:<:]]" makes the engine look for non alphanumeric characters as word boundaries. It's pretty darn fast, and it should tear into those comma delimited columns without a problem... especially if they are indexed.
  5. Sorry, mispoke... it looks like it's joining ONE table to itself. If I were you I would print off the values of these variables: $glob['dbprefix'] $_GET['productId'] and look at that sprintf function page to see how it inserts them into the output. OR you could just print off $query and find out the same thing.
  6. Can't tell you what the query is doing besides joining tables and selecting a couple columns, but sprintf is a native formating function for php. A lot of developers use it as a way to verify the input into a query. Once you figure out what the tables contain, and what values the columns hold, the answer to your question should be more obvious. I however, have no idea what those tables contain. I'll also give you another hint... when you're writing queries, or looking at them, I find it's MUCH easier to figure out what's going on if you format them a little so they're easier on the eyes like so: $query = sprintf(" SELECT B.*, T.option_name, T.option_type, M.value_name FROM %1\$s_options_bot AS B LEFT JOIN %1\$s_options_mid AS M ON B.value_id = M.value_id, %1\$s_options_top AS T WHERE B.option_id = T.option_id AND B.product = %2\$d ORDER BY T.option_name, M.value_name ASC", $glob['dbprefix'], $_GET['productId']); Using extra lines doesn't effect MySQL any, but it sure as hell makes it a lot easier to read for me.
  7. Can you login to MySQL as the root user, using that password?
  8. Here is a good launchpad for building a CHAP login system. Basically, the idea is to store the encrypted password in your table, and when a client tries to login, you encrypt their credentials client side via javascript (now their password is the same as what you actually have in your database), pass a salt, then you encrypt again on both sides via the shared salt and compare the results. It's certainly not an impervious method, but if ssl is cost prohibitive that's a good way to go. My thinking is that if a client trusts you with their password, the least you can do is try to protect it. It's very likely that they use the same password on their banking website, email etc.
  9. Don't know if this will help or not, but I am kind of picky about my connections in my code. I always up up any function call like this: sql_function($fake_var, $fake_var2, $conn = FALSE){ if($conn==FALSE){$conn = conn();} ... Where conn() is a mysqli connection helper function. This way, when I call an object it could have a million pages included, but I keep on passing the connection to each method or function individually so they will only use one connection. Php is supposed to manage connections real well... but I would rather avoid the whole problem in the first place. Of course, in a php class, I usually create a single connection in the constructor, set it to be a class constant , then just access it, or pass it on to other called classes like $this->conn(); Don't forget that you can set php ini variables temporarily in your script like: ini_set('mysql.connect_timeout', $int); So if you think that REALLY is the problem, you can call that and straighten it out. Hope that helps.
  10. Ah, okay... I assume the table with staff has different columns then the one for the players, otherwise you would probably just combine the two tables and add another column for group ("staff" or "player") then order your results by group.
  11. Not tested: SELECT rooms.visit_data, rooms.areaid, rooms.room FROM visit_data LEFT JOIN rooms ON rooms.room = visit_data.room Go through this join tutorial, it'll help teach you how to do it yourself.
  12. You mean you want two ROWS right... not two lines? You'll have to do something like AbraCadaver suggested using a UNION, or you could just concatenate two sql strings togther and use mysqli_multi_query() (which would be REALLY close to simultaneous). If you don't mind me asking, why do you want two rows returned if you can have them both returned in one?
  13. Yeah, that will work. I found through further research that you can't reuse an alias in the select statement. My only recourse is to duplicate queries... which offends my sense of aesthetics, but it works. I could also create a view, I guess, but I would like to avoid locking the table. Thanks for the response.
  14. It sounds like you need something like this: SELECT * FROM table1 as t1 LEFT JOIN table2 as t2 ON t1.field1 = t2.field1 WHERE t1.field1 LIKE \"%$trimmed%\"; This joins the two columns where the names are the same. It should return results like: John, 18, male all on one row. Also, because we are joining the two tables on field1, where they are equal, there is no use searching both columns... only searching one would be sufficient.
  • 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.