![]() |
Values being returned as NULL
I'm not sure what's causing it, I'm using a bit of the code from when you guys helped me last which seemed work work, but now it's not.
http://phpfi.com/271062 For the elseif section to see if any variables are empty, would that be best to put into one if condition and use the || operator? Also, I have another question. Is all that in the __construct() function necessary? It doesn't seem like it, but I'm not sure how else to pass the variables off into member variables. |
Hi Andrew,
The class looks fine to me. Setting default values in the constructor is a good thing, it provides a consistent place for property initialisation. With that said, if not all properties need to be set via the construct call then I would suggest adding a few "settor" methods, for example, to set the title independently of the constructor then you could add this method: PHP Code:
PHP Code:
As for your santize method, this isn't the cleanest approach to validation but it looks OK for its the task it is supposed to do. |
How would you recommend doing the santize function? Not looking for you to create a full function to do it, but could you list off how you would go about doing it?
|
I think what Karl is refering too, is that you do not have any clarity in your error reporting:
PHP Code:
I would hazard a guess that Karl will recommend an external validation class, as would i :) |
Yep bluesaga is right. I would improve the validation to allow for custom error messages, as bluesaga said, an external, reusable class would be ideal for this job.
|
Well, I would like to get it working first, then update later. I'll work on the specified errors for now.
Fixed all the bugs. Just stupid errors like forgetting the m_, capitalizing stuff that shouldn't have been, etc. |
| All times are GMT. The time now is 03:44 PM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0