Jump to content

pl_harish

Members
  • Posts

    10
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

pl_harish's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. We have an application that works fine on a normal win32 based PHP-Apache-Mysql system. Recently we moved to a new server which is win64 bit, and web server we use here is iis 6. Though there were almost no changes in code as expected, we had a PHP Access voilation xxxxxx(typical windows memory id) problem occuring on almost every page request. Checking forums, we found the problem was a known bug in php and was corrected in php 4.x We are using php 5.2.x and mysql 5.1.x, both installed as appropriate on a win64 bit win2003 machine. We couldnt understand why the error was still appearing. In one of our many tests, We tested by inserting a 1 sec delay for every 100 mysql query requests the php script made (the script is a large database updater and processes several 100,000 records before it ends). Inserting this delay kind of stabilized the system, and we stopped havng the php access violation problems. Questions, we are trying to find answers for: 1. Is php tested and stable on win 64 bit.. are there critical, known bugs. 2. Is the php access violation, an unfixed known bug on php for 64 bit machines. Any help/information is appreciated.
  2. For a short discussion about the differences between print() and echo(), see this FAQTs Knowledge Base Article: http://www.faqts.com/knowledge_base/view.phtml/aid/1/fid/40 I prefer to use echo and its different forms.. like <?= "print this" ?> short tag outputs echo <<<END print whatever is here.. just like it is. This is for some reason refered to as "here document" syntax. adfa df a d a <<<END and the usual ones. echo "hello"; echo ("hello"); I use print.. only as print_r() for printing arrays during debugging. This function print_r() is very helpful for printing arrays in a structured manner. For example: $testArray = array("hello", "world"); print_r($testArray); //outputs array() { [0] = hello [1] = world }
  3. while i agree to that.. i assume, if you hire hosting, you should look for atleast the basic things that you need, rather than "write code that works on ANY server". shouldn't we be looking at best practices as that is best for code rather than best for server hosting companies. if some company doesn't support fopen but only curl, does that mean fopen is not best practice...or curl is better than fopen?? yes, if short tags are not supported on your server, it is a stupid suggestion.. but having <? tag enabled, <?= tag enabled, having .php extension enabled (rather than just .php3/.php4), etc, are very basic items that any valuable hosting should be doing if we are even going to put up a php website. regards, Harish. www.floresense.com www.harishpalaniappan.com
  4. I do not understand exactly either.. but is your question about "layers" in architecture. like, to get data, we would instance a class and call a method, which in turn instances a data access class, does the required and returns the value. So it looks like we could have actually directly used the methods in the data class. is that your question? if yes, layering implementation as "front-end classes > logic classes > database classes" make more sense than doing it directly in bigger projects .. project which have or will easily grow to have more than 3000 lines of code. since i am not sure whether this addresses your question, i will like to explain more if this helped. regards, Harish www.floresense.com www.harishpalaniappan.com
  5. Firstly, Please don't extend a db class unless the class you are extending also has a lot to implement in db access requirements. If your processing scripts or logic needs to do db access you can use an instance of the db class. and you can always have a singleton instance of the db class if your requirements suggest. I strongly feel data classes (if implemented as classes at all.. which is good) should be isolated from other classes and only arguments passed to methods to do the required.. not extend the data class in every other class. Extending means, you are expecting to use all methods of the data class, its variables and further going to add on it. To your question : do you need a constructor? like already mentioned by another user here.. it is not mandatory but a best practice even if it is empty. and you will need a constructor if you want to set values to some variables inside your class upon instancing it. for example, if we have a user class with a user id private variable. if makes lot of sense to set the user id variable with a value as soon as you instance the class. regards, Harish. www.floresense.com www.harishpalaniappan.com
  6. Between objects and arrays its a simple equation.. You use arrays as long as the data is manageable with just an array.. manageable in the context of the programmer understanding easily what is where, and be able to quickly draw a flow chart of how data travels within the code if asked. People use objects sometimes even for one field of information.. which could easily be done with arrays.. but they do objects because they expect to have more fields in the near future.. if things are arrays, you will have to spend more time increasing the number of fields handled, because simply arrays are not as organized as objects. $user->isLoggedIn() is more sensible and feels easy to upgrade than isUserLoggedin($username), though both will typically have the same kind of implementation,.. and actually the object way will have more code to type to create the user class..instance it, etc., It entirely depends on what the programmer wants to do.. and how much time he/she has. If professional code is what you are looking for, do object for all data that has child data (or at least will have in future) Theoretically, if things go beyond 2 dimensions in an array, objects are used.. because arrays beyond 2 dimensions are too unfriendly.. considering we want to understand and follow our code after sometime without taking a painful code walk. regards, Harish. www.floresense.com www.harishpalaniappan.com
  7. In OOP, this is a standard 3-tier architecture like scenario.. and i believe thats the best way. 1. Have a data layer dataL.class.php 2. Have all your data access implementation within this class. including sql query's, opening closing connections, executing and returning values. 3. Have all your sql in this class as private constants like $user_ins = "insert into users (name, email) values ('@name@','@email@');" 4. Create methods in the data layer class like public function user_add($name, $email) { $query = $this->user_ins; $query = str_replace("@name@",$name,$query); ... call execute functions.. and return the result required...or just return true/false. } I use this. http://www.floresense.com/resc_center/?c=3&art=1393 regards, Harish www.harishpalaniappan.com www.floresense.com
  8. can you post a sample of the actual file and what you want to do with it. regards, Harish www.harishpalaniappan.com www.floresense.com
  9. Firstly, Try to debug by doing print_r($_POST) at the beginning of the form processing page to chk if values are passed. if the values are infact not passed, make sure your form and elements have the name attribute. this is important on many browsers unlike IE where id attribute would do. That should help. Secondly, instead of <input type="text" name="name" value="<?php echo $name; ?>"> best practice is <input type="text" name="name" value="<?= $name; ?>"> also best practice is set your php.ini such that you can use just <? why use 3 chars in excess every time.. if you are using a hosting company, then probably they have already done that and only your style gotta change. regards, Harish www.harishpalaniappan.com www.floresense.com
  10. try this. $userVal = $onecats->USER_ID; echo "<option value=$userVal"; if that doesn't work, it simply means there is no value in $onecats->USER_ID.. debug that. regards, Harish www.harishpalaniappan.com www.floresense.com
×
×
  • 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.