Jump to content

btherl

Staff Alumni
  • Posts

    3,893
  • Joined

  • Last visited

Everything posted by btherl

  1. Try var_dump($row), and you will see the problem After that, try adding the MYSQL_ASSOC option, as mentioned here: http://sg2.php.net/manual/en/function.mysql-fetch-array.php
  2. You may want to call an external program to unzip the files. I can't imagine how unzipping would require so much memory, unless you are reading the entire archive into memory.
  3. Thanks, it does help I'm not familiar with the software you're using (apart from mysql), but I think the most likely problem is that the username or password is not what mysql is expecting. How did you set the root password initially?
  4. Sorry, I didn't read carefully. Which program are you using to connect to mysql?
  5. Can you post your full code (or at least the entire section related to mysql), and also tell us what happens when you try to store the data? Is there any error message? Is anything stored (even if it isn't what you expected to be stored)?
  6. Can you post your code (with the password removed of course) The error means that it didn't recognize your username and password. It may be because they are incorrect, or it may be because they weren't passed correctly. There's other possibilities too, so first I want to see that your code is passing them to mysql correctly
  7. The reason for the unexpected ordering is that varchar data is sorted as strings, not as numbers. String sorting doesn't align the units, tens and hundreds, which is why you get the strange sort order you see. The solutions already mentioned will work. Another alternative is to use an integer type for your property names. Integers will be sorted in the way you expect, with 1 < 2 < 3 < ... < 10 < 11 < ...
  8. Do you have a unique identifier (like an auto_increment id) for your users? Having that will make it much easier, as you can exclude that row when checking.
  9. And what is in users.php?
  10. Did you copy the dll into the "extension_dir" folder (should be listed in php.ini), and restart the webserver? There's brief installation instructions here: http://www.php.net/manual/en/install.pecl.windows.php
  11. I think a "complicated little function" is the way to go. To write it you need a full list of the various business constraints you need to work with (which we don't have). Then you can write a function that implements those constraints. If you give us all the constraints, we can probably come up with an implementation for them. It may be easiest to just write a list of rules like "If splitting 1 adult and 5 kids between 2 rooms, do it this way". If someone is booking large numbers of rooms at one time, you can fall back to manual assignment (or give a temporary automatic but non-optimal assignment, which can be reviewed later)
  12. "Windows users must enable php_printer.dll inside of php.ini in order to use these functions. Unbundled PECL extensions may be downloaded from: » http://pecl4win.php.net/" You will find the file under "PECL extensions" on the website mentioned in the above quote.
  13. If you can come up with some code, even if it doesn't do what you want it to, then it's much easier to get people to fix it. People like having a first draft to work with. If you're totally lost about where to start, I would look at the following: 1. Processing forms 2. Storing and retreiving data from mysql (in response to a form request) Start with something simple, like just logging in and logging out, and perhaps editing one type of information (like the user's name). Then once you've got that, start adding in more things to edit. If you get stuck while doing the above, post the code you have so far and explain what it does now, and what you want it to do. If you haven't already, try using sessions. They will be a huge help.
  14. Hmm.. are you trying to eval() javascript code in php?
  15. The code you posted gives no parse errors here, php 4.3.10
  16. The main page gives more information for installation. Basically you must install a dll before you can use those functions. http://sg.php.net/manual/en/ref.printer.php
  17. If your site is accessed regularly, you can have some code that runs every time your site is accessed. This code will check when your job was run last, and run it again if it was run more than 30 minutes ago. That will give you an "at least 30 minutes" job. Alternatively, you can run the cron job somewhere else and have it hit a script on your site every 30 minutes. That script can do the work.
  18. Try this: if (!preg_match('|^[[:blank:][:punct:][:alnum:][:space:]]{1,500}$|', $listingdescription)) preg is faster than ereg too.. it's a win-win situation Edit: There's no need to use eregi() rather than ereg() when you are not mentioning characters by name (or when you include both a-z and A-Z as in the first regex). eregi('A-Z') and eregi('a-z') are identical, because eregi() ignores case.
  19. Ok you're right, it's not simple in php But it's simpler in php than sql. For me anyway, being an experienced programmer. Hmm.. I am a bit stuck on how to group by a subquery, since I'm not too familiar with mysql. I'm a postgres user, which handles a lot of things differently. The idea I have is like this: GROUP BY (SELECT max(time) FROM vehiclehistory AS inner WHERE inner.time < time AND inner.location != location) AS group_time But I don't know if that is valid syntax. Probably not. The idea is that the subquery gives you a value which is unique for each vehicle stop, even when there is more than one stop at the same location in that day. But the value will be the same for every entry within that stop. For doing it in php, the general structure is $last_location = null; $locations = array(); $start_time = null; $last_time = null; while ($row = mysql_fetch_assoc($res)) { if ($row['location'] !== $last_location && $last_location !== null) { # We have reached a new location. Store the old data and prepare the new $locations[] = array( 'location' => $last_location, 'time' => $last_time - $start_time, ); $last_location = $row['location']; $last_time = $start_time = $row['time']; } else { # Still at same stop. Just update the time only. No other work to do. $last_time = $row['time']; } } # loop is finished. Record the final stop (unless there were 0 stops that day) if ($last_location !== null) { $locations[] = array( 'location' => $last_location, 'time' => $last_time - $start_time, ); } The time arithmetic won't work in there.. you will need a function that calculates differences between times. Or you can get mysql to give you a time in seconds instead of as hours:minutes:seconds.
  20. Does your current code work? Edit: The reason I ask is that it doesn't look like valid php to me
  21. Check for any javascript on the page. PHP cannot autosubmit by itself, only javascript can (or other client side software like flash and java)
  22. Can you make the entire script available? Or at least the function containing this code, so we can do automated syntax checking. If I copy and paste what you've posted I get a whole heap of unrelated errors. And it's too messy to check manually.
  23. Hmm.. it may be possible, but very messy. Basically, you can do what you want to do by distinguishing rows based on the condition "What was the most recent row which does not match this location?". That translates to a subquery selecting the first row with date < this row's date, and location != this row's location. Does that make sense? It half makes sense to me. But the easiest way by far is to select all the rows and process it in php. Then it's simple.
  24. perl regexps need a delimiter, like preg_match('/a/', $str, $matches); So try: preg_match("/http:\/\/files\.redvsblue\.com\/RvB05\/5x(.*)\/fl4sh\/(.*)\.flv/",$text,$matches); Or you can change the delimiter to avoid all that escaping: preg_match("|http://files\.redvsblue\.com/RvB05/5x(.*)/fl4sh/(.*)\.flv|",$text,$matches);
  25. Maxcell, you will still need a strategy for generating those words. Usually you will start with a simple dictionary (english words, names, or words in whatever language is appropriate) and generate variations on those words, like add 0 to the end, replace "l" with "1", and so on. For the overall structure you could use: <?php if ( $argc != 4 ) { printf("--------------------------------------------------------"); printf("\nUsage: php $argv[0] dictionary one_time_token encoded_pw\n"); printf("\n dictionary = Textfile containing password, one each line"); printf("\n one_time_token = Token extracted from sniffed packet"); printf("\n encoded_pw = Already encoded password extracted from sniffed packet\n"); printf("\nExample: \nphp $argv[0] dic.txt 045E54583B13364A6E77E2FAC27AFD90 7C62B02BF9A238ED1455F74F03367C49\n\n"); printf("Don't mix the arguments - sorry for this.\n"); printf("--------------------------------------------------------\n"); exit; } $one_time_token = $argv[2]; $encoded_pw = $argv[3]; $dic = $argv[1]; $a=0; $b=0; $t=time(); while($word = next_word()) { $password = md5($word); $password = strtoupper($password); $final_step = $password . $one_time_token; $final_step = strtoupper($final_step); $password_enc_my = md5($final_step); $password_enc_my = strtoupper($password_enc_my); if ( $password_enc_my == $encoded_pw ) { printf("\nSUCCESS - Password is '$word'\n"); break; } if($a==20000){$s=time()-$t;printf("Time: $s seconds, trying word #$b - $word\n");$a=0;}else{$a++;$b++;}; } function next_word() { static $x = 0; // Word generation code in here. $x is used to remember where we are up to. // If no words left, return false } ?> Then you just need to decide on your word generation strategy, which will go inside next_word()
×
×
  • 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.