Search found 148 matches
- Wed Jul 11, 2012 6:10 am
- Forum: Coding Critique
- Topic: My Class file! Need Critique!
- Replies: 12
- Views: 21874
Re: My Class file! Need Critique!
A couple of things: 1) Use curly brackets even when they're not necessary; it's more future proof. // Bad public function process() { if( $this->valid_token() && $this->valid_data() ) $this->register(); return count( $this->errors )? 0 : 1; } // Good public function process() { if( $this->va...
- Sat Apr 07, 2012 1:56 am
- Forum: Coding Critique
- Topic: Proposed new Tutorial on Login Scripts for review
- Replies: 4
- Views: 15348
Re: Proposed new Tutorial on Login Scripts for review
prepared statements ftw but a total newbie, who doesn't understand the basics of php even will doubtful know what PDO is. You may argue that such a newcomer wouldn't attempt a login system but they often do True, but I always think it's better to learn best practices from the start than to learn ou...
- Fri Apr 06, 2012 1:23 am
- Forum: Coding Critique
- Topic: Proposed new Tutorial on Login Scripts for review
- Replies: 4
- Views: 15348
Re: Proposed new Tutorial on Login Scripts for review
Some suggestions: 1. Although you talk about password hashes, you don't talk about password strength . It doesn't matter how reliable the data stored in your database is at preventing a hacker from finding out your users' passwords if they can be easily broken by a brute force attack (which presumab...
- Thu Nov 24, 2011 10:47 pm
- Forum: Coding Critique
- Topic: Pulling a single MySQL value
- Replies: 6
- Views: 7531
Re: Pulling a single MySQL value
I didn't think booleans could be returned from (or stored in) a database. Aren't the data types used one of string, integer, double, blob, or NULL?Hermit TL wrote:The reason I prefer NULL over FALSE is that sometime a result of FALSE would be correct if I am trying to pull a TRUE/FALSE value from the database.
- Sun Jun 19, 2011 6:42 am
- Forum: PHPDN Suggestions
- Topic: Add line-height to text within [syntax=php][/syntax] tags
- Replies: 2
- Views: 21061
Add line-height to text within [syntax=php][/syntax] tags
At the moment it's quite difficult to read the code people provide because of the lack of line-height/leading. Using { line-height: 1.2; } seems to be the preferred option.
- Sun Jun 19, 2011 6:24 am
- Forum: Coding Critique
- Topic: MySQLi Connection, Statement, and Result classes
- Replies: 16
- Views: 17624
Re: MySQLi Connection, Statement, and Result classes
Good point, Weirdan. Changed.
- Sat Jun 18, 2011 6:46 am
- Forum: Coding Critique
- Topic: MySQLi Connection, Statement, and Result classes
- Replies: 16
- Views: 17624
Re: MySQLi Result Class
I've updated the classes to account for suggestions by josh and John Cartwright . Statements can be chained and there are separate classes for INSERT, DELETE, UPDATE, and SELECT results. I've also implemented the Iterator interface on the MySQLiSelectResult class to allow iteration over the result s...
- Sun May 01, 2011 4:20 am
- Forum: Coding Critique
- Topic: Get start of week
- Replies: 7
- Views: 8847
Re: Get start of week
I see what you mean. Using names would probably be best.
- Sat Apr 30, 2011 12:45 pm
- Forum: Coding Critique
- Topic: Get start of week
- Replies: 7
- Views: 8847
Re: Get start of week
I don't really see what difference it makes using 1 as Monday and 7 as Sunday. If the person using the function cares that much about which integer refers to which month then they're more than welcome to change it. There's no point in making it unnecessarily complicated.
- Fri Apr 29, 2011 10:42 am
- Forum: Coding Critique
- Topic: Get start of week
- Replies: 7
- Views: 8847
Re: Get start of week
Aren't there people who start their week with sunday. That's what the third parameter is for; to set the day which starts the week. It defaults to 1 (Monday). eivind : Originally I did have that but decided to change it to make it quicker for those who might want to use the default format but want ...
- Sat Mar 26, 2011 8:12 am
- Forum: Coding Critique
- Topic: Get start of week
- Replies: 7
- Views: 8847
Get start of week
function getStartOfWeek($format = '', $offset = '', $start = 'Monday') { if (empty($format)) { $format = 'Y-m-d'; } $date = array( 0 => 'Sunday', 1 => 'Monday', 2 => 'Tuesday', 3 => 'Wednesday', 4 => 'Thursday', 5 => 'Friday', 6 => 'Saturday', ); if (!in_array($start, $date)) { $start = 'Monday'; }...
- Fri Mar 25, 2011 1:28 pm
- Forum: Databases
- Topic: Update common column across multiple tables
- Replies: 2
- Views: 1135
Re: Update common column across multiple tables
Unfortunately this only updates the column in the first table. But then this will work: UPDATE t1 JOIN t2 USING (user) JOIN t3 USING (user) SET t1.user = 2, t2.user = 2, t3.user = 2 I'm not sure why I didn't consider this before. :? And would this in fact be a better solution than updating each tabl...
- Tue Mar 22, 2011 12:25 pm
- Forum: Databases
- Topic: Update common column across multiple tables
- Replies: 2
- Views: 1135
Update common column across multiple tables
Is there a way to combine the following queries into a single multi-table update, and if so, would it be faster? There are 24 tables with the 'user' column, and every one needs to be updated as follows (where 2 and 3 are dupes of 1 and so need to be merged). With 4,000 sets of dupes I have close to ...
- Mon Feb 21, 2011 3:29 pm
- Forum: Coding Critique
- Topic: Password validation
- Replies: 5
- Views: 6849
Re: Password validation
Yours are a bit off-the-scale, but in security more is better, and storage is cheap, so go for it if you so wish. I'm never happy with second best. And it's also my intention to better understand how these things work -- if I just accept what's "good enough" then I'll never really know wh...
- Mon Feb 21, 2011 12:50 pm
- Forum: Coding Critique
- Topic: Password validation
- Replies: 5
- Views: 6849
Re: Password validation
Thank you for the comments, Mordred . As I want to make the function as secure as possible, how many bits should the key and the password each be (the password can be lengthened as much as necessary using the "pepper", assuming I use hash_hmac('sha512', $password, $key)? Edit: I wonder whe...