LLLLLLL
Members-
Posts
306 -
Joined
-
Last visited
Everything posted by LLLLLLL
-
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?
-
Never mind. Code was right, database had wrong value.
-
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.
-
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.
-
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! Thanks (PHP 5)
-
Oh, well yes that makes sense. Thanks.
-
Pardon my ignorance, but won't that then make the file function fail altogether? http://php.net/manual/en/function.basename.php Given a string containing a path to a file, this function will return the base name of the file. It seems like it would fail with file not found.
-
Fair enough. I guess I will copy the file to a temporary directory and stream from there. This way the user won't know as much about the server. Thanks!
-
Well I have two questions there: 1 - Can the client see this information? 2 - Even if the client can, does it matter? The file is not directly accessible from the web, as far as I am aware. (Can you tell me how I'm able to see the file information in my browser, by the way?)
-
Sorry, why does that change help with security?
-
$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.
-
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. Thanks!
-
Global setting to log all mysql errors (and/or queries)?
LLLLLLL replied to LLLLLLL's topic in MySQL Help
Well, you're assuming the code I have is good! It was inherited, so mysql_query($sql) is all over the place without proper handling of stuff. I'll hack away at doing it right with a single DB accessor class... -
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!
-
This was indeed helpful: error_reporting set to E_ALL and display_errors set to ON There was a typo in some OTHER code that caused downhill problems. Argh. Thanks for that info.
-
Excellent. Yes, I just tested this as well. thanks.
-
:'( 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??
-
strtotime just knows how to parse "HH:mm:ss MMM DD, YYYY PDT"? This was unclear to me in any documentation. I was using http://www.php.net/manual/en/class.datetime.php for reference. (I haven't tried your code; I'm away from my dev environment right now.)
-
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 ); }
-
Note that I'm on PHP Version 5.2.14.
-
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.
-
Your name is fortnox! You, of all people, should understand security!! Well thanks for the info. I'll look around and post anything relevant that I find.
-
I figured as much. How can this be implemented?
-
Well, it IS a password field, after all. How do other sites do this? Surely when I sign into amazon, my password is encrypted, right? You wouldn't want network sniffers to grab passwords. If I went the JavaScript route, is that safe? How would that look?
-
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?