Jump to content

gizmola

Administrators
  • Posts

    5,945
  • Joined

  • Last visited

  • Days Won

    145

Everything posted by gizmola

  1. If the connection is slow/unstable, how is doing more of the same going to help you? What operating system is the php running on?
  2. If you have 10k rows in a mysql table, and you can't get a reasonable subset of the data in milliseconds, there is something wrong with your approach. There are ways to performance tune the data. In order to do anything with an array, you first have to read the entire contents into memory. That is going to take a while. Yes arrays are hashed on their key, which is very efficient, and this is key, once the data is read into the array! But that sort of efficiency already exists in the database, if you have normalized structures and have appropriate indexes and done explain on the queries, so that you are clear on how the queries are being optimized.
  3. No, your my.ini should have this: event_scheduler=1 Running SET GLOBAL event_scheduler = ON is something you would do as the mysql root user in the mysql client of a running server to turn it on. However, if it's disabled in the my.cnf or my.ini, that won't work, until you change the configuration variable and restart mysqld.
  4. Yeah there is no error 3306. We need to know what error is occurring.
  5. Yes certainly. There are browser plugins you can find that make it fairly easy to move files into s3. In terms of a relatively low cost, pay in advance all you can eat backup service, I am currently using crashplan.
  6. Sorry about the trailing off above.. i was going to write something like I don't understand your approach to .... whatever, but I trailed off and posted that accidently. At any rate, I'm glad you got things sorted out, and hopefully I put you on the right track.
  7. There are lots of backup services out there. If you are talking about something more interactive, you can in fact store anything "securely" in terms of using industrial strength public key/private key crypto. So long as noone ever gets your private key, there is noone in the world that will ever be able to decrypt your data even if they hack the server and download every file you've stored.
  8. Use a foreach loop. foreach ($rows as $row) { var_dump($row); }
  9. I have a hard time following the code. But I can tell you this is wrong: $query = mysql_query("SELECT * FROM `Music` GROUP BY musicalbum"); $b=mysql_fetch_array($query); while ($art=mysql_fetch_array($query)) { $a[] = $art['musicalbum']; $b[] = $art['musicalbumart']; } You fetch one row and assign it to $b. If you var_dump($b) after that line I think you'll be surprised by what it contains. Then you proceed to fetch other rows, but now you add additional array elements, each of which is the contents of the 'musicalbumart' column. Things would be a lot cleaner if you just did this: $query = mysql_query("SELECT musicalbum, musicalbumart FROM `Music` GROUP BY musicalbum"); while ($row = mysql_fetch_assoc($query)) { $rows[] = $row; } Now you have an array ($rows) which has one entry for each album/albumart row in the database. Truly this is a mess. I'm not sure why you're trying to make 2 arrays when 1 will do. I don't really understand you
  10. 3 things: - $row = mysql_fetch_assoc($query); That will fetch exactly one row. You would need to while loop if you actually want to get more than the first row of the result set (assuming there is one) - You have an associated array that you are foreaching through to make the exact same thing. It doesn't make any sense. - In my signature there's a link about having problems with mysql that you should take a look at. It's probably relevant to debugging your problem.
  11. gizmola

    Forums...

    If you abstract the entities: -Users -Boards -Topics -Posts Now you simply have to determine the attributes relevant to each entity and the relationships between them.
  12. When you see the above, it is typically because there is an ORM involved. It takes changing your thinking about things, because the point of an ORM is that it is working with Objects, rather than sql tables. The sql is suppossed to be obfuscated, and you're supposed to configure the ORM so that the underlying details of how data is persisted into the database is not important - you simply deal with objects and how they relate to each other, even if an object is a composite of a number of different tables. So while there may be a direct correlation in the first example between new and a news table and date and a date table, at the point you're working with the ORM you are really working with the classes news & date.
  13. gizmola

    Forums...

    Yes that's wrong. There is no reason to have a different schema. One schema, multiple related tables.
  14. use preg_match on your string to extract the url. A regex like this, while not impervious to some slight format issues, will do what you need. The better you control the format of the img tag, the more reliable the match. For example, the match will have a problem if your tag has "http://ur.png" />" rather than http://url.png"/>. That could be improved upon but I didn't see the point in adding more complexity to it without knowing the context in which it will be used. $source = ''; $matchcount = preg_match('!!i', $source, $matches); if ($matchcount) { var_dump($matches); } else { echo "no match found"; } If matched, the url will be in $matches[2]
  15. This topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=337675.0
  16. I'm not looking at whether or not any of your code will work, but just on the basis of the errors: $x=fgets($CfgFile)(); function(arguments) format. The extra () is invalid. $x=fgets($CfgFile); The UpdateSimpleDNS is going to need a rewrite. I'd suggest, based on what you're doing there, that you use curl
  17. I wouldn't over think the storage requirements unless you truly believe that you are going to have a huge database, which in my experience only happens to a rare few companies. You are right that a bigint takes 8 bytes whereas an int, only takes 4. Since an UNSIGNED int can store over 4 Billion rows, that's a pretty large universe. The cost of quick select statement is not significant, however in order to truly do it properly, you need to put a write lock on the table. Basically what you need with that approach is (in pseudocode): -write lock table -get your rand -while select count(*) where yourrand = saverand > 0 -- get your rand - insert row -unlock table For that reason it's a lot cleaner to make the unique index on the column and exception handle a unique constraint violation error after you try an insert. Simple enough to just keep trying until you don't get the constraint error. These collisions will most likely be few and far between... like winning the lottery although the chances increase dramatically over time, but you know that they are possible, so you have to do something to handle them.
  18. You will get a lot of hits if you search for javascript tooltip. I recommend jquery based addons like http://craigsworks.com/projects/qtip2/ Check the demos and I'm sure you'll be very impressed at the capabilities and variety of different ways you can use it. Here's a whole list of similar packages to check out. http://www.webdesignbooth.com/15-jquery-plugins-to-create-an-user-friendly-tooltip/
  19. No, that will not work. PHP is run server side. Javascript events happen in in the browser on your workstation. What are you trying to accomplish?
  20. You would do this using the javascript api as described here: http://developers.facebook.com/docs/reference/javascript/FB.Event.subscribe/ The event that fires when the user likes something is edge.create. You setup a callback function to run when the event fires.
  21. I really have to question your assumptions. Why would I bookmark an article I wrote while I was still working on it? It doesn't really match my experience. Ok, so if you don't care about search indexing (a decision that if you ever change your mind about you will regret) then the sky is pretty much the limit. As for generating a random number, there is no good reason to go for a bigint vs an int. The reality is that in either case, there is a small chance you will have a collision, but you could code around that by putting an index on it and looking up the value before you save the row, or handling a constraint error. You could also go for an md5 or sha1 hash of something like the user_id + time(). Another possibility is to just use the id after all, but obfuscate the fact that you are using it. I wrote this code for a now long defunct site. Feel free to experiment with it. class Obfuscate { static private function XOREncrypt($plain, $key) { $keyLength = strlen($key); $plainLength = strlen($plain); // Loop through input string for ($i = 0; $i $rPos = $i % $keyLength; $r = ord($plain[$i]) ^ ord($key[$rPos]); $plain[$i] = chr($r); } return $plain; } static public function obfuscateIntParam($in, $key) { // Add some noise $noise = rand(0, 15); $in = $noise + ($in $in = self::XOREncrypt(decHex($in), $key); // Make safe for uri $in = strrev(strtr(base64_encode($in), '+/=', '-_,')); return $in; } static public function deObfuscateIntParam($in, $key) { $in = base64_decode(strrev(strtr($in, '-_,', '+/='))); $in = hexDec(self::XOREncrypt($in, $key)); $in = $in >> 4; return $in; } } You could do a test like this: for ($x=1; $x $url =Obfuscate::obfuscateIntParam($x, 'Ilovethesmellofnapalm'); $original = Obfuscate::deObfuscateIntParam($url, 'Ilovethesmellofnapalm'); echo "$x. $url = $original \n"; } The advantage to something like this is: no additional storage required, and no giant hash url.
  22. I updated your original post SparK.
  23. Right after: $category_list_sql = "SELECT * FROM `".WPSC_TABLE_PRODUCT_CATEGORIES."` WHERE `active`='1' AND `category_parent` = '".absint($category_id)."' ORDER BY 'nice-name'"; Add var_dump($category_list_sql): die(); What is the output?
  24. A popular approach is to make a slug. A slug is based on the title of the article, but replaces spaces and punctuation and other characters that would have to be url encoded, and frequently there will be some sort of addition that insures that there will not be a problem should two users happen to create two articles with the exact same title. You would save the slug separately from the title. There are advantages to this, as it has been observed that search engines work off language, so having a url that matches the title of the article is often helpful in getting the article indexed. The slug can be safely recomputed any time the article is saved, so long as it is not published. Even after it's published the only danger in changing the slug comes from having the site indexed, and having 404 errors presented to visitors who come to the site from a search engine, but that is not a major problem. In terms of mod_rewrite rules, that is not directly related to the question of slugs or another mechanism. If your site works like this: index.php?slug=3_slugs_work_great The link that should be presented should be something like: www.site.com/slug/3_slugs_work_great This is again because it has been noticed that many times search engines will not index url's with lists of url parameters.
×
×
  • 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.