Jump to content


  • Posts

  • Joined

  • Last visited

Posts posted by LLLLLLL

  1. I get some results back from a query

    Col 1    Col 2
    X        ABC
    X        DEF
    X        GGH
    Y        Blah
    Z        Foo
    X        Bar
    Z        Something
    G        Blah


    I'd like to get the count of the item in Column 1, basically to associate each "instance" of the column 1 value to a 1-based index.

    Col 1    Col 2      Col 3
    X        ABC        1
    X        DEF        2
    X        GGH        3
    Y        Blah      
    Z        Foo        1
    X        Bar        4
    Z        Something  2
    G        Foobar


    In the case of Y and G, they only appear once in the result set, so I'd like column 3 to be either a 0 or NULL.


    Ideas on the best way to do this?

  2. I'm not too sure that's relevant (I'm not finished with the code here, and if there's a better way I'll use it)... I really just want to know how to determine the timespan between two times. This is trivial in C#.  ;)


    But since you ask...


    $now = date( 'Y-m-d H:i:s' );
    echo "last attempt time: " . strtotime( $di->attempt_time );
    echo "<br>now: " . strtotime( $now );
    echo "<br>difference: " . ( strtotime( $now ) - strtotime( $di->attempt_time ) );


    where "di->attempt_time" came from a mySql datetime stamp.

  3. I've echoed these things to the screen, the first two values come from strtotime and the third is math:


    last attempt time: 1286374178  (About 1:24 pm)

    now: 1286735148 (About 1:25pm)

    difference: 360970


    What does 360970 represent? I want to know how many minutes have elapsed between the two times.

  4. What's the best United States Postal Service API that anyone is using? I've tried three (from the top google results for this question) but none seem to work. No errors, just not getting results back from USPS. I'd like to know what anyone else is using, and if you have some sample code!



    (PHP 5)

  5. $filename is a full path to the file.


    I'm reading the filename out of a mysql database; I don't think there's a security issue there.


    I guess I was wondering if someone had a way to know where the file is coming from. My directory structure has the public_html directory and the "my_files" directory parallel. So there seems no way for anyone to get to "my_files", as it is only accessible from the server. But when I serve up a file from that directory, I wanted to be sure that there's no way for the user to actually know the path/location of the file.


    I think I've done this, but I just wanted to ask for other opinions. I'm not 100% sure of possible security issues.

  6. I have a file on my server that I will stream to the browser:

    header( "Content-Description: File Transfer" );
    header( "Content-Type: application/force-download");
    header( "Content-Length: " . filesize( $filename ) );
    header( "Content-Disposition: attachment; filename=$filename");
    readfile( $filename );


    $filename is going to be in a location that's not publicly available (there's no URL to it, as it's on the server, and not within public_html or subdirectories).


    Any safety concerns here? Basically, I'm just curious if a user has any way to steal the file or otherwise access the directory. I don't think so, but I'm just tossing this out here as a general discussion.



  7. On MySQL 5.1.47, PHP 5.2.14.


    Is there a way to somehow send all mysql errors or queries to a log? I'd like to do this in a global manner, not query-by-query.


    I just changed some major functionality, and there are no PHP errors in the error log, but data is missing from the DB so I'm sure there's a mysql error somewhere. So a global setting is clearly ideal here!

  8. :'(

    I'm calling a function that resets a couple arrays:


    public function resetStuff() {
    $this->someArray = array();
    $this->someOtherArray = array();


    However, someOtherArray is not resetting!! How could that be?


    I can add debug statements to echo the size of the arrays before and after the function calls. It shows that:

    someArray went from n to 0

    someOtherArray went from n to n


    How is that possible??

  9. I'm doing this for now. pretty ugly

    public function setPaymentDate( $pds ) {
    	// pds is "pay date string", in the format of HH:mm:ss MMM DD, YYYY PDT
    	$a = explode( ' ', $pds );
    	$t = explode( ':', $a[ 0 ] );
    	$monthText =  $a[ 1 ];
    	$day = str_replace( ",", "", $a[ 2 ] );
    	$year = $a[ 3 ];
    	$hour = $t[ 0 ];
    	$min = $t[ 1 ];
    	$sec = $t[ 2 ];
    	// this is ugly. A better way?
    	$months = array(
    		"Jan" => "01", "Feb" => "02", "Mar" => "03", "Apr" => "04",
    		"May" => "05", "Jun" => "06", "Jul" => "07", "Aug" => "08",
    		"Sep" => "09", "Oct" => "10", "Nov" => "11", "Dec" => "12"
    	$month = $months[ $monthText ];		
    	$unixTs = mktime( $hour, $min, $sec, $month, $day, $year );
    	$this->payment_date = date( 'Y-m-d H:i:s', $unixTs );	

  10. It seems like this is a question that may be on here already, but I couldn't find it with a search, so I apologize.


    I am given a string that represents a datetime, and it is always in this format: HH:mm:ss MMM DD, YYYY PDT.


    I just want to turn that into a proper format for mysql (Y-m-d H:i:s), but I'm not exactly sure how to go about that. (I could do this in C# rather quickly!)


    Probably a simple question, I hope someone can help! Thanks.

  11. Perhaps this is not clear.


    Let's say that the code I wrote in my initial query is for a form on page 1. This will do a POST to page 2.


    In page 2's code, I don't want to receive the POST message in plain text. If the "password" input field has a value of "mypassword" that the user typed in, I want to see the encrypted version of that string, not the actual string. I don't want the string to be visible to anyone at any point. How can I do that?

  • 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.