Jump to content

brentman

Members
  • Posts

    65
  • Joined

  • Last visited

Everything posted by brentman

  1. I am just concerned because I have seen some companies go down because of database issues that were not fixable. True story: One company needed to complete a query automatically every second. They were easily able to do that for a year. On year two, it was talking almost a second so they made some changes and it worked better. By the end of the year, it was failing occasionally but each time it cost them approximately $1000. At that point, there was no way to fix how it worked short of a complete rebuild from scratch of the core functionality which was estimated to cost around a quarter of a million dollars and take 6 months. That cash was not available, especially since business would have had to cease operation for 6 months and thus the company is now gone. So after seeing that I am a bit nervous about the life of my database and code logic. Test rows I think will be a great idea. Thanks. Once I finish my my queries I will definitely try that!!!!
  2. I am expecting to hit 100k rows. But I think that answered what I needed. I will try to do most of the data checking through the MySQL query, avoid 'like' operations, and not worry so much. Unless you think I should be worried about 100k rows on about 30+ columns. It is also a user experience issue if it doesn't load quickly. 5 second wait isn't good for what I am doing. Thanks!
  3. So I have a big table of about 30-40 columns. Some variables are quite long strings while others are simple tinyint(1) values. Input into the code is a value or range of values or something that applies to each of the columns. I need to find which ones are an applicable match to the user request and then load them into php. Now I know variations can cause something to run more optimally one way or another but this system will get bogged down with lots of requests and lots of data, so any additional performance I give it now will help me down the road. I am just looking for general concepts to help, not specific code tweaking. I have heard the typical rule is to query mysql as little as possible and do the hard lifting in php but I am not positive this is right. Since I have to query anyways, should I do a mysql pull using a complex 'WHERE' to do most of the sorting. ie only get rows where a=1, b>5, c="http://google.com", d="3242342323kj4238237489023ejfjf3jrjf8jeifjdjf" ie long string, etc for all 30+columns? OR I pull the whole DB and do all the sorting in php... OR I do all the simple sorting in the MySQL query and some of the more complicated sorting in PHP (or vice versa) Any ideas would help.
  4. Barand, thanks. I was able to update to MySQL 5.6 and then get the code to work as you posted in your last response. Perfect timing for the new release!
  5. Found the answer but new issue now. Here is the code: $ipv6 = '2404:6800:4001:805::1006'; $int = inet_pton($ipv6); $bits = 15; $ipv6long = 0; while($bits >= 0){ $bin = sprintf("%08b", (ord($int[$bits]))); if($ipv6long){ $ipv6long = $bin . $ipv6long; } else{ $ipv6long = $bin; } $bits--; } $ipv6long = gmp_strval(gmp_init($ipv6long, 2), 10); Now the only problem is I do not have math functions installed. I would prefer not to install them. Is there an alternate for the two gmp functions?
  6. I tried this and it returned empty. $ip_test = '2607:f0d0:1002:51::4'; $result = mysql_query("SELECT * FROM ip2location_db11_ipv6 WHERE INET_ATON('$ip_test') BETWEEN ip_from AND ip_to"); $location_record = mysql_fetch_array($result);
  7. I don't think those will help unless I am just not understanding them that well.
  8. You want to explode it based on a unique part of code immediately before and after the content you want. Then you just use the piece you like echo'd out where you want it and tada. Step 1: file_get_contents Step 2: explode Step 3: echo part(s) out
  9. I just downloaded and installed IP2Location database and everything is smooth for IPv4 addresses. (If you want to get location from peoples IP the free version is here: http://lite.ip2location.com/database-ip-country-region-city-latitude-longitude-zipcode-timezone) You convert the IPv4 address to an IP number and then do a database query. See here: $ip_split = split ("\.", "$ip"); $ip_num = $ip_split[3] + ($ip_split[2] * 256) + ($ip_split[1] * 256 * 256) + ($ip_split[0] * 256 * 256 * 256); $result = mysql_query("SELECT * FROM ip2location_db11 WHERE '$ip_num' BETWEEN ip_from AND ip_to"); However I now need to do this for an IPv6 address but there is no documentation or anything I can find Googleing about how to do this for IPv6. Obviously the same method will not work as it has letters in the address as well as more numbers. There is obviously some difference to it. Anyone know what to do? Thanks!
  10. Thanks that looks like it is the best solution. I am however nervous using something outside of apache/php/mysql for a production build as that is all I have ever worked with and I am on a time crunch to launch Jan 5th. Any more typical suggestions I can implement pre launch until I can migrate to Cassandra later on?
  11. So just to preface this, I have been part of two operations (one as developer, one with a 3rd party company developing) where the business was forced to cease due to difficulties in database load balancing and lots of people lost lots of money. I am talking about big data and high performance needed at the same time. So for my new project, I am going to try and design it around having a forever expanding infrastructure of servers but that means setting it correctly from the beginning. I have put together some ideas for possible ways to split the database load across multiple servers. Any input to which idea(s) are best would be great so I know which to explore further. Also any relevant info on this type of thing would be helpful as this is the first time I am personally doing this. Thanks!
  12. Say there is a complex opt in process where people start to enter their data but certain questions stop them where they close out of the page. They already entered their data and I feel there is a way to grab it and post it to mysql even though they do not click submit. How would this be done? A super simple example (proof of concept) or a link to a tutorial would be very useful.
  13. I have a person who is male, aged 30 and has kids. I have a list of products with information like (product should only be shown to people with kids or product should only be shown to men aged 30 or older) I have an array of the persons details and an array of all products with their details. How do I remove the products from the array that do not match the users details. ie remove dresses when the user is a male.
  14. I have users in my database with many stored points ie age, gender, interests etc. about 20 points in all. I have a table of products that I want to recommend only applicable products. They each have saved like minage, maxage, gender, interest etc for the ideal consumer. ie dress gender=f This is the bare bones of what I have so far: $result = mysql_query("SELECT * FROM user_table WHERE hash='$session_id'"); $rowuser = mysql_fetch_array($result); $result = mysql_query("SELECT * FROM products"); $rowproducts = mysql_fetch_array($result); So now I have $rowuser['gender'] = m , how do I remove all from $rowproducts where gender = f? Is there a best way to do this knowing I have about 20 points to go through before I am left with an array with just the best selection of products for this user in it?
  15. Thanks you are right, it was nothing. Must be something else going on with the code or my server.
  16. I am writing a slot machine and have a super basic script at this point, this makes up 90+% of the php in the slot machine file however it loads pretty slow compared to all my other sites and scripts so I think I am doing something wrong in terms of performance. ie I have a dice script that loads almost instantly on the same hosting but this takes like a full second. Logic is right and it works but how to optimize? or am I just crazy and its just variations in hosting and this shouldn't be slow? if ($one == 1 && $one == $two && $two == $three) { $bonus = 10; } elseif ($one == 2 && $one == $two && $two == $three) { $bonus = 20; } elseif ($one == 3 && $one == $two && $two == $three) { $bonus = 30; } elseif ($one == 4 && $one == $two && $two == $three) { $bonus = 40; } elseif ($one == 5 && $one == $two && $two == $three) { $bonus = 50; } elseif ($one == 6 && $one == $two && $two == $three) { $bonus = 60; } elseif ($one == 7 && $one == $two && $two == $three) { $bonus = 80; } elseif ($one == 8 && $one == $two && $two == $three) { $bonus = 90; } elseif ($one == 9 && $one == $two && $two == $three) { $bonus = 100; } elseif ($one == 10 && $one == $two && $two == $three) { $bonus = 250; } elseif (($one == 7 || $one == 8 || $one == 9) && ($two == 7 || $two == 8 || $two == 9) && ($three == 7 || $three == 8 || $three == 9)) { $bonus = 70;} //add scatter pay elseif ($one == 6 || $two == 6 || $three==6) { if ($one == 6) { $scatter = $scatter+2; } if ($two == 6) { $scatter = $scatter+2; } if ($three == 6) { $scatter = $scatter+2; } $bonus = $scatter; } else { $bonus = -1; }
  17. I am trying to program a variant of a dice game called cee-lo. User rolls three dice... best to worst listed below.... 4,5,6 - automatic win three 6's three 5's three 4's three 3's three 2's three 1's any pair and 6 any pair and 5 any pair and 4 any pair and 3 any pair and 2 any pair and 1 1,2,3 - automatic loss Any non matching to these which would reroll. They are compared to the banker who wins in a tie. How can i program this without a GIANT if/else nightmare? or is that whats required? a little guidance in the logic of this would be appreciated.
  18. @kicken: Can you elaborate on the dynamically generated image? That could be something I could work with but I am not quite sure what you mean. Even though most images are blocked by default, enough people load the images that it would be an acceptable solution for what I am doing.
  19. Well yes but I am already doing that. So basically anything other than clicking a link.
  20. Ideally my goal is to run php code in emails.... It needs to be a solution that will work with at least one major email client, ie gmail, yahoo. iframes work in many of the non popular clients but do not work in gmail and does not work in yahoo as far as I know. I can't create the correct content on email send because people don't open their email right away so the content will need to change to be correct when they open it. I was thinking about doing something with <img width="300px" height="300px" src="blahblahmyserver.php"> to do this but I am not quite sure if I am going down the wrong path here. When I try it with just a domain it displays a broken image. If I could pop open a window on email open (or even acceptance of images) i could display the content that way. Any ideas on how to accomplish this would be helpful. There has to be some way Thanks!
  21. Server Side language isn't viewable in "View Source" only the output. You can't block the output. But the important part, the php code, is not viewable and safe. (Providing your code is secure)
  22. I once had a need for scraped data like this and a little Google-ing and I found someone who provided a free API for it. I would really spend a little more time trying to find the right way to do this before resorting to scraping. Not only is it data theft, a pain in the a- to program it correctly but you risk them blocking you out at any time... and it will happen at the worst possible time!!!!
  23. Ideally you only let "Registered users" vote. Then you block that account from voting again. This assumes you have already established security on peoples accounts to avoid duplicates. If that does not apply to you, it really depends on how secure you need this to be. You could block by IP, that would probably be the best solution. You can double up security by also placing a cookie that says they had voted already (helps if people try to change their IP). If you want to get crazy, you can fingerprint their system, or install zombie cookies. But those are pretty intense operations for a simple voting system.
  24. You may also want to check like half the servers every 10 minutes, then the other half the next 10 minutes. That would cut your requests down 50% and 'maybe' won't be a big deal to what you are trying to accomplish?
×
×
  • 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.