Jump to content

BioBob

Members
  • Posts

    90
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

BioBob's Achievements

Member

Member (2/5)

0

Reputation

  1. Its a fairly stright forward question I think. Lets say I have an Enum or a Set type, where I specify the specific values of the Set. Say the field is called Fruits. If I want to have more different types of Fruits available later, I can edit and add those new fruits to the set type later. So lets say for right now I have Apples, Oranges, and Bananas. In my php code, I could hard set these values, but I want to count the total number of different values, or simply return the values themselves. I'll be happy with either an INT for returning a COUNT(*) or the Value, IE mysql_fetch returns (Apples, Oranges, Bananas), so either way. The total number probably isn't going to be a very high number, single digits, maybe low double digits... How on earth would I do that?
  2. Not a Time Stamp, Time Code. Format is a bit different. HH:MM:SS:FF where FF is Frames. I dont really care if it is a Drop Frame or Non Drop Frame system, it doesnt need to be that accurate. Just curious if anyone has any links...
  3. Can you also post the HTML output of the page? Im looking at your $PHP_SELF var and dont think its gonna work in the way you have it set up... You might try replacing $PHP_SELF with: <a href=\"" . $_SERVER['PHP_SELF'] . "?s=$news&q=var\">Next 10 >></a> Additional Note: Youre leaving yourself open for a mysql injection attack. Trimming data is fine and dandy and all but you want to do some error checking on it. for example also add this: if ( (isset($_GET['q'])) && (is_numeric($_GET['q'])) ) { $var = $_GET['q']; } else { $var = 10; //Default } Which thats fine and dandy for working with NUMBERS but if youre going to deal with text, make DAMN sure you use mysql_real_escape_string($text_var) before you put it in a query. Do that after you connect to the database tho...
  4. Its possible its blowing up in the query itself for some reason. Situations like that where you cant figure out WHY its not working, I try to stick with php's OR statements as much as possible. mysql_query($some_query) OR die("there was an error in the query:\n$some_query\nMySql Said: " . mysql_error() . mysql_errno() ); Alternatively, if you dont want to kill the script, you could try error_log(mysql_error()) also. Alternatively, yet again, mysql will return FALSE if the query didnt run or there was an error, so you can also do something like: $some_query = "UPDATE something SET something = 'something' WHERE some_id = '$real_id' LIMIT 1"; if (!mysql_query($some_query)) { error_log("Some Error Text" . mysql_error()); } Its pretty simple logic, but what you gotta do is write your code so no matter what, you can figure out what happened. 90% of programming is setting up your code so no matter what happens in your code, you have a way to find out what its doing and why its doing what it is doing.
  5. Are you typecasting your variables? PHP might be interepreting your INT as a STRING...
  6. This is more of a CONCEPT issue than actual coding question. I have a rather complex query. Lot of conditional statements. One of the statements, when I run it by itself and totally exclude the rest of the statements runs just snappy. But when I include this statement into the whole query, it runs slower than I want. About half a second. Especially considering when I run the whole script without this, I get results back in about 0.01 seconds, for BOTH the whole query without one of the AND statements, and the AND statement when it is run by itself. Put em together and VOILA! Half Second Query Time So, the question becomes this: Can the ORDER of where AND clauses are in a Query affect its performance? And if so, where should I put the query in the complex statement, beginning or end? Select * From somewhere WHERE (simple statement, like indexed user_name = 'Whatever') AND (complex statement with subselects n stuff like that) VS (complex statement with subselects n stuff like that) AND (simple statement, like indexed user_name = 'Whatever') Does it make any difference as to the order of the conditional statements?
  7. Try telnetting to mysql from the remote machine to the mysql server (have to install as an extra option if you use Vista on remote machine). Syntax should be "telnet 192.168.1.18 3306" and you should get some garbage characters back. Thats step #1, just make sure you can talk to the mysql server and that the port isnt being blocked. After that, it ends up being a permissions issue. MySql has a field called HOST for the hosts that are allowed to connect to it from said host. For example, ROOT should be a LOCALHOST only, and other users can be specified to specific hosts.
  8. UPDATE field SET days_old = days_old + 1, date = TIMESTAMP() WHERE date < TIMESTAMP - (60*60*24) or something like that. Depends on how you have your time set up. Epoch time or with a formatted date...
  9. This sounds like a major project, and your best bet would probably to look for a freelancer.
  10. Use the mysql LIMIT feature. It accepts ONE or TWO arguments. SELECT * FROM field_name WHERE name='Fred' LIMIT 1; or SELECT * FROM field_name WHERE name='Fred' LIMIT 15, 30; When you use the second argument, the first argument becomes the result number you start at, and the second option is the total number of results, if there are that many results. This is also supposing that the second example query I gave you had over 45 rows in it. So basically it starts at result #15 and shows the next 30 records from there.
  11. If you want to test your efficiency, load it up with some dummy data, like you said about 1,000 users, so load it up with about a thousand rows of just junk. You could also try doing some JOINING on a couple of those first fields to again reduce the number of queries, but not sure if that will speed it up at all...
  12. Yep. Two bits of advice here. #1: The @ symbol is used as ERROR SUPPRESSION. So if the function kicks back an error, but its not a FATAL error (like a syntax error) you wont get any warning as to why the function failed to do what it was expected to do. #2: Logging in from a command prompt is just "mysql -u root" and if you want to give it a password, use "mysql -u root -p" and dont put the password in, it will prompt you for your password (if you have one) when you hit enter.
  13. Results Im trying to get is recipe_id, TotalMatches... Schema is modified a bit to protect information of my client so Im not really using "recipes"... Wasnt my design, I was hired on after it was built...
  14. SELECT * , nickname IS NULL AS isnull ORDER BY isnull ASC, nickname ASC create a column for a NULL value then order by it in your order clause
  15. could also try looking up htmlspecialchars which will change characters like < and > to their ASCII components like & lt ; or & rt ; or like an ampersand is & amp ; (no spaces)
×
×
  • 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.