Jump to content

Asheeown

Members
  • Posts

    471
  • Joined

  • Last visited

Everything posted by Asheeown

  1. Works perfectly, thank you very much.
  2. That regex sends back an empty array when using preg_match_all. I tried with the example I posted as well and it's the same thing.
  3. I'm making this simple parser that has turned out to be not so simple. Phrases/sentences are encased in apostrophes and parsed but when they CONTAIN apostrophes, slashes are added before it is parsed. For example, if someone entered the sentence (It's a sunny day today.), the output would look like this: 'It\'s a sunny day outside' I add the apostrophes manually on the outside to separate sentences but addslashes before that to escape any existing ones so far. However, my expression below just doesn't cut it, and I can't figure out how to skip over any apostrophes that have the escape character in front of them. $regex = "/'(.*?)'/";
  4. I'm working on a new project and this is a feature I've always wanted to implement. An auto-updating activity table. It will be shown at the top of each member page to show new 'posts' or whatever and it will refresh say every 10 seconds. I wanted to have records fade out on the bottom as new ones faded in. I can fade in and fade out records, I can also create new rows in the table with data coming from the ajax php request. For fading the table rows I use the following code: function ShowHideTableRow(rowSelector, show, callback) { var childCellsSelector = $(rowSelector).children("td"); var ubound = childCellsSelector.length - 1; var lastCallback = null; childCellsSelector.each(function(i) { // Only execute the callback on the last element. if (ubound == i) lastCallback = callback if (show) { $(this).fadeIn("slow", lastCallback) } else { $(this).fadeOut("slow", lastCallback) } }); } and to execute: ShowHideTableRow("#" + tbl.rows[6].id,false,function() { }); That would hide row 6 in 'tbl'. Thing is I'm severely confused. I'm not sure how to maintain a list of whats supposed to be there, or what gets switched out, what stays, what fades. I've just been butchering everything I code and I've been stuck for three days. If anyone else has done this could they point me in the direction of the code they used or the techniques they used to code it.
  5. Absolutely, and I figure designing and testing the structure of each will give me a nice final solution in the end. Maybe even a new combination of sorts. Well, I'll just have to find out.
  6. When I first read that I was like "crap, wish I knew if it was a sure more efficient way to do this." But this is actually a good opportunity. I'm going to create a structure for two methods, yours and creating a table for each log book. Then I'm going to make a script to create a few hundred log books in each and start populating them with thousands of rows. Then I'll run a stress test script against both my webservers and see each reacts to the processing loads. I think querying one table for all log entries might start to bog the query result speeds but I also think too many tables will bog MySQL in general so we'll see how it comes out. Thanks for the suggestion. I'll mark this as solved and most likely post my results when I'm done for future reference.
  7. fields (field_id, field_log_id, field_name, field_type) logs (log_id, log_name) fields_values (log_id, value_field_id, value_value) insert into logs (1, 'Walk The Dog'); insert into fields (1, 1, 'Location', 'String[200]'), (2, 1, 'BathroomStops', 'Integer'), (3, 1, 'FirehydrantsSeen', 'Integer'), (4, 1, 'GoodExercise', 'Boolean'); insert into fields_values (1, 1, 'Pittsburgh'), #Location (1, 2, '3'), #BathroomStops (1, 3, '15'), #FirehydrantsSeen (1, 4, 'False'); #GoodExercise Just left out the log ID in the field values table. So you think this would be an efficient method of doing this even with say 200 log books and around 20-50 entries a day on each?
  8. I'm making a log book system and I'm in need of a good dynamic fields idea. In this system a user can create a new log book. In that creation I want him/her to be able to specify custom fields for the logs in that book. So for instance if I was making a log book on when I took my dog for a walk, I might want the following fields: * Obviously joking in most of these My first choice to myself was new MySQL tables for each book. Just take the fields they entered with a data type and create a new table for that specific log book. My second choice was to create tables that the data would be stored in with an abundant amount of columns. For example, 20 or 30 columns, so when the user entered the fields they wanted I could have a definitions table telling me which column did what. The more I go on about this is, it seems like a MySQL question, but in reality PHP will be determining what fields to show on the screen and so on. So really I'm looking for a simple efficient solution, no code, just the idea.
  9. Where is your secured page getting all of its variables? $username, $row? The order of your pages doesn't make sense and none of them link together. I see you set a cookie after logging in and then the user data in session variables in the secured page, but if the secured page doesn't know where to get that information it can't set it.
  10. <?php $q = ("UPDATE listings SET location='$location', company_name='$company_name', editor1='$editor1' WHERE id = '$id'"); $result = mysql_query($q) or die("<b>A fatal MySQL error occured</b>.\n<br />Query: " . $q . "<br />\nError: (" . mysql_errno() . ") " . mysql_error()); ?> As long as you populate $id with the correct listing id before this statement now it will update the specific record.
  11. You need a MUCH MUCH better way of verifying your licenses. Send it to a PHP page and have it verify against a database with string sanitization going on. ANYTHING will be better than that. Seems like you need to focus on that before you actually go locking down the code with this license page. Encrypting each page against formula that's made to generate the license codes is your best bet. This way license codes generated from the formula will be able to decrypt the code and allow it to run.
  12. Post the error. EDIT: If a blank screen is showing, turn on errors for PHP temporarily, even just to see this.
  13. $count1 = count($large_images); $i=0; while($i<$count1) { mysql_query("INSERT INTO images (image, thumb, when_up, who) VALUES (" . $large_images[$i] . ", " . $small_images[$i] . ", '$when_up', '$by_who')"); $i++; } That should work just fine
  14. Okay, so you guys were right. The equation I gave you has no solution. Problem is it isn't the real equation. While transcribing it to me, my friend mistyped one of the letters in the equation. Here are the actual two equations: A * (BC) = (DEF) = (HK) * G H * (EC) = (DBG) = (AK) * F I bolded the incorrect letter. This set of equations yield two answers: AND Sorry about the confusion guys. I knew something was wrong, the script averaged about 500 million attempts per 12 hours, and it was running for days without posting an answer. I found these new answers in less than 10 seconds a piece.
  15. I'll see if I can grab the answer tomorrow. He said an answer does exist so I'm not sure. I rechecked the problem setup and I did not type anything incorrectly.
  16. Yes, positive, I just didn't ask for it because I wanted to actually see if I could script something to figure this out. As long as my script is accurate in guessing possibilities then that is fine with me. Do you think I should use your form instead of grouping? A * (10*B + C) = (100*D + 10*E + F) = (10*H + K) * G A * (10*E + C) = (100*D + 10*B + G) = (10*A + K) * F
  17. This problem was shot my way by a friend who is curious of the answer. And it is essentially this: You are given these nine (9) letters: A, B, C, D, E, F, G, H, K The letters each represent a number (1-9) and each is unique, so if A=1 no other letter could equal 1. Given that information you have to find the set of numbers that will make the following two equations correct. A * (BC) = (DEF) = (HK) * G A * (EC) = (DBG) = (AK) * F Letters that are grouped together in parenthesis make a whole number (Ex. B=2 C=3 (BC) = 23) So I wrote this PHP script to run random sets of numbers through and see if they worked out, the thing is, it's been running for three days now and hasn't found an answer. Is my scripting incorrect or is it really just taking that long? And I've tried it with just one or two parts of the equations and it has found answers, but only for those specifically. <?php set_time_limit(0); // Start time elapsed function $mtime = microtime(); $mtime = explode(" ",$mtime); $mtime = $mtime[1] + $mtime[0]; $starttime = $mtime; //////////////////////////////////// while(true) { $a = rand(1, 9); while(true) { $b = rand(1,9); if($b != $a) { break; } } while(true) { $c = rand(1,9); if($c != $b and $c != $a) { break; } } while(true) { $d = rand(1,9); if($d != $c and $d != $b and $d != $a) { break; } } while(true) { $e = rand(1,9); if($e != $d and $e != $c and $e != $b and $e != $a) { break; } } while(true) { $f = rand(1,9); if($f != $e and $f != $d and $f != $c and $f != $b and $f != $a) { break; } } while(true) { $g = rand(1,9); if($g != $f and $g != $e and $g != $d and $g != $c and $g != $b and $g != $a) { break; } } while(true) { $h = rand(1,9); if($h != $g and $h != $f and $h != $e and $h != $d and $h != $c and $h != $b and $h != $a) { break; } } while(true) { $k = rand(1,9); if($k != $h and $k != $g and $k != $f and $k != $e and $k != $d and $k != $c and $k != $b and $k != $a) { break; } } if(($a * ($b . $c)) == ($d . $e . $f) and ($a * ($b . $c)) == (($h . $k) * $g) and ($a * ($e . $c)) == ($d . $b . $g) and ($a * ($e . $c)) == (($a . $k) * $f)) { break; } } echo "A = " . $a . "\n"; echo "B = " . $b . "\n"; echo "C = " . $c . "\n"; echo "D = " . $d . "\n"; echo "E = " . $e . "\n"; echo "F = " . $f . "\n"; echo "G = " . $g . "\n"; echo "H = " . $h . "\n"; echo "K = " . $k . "\n"; echo "\n\n"; // End time elapsed function $mtime = microtime(); $mtime = explode(" ",$mtime); $mtime = $mtime[1] + $mtime[0]; $endtime = $mtime; $totaltime = ($endtime - $starttime); echo "This page was created in ".$totaltime." seconds\n"; //////////////////////////////////////////////// ?>
  18. If any extra explanation or examples are needed just let me know.
  19. Alright let me focus on my main problem since I probably was too vague with my question. If I have a string like this The first three directives with operators and values I can pull out so it would look like this: Base: Type == Boots Quality == rare Extra: FRW >= 30 Now as it gets to the enclosed groups, that's where I am stuck. I need To be: Group 1: Subgroup 1: FHR == 10 Dexterity >= 9 and (substituting for || operator) ItemMagicBonus >= 25 and ItemGoldBonus >= 80 I'm trying to get the full group which is the overall statement enclosed in ()s and then subgroups also enclosed in ()s.
  20. Okay, so I'm trying to attempt to parse a configuration file for a program I'm using. Basically I'm going to end up parsing it and allowing a user to edit it, write it and download the finished file. Each line represents an item that has directives within. The directives are encased in []'s, they then have an operator (i.e. >=, ==, <=, etc) followed by the value for that operator. Seems easy at first but some of them have hard balls thrown in there, such as directives located within brackets to indicate a group. Here are some examples: The first one is one of the harder ones, the second one I already can do for the most part. Directives that have + signs in between them are linked instead of using && operators to define all of them. This is the code I have currently: $handle = @fopen("Everything.NIP", "r"); if ($handle) { while (!feof($handle)) { $lines[] = fgets($handle, 4096); } fclose($handle); } $i=1; foreach($lines as $x) { $x = str_replace(' ', '', $x); $Line = explode("#", $x); $Base = $Line[0]; $Extra = $Line[1]; // Calc base stats echo "<br>"; preg_match_all('/\[(.*?)\](.*?)(.*?)/si', $Base, $nvhost_matches); echo "$i Base Stats:<br>"; foreach($nvhost_matches[3] as $m) { echo "$m<br>"; } preg_match_all('/\[(.*?)\](.*?)(.*?)/si', $Extra, $nvhost_matches); echo "$i Extra Stats:<br>"; foreach($nvhost_matches[3] as $m) { echo "$m<br>"; } echo "$x<br><br>"; $i++; } It doesn't even work right now since I extract all the spaces in the string. The spacing is screwed up in the config file so I figured it'd be easier to strip it and parse everything without spaces. Any help at all would be appreciated.
  21. I'm making a program that is going to be communicating with mysql a lot. For all of it's directions actually. It's going to constantly run select queries to check for pending commands and constantly run insert queries to write other data to other tables. There will be lots of these running at once. So lets say 100 people are using it at the time and they average 10 queries a second. How do I lower my bandwidth usage? Should I keep an open connection for each user? Is there a way to keep a query open so it doesn't need to execute every time but basically post changes? Just looking for any suggestions on lowering my usage. If you don't think that many queries is a problem that's fine with me, I'd like to hear that too
  22. I want to make a third party program in C# on a windows based service that a PHP application will connect to, to receive data. What is the best way to go about this, a telnet server that PHP connects into? Or some other way of transmitting the data. Many updates will be made on the data per minute so it needs to be efficient also.
  23. I have a list of sites in this form: www.example.com Now, obvious to start with gethostbyname() right? Well all it returns is the hostname right back. $ip = gethostbyname($x); echo "$x - $ip<br>"; Something I'm doing wrong here?
×
×
  • 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.