Jump to content

Braet

Members
  • Posts

    12
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Braet's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. bingo!  ty - driving me mad and have been googling for days - that is (once I figured out how to properly use it) exactly what I needed there.
  2. I have a preg_match_all going through some information I submit by form, and pulling out numbers.  These numbers are often in the millions therefore have commas in them.  When I would add them, it would add each section, ie: 123,456,789 +123,456,789 would = 2736 instead of the actual 246,913,578 So I stripped the commas: [code]$numb2 = str_replace(",", "", $numb);[/code] Now it adds properly (yaay), but is very hard to read w/out those commas which brings me to my question, any tutorial that you can point me to (as my searches have yeilded nothing and "the" php manual is still confusing to this php newb) that will explain how to treat numbers with commas or a simple fix to either keep those commas and have it add from the array properly or to put the commas back in once the addition is done? tia yet again -Brae
  3. have a preg match that is working as needed, printing what I need it to as well, but for some reason each printed line is missing the very last character.  I've tried adjusting my regex but have only successfully broken it many ways: [code]preg_match_all("/The (.+?) drops (.+?)[^, which you pick up]\./", $data, $loot); $totLoots = (count($loot[1]) -1); $i2 = 0; while ($i2 <= $totLoots) {$row=$i2+1; if ($row % 2) {echo "<TR><TD>".$loot[1][$i2]."</TD><TD>".$loot[2][$i2]."</TD></TR>";} else {echo "<TR><TD CLASS=\"one\">".$loot[1][$i2]."</TD><TD CLASS=\"one\">".$loot[2][$i2]."</TD></TR>";} $i2++;;}[/code] it should return a name, and an item when there is a period after the item - and ignore it if it then goes on to say ', which you pick up' prior to the period.  It is returning the information, just cutting off the very last letter of the item. tia in advance.
  4. givinga little bump hoping someone today has an idea on this - still haven't found an answer. tia
  5. an .htpasswd file stores the username and (usually encrypted) password(s) for login to a specific directory. an .htaccess file is basically a set of server instructions.  In this instance, it would provide the server w/the instruction that this directory is password protected, and you can look here (path to .htpasswd file) to find the user/pass information that is allowed (.htaccess can be used for so much more, this is just one use). an .htaccess/.htpasswd can have various info in it - some things will always be different (username, encrypted password in the .htpasswd file - path to user root, log in comment, and other things depending if they will have only 1 user or multiples). ie: lots of coding to strip, match, if/else, etc - when I know that perl can do it in 2 lines (if they didnt authenticate to get here, tell 'em they have a security issue). If perl can do it, I know php can. From what I have found so far, seems the methods would be different depending if you are running php in cgi mode (my host does).  I will find this, I will I will I will! ;)
  6. well.. yes & no. Yes:  it would likely show me that the .htpasswd file is in root, and that there is an .htaccess in the proper directory.  No:  It would not show me if that directory was password protected (as both files could be blank, or the .htpasswd could have auth info for a diff directory, etc). still researching it and if I find the answer before someone comes up w/it here I'll post my results for any searching in the future.
  7. that will only show if it exists, not that they exist in the proper places (the .htaccess would of course be an obvious check - it would need to be in the same directory - but the .htpasswd file should be in root (non-web-accessible) on most servers). I should be able to check via the actual information sent via the login.  For the life of me I can not find my Perl script I did this in but want to say it was a check to see if $ENV('REMOTE_USER') or AUTH_USER (or something along those lines) was empty, give the warning - if it had info, they log'd in. Such a lack of sleep the past week however, that may be a code snippet floating in my head from something completely different.
  8. I know in perl it is a very easy thing to check to see if an .htaccess/.htpasswd is in place on (and used to access) the directory your script resides in - and then print a warning (ie: you lazy bum, add some pass protection to this will you?).  Seems I am at a loss on how to do this with php however.  I have tried various searches and have come to the conclusion I'm just not using the proper key words.  I do not want to authenticate w/php - just want to remind the user that they haven't locked up their admin. any code snips?  Links?  examples?  sympathies? tia!
  9. as it does for me, and if I add a little $ in there at the end, it gives me everything I need.  I now officially feel sick that I spent 6 hours focused on the wrong issues - thanks so much, now I can move on to figuring out why it's not going into my db (found 2 other issues based on your info).
  10. ok, I see what you are stating for output - but in case that format was incorrect I also added the $match3 (no info is returning).  What caused me to attempt printing out is that it was not putting the information (once separated) into the db table.  I then set it to print each match, as well as the $winremove variable, and the $match array to see exactly where the issue was.  Changing the echo coding still provides me with a lack of information in $match3 and the variables created from it. Perhaps I'm just missing something in the information you directed me to, but it seems to me the issue is that it is not finding any matches, there has no data to print (as $match3 should print as $winremove does, no?) tia!
  11. newb myself, but: [code]<?php $value="473"; if(ereg("[0-9]", $value)) {echo "yup";} echo $value; die(); ?>[/code] does work no matter the number 4 or 473 (and will not return the "yup" if it has no number.  Per php.net, preg_match is usually faster though - I do not know if ereg will suit your needs - but perhaps that will steer you in a direction suited to what you are attempting.
  12. 4 hours later and I still can not find where I have gone wrong - nor can I find the answers on my own, so here goes. My script is not finding matches, the code (well.. in its current incarnation): [code]preg_match_all("/(.+?) \((.+?)\) \[(.+?)\]\: (.+?)/ims", $winremove, $match3);[/code] A typical line it will be searching: Jonathan (729) [Title]: Information, perhaps nothing - perhaps run on sentences the script will echo $winremove for me - actual echo: Array[]; Array[]; Array[]; Array[]; Jonathan (729) [Title]: Information, perhaps nothing - perhaps run on sentences. Array from this code: [code]echo <<<TESTMATCH $match3[1][$i];<BR> $match3[2][$i];<BR> $match3[3][$i];<BR> $match3[4][$i];<BR> $winremove<BR> $match3 TESTMATCH;[/code] As I'm new to PHP (whoohoo, 5 days now!), I'm quite sure I'm falling under the ID10T ways and it's sitting plain as day in the coding above, but for the life of me I can not see it and hope someone here can. tia!
×
×
  • 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.