CakePHP: Caching and issues related to it

There may be occasions that the programs that you develop in your development environment does not fetch the desired results when the programs are moved to the production environment.

The possible cause of this problem may be due to active caching in cakePHP which tends to bring in copies of text from older program revisions.
Continue Reading…


Configuring CakePHP in localhost

Quick and easy steps

Grab a copy of cakePHP from website

You can either create the new cakephp website in the root (http://localhost/) or by adding it as a subfolder (http://localhost/mycakesite/)

If you create it as a subfolder, then configure the appropriate path settings for linking images in the web pages.
Continue Reading…


PHP Parse error unexpected T_STRING

Sample error message that you may have come across when designing php pages …

Parse error: syntax error, unexpected T_STRING in C:\wampserv\www\my_program.php on line 4

Check your program to see if there is a missing semi-colon at the end of line 3. Php need the character “;” at the end of the statements to indicate the end of php command.


PHP: Buffer Overflow

PHP Program Flow
A call that is made to execute a sequence of code in PHP program is sent to PHP core library written in C programming language which in turn would talk with the underlying operating system to get the results of its execution.

What is buffer?
A buffer is a temporary memory location to hold data for faster program execution time. The data may be stored as a heap or as a stack. Stack can be visualized as a FILO array of data and heap as a linked list of data.

Why we need to take care of buffer overflows?
Programmers who know about certain loop holes can exploit this feature in by pointing a record in the heap or stack to prewritten block of hackable code. These are called buffer overflow attacks.
Continue Reading…


Cross site scripting Attack – XSS

Cross-Site Scripting (XSS) is the method of code injection whereby a malicious user injects code (html, javascript) which would get executed from the site on the users browser. When Google finds this, it will show up a warning message in its search results if the users had searched for a specific term for which your site is indexed. This can harm your user base.

XSS attacks are classified as
Persistent attacks
Non-persistent attacks
Continue Reading…


cakePHP: Static page handling tips

You can create static pages in cakePHP by adding .ctp files under /app/views/pages folder and can access it using the URI http://sitename/pages/pagename.ctp.

Try creating two files page1.ctp and page2.ctp and add those files under /app/views/pages folder.


<h1>Page 1</h1>
<p>Static Content for page 1 goes here</p>


<h1>Page 1</h1>
<p>Static Content for page 1 goes here</p>

Continue Reading…


cakePHP: Session enabled messages using Session->setFlash

There are different ways to flash or publish the messages for a user action. Usability plays a major role in determining how the navigation pattern for a web application takes place.

  • publishing the outcome of user action on the same page
  • designing a single page to flash all success, error, warning, notice level messages
  • designing a separate page for each message that gets published for the user

Continue Reading…


Strange character sequence when parsing XML

When XML files are read from RSS feeds or from other sources, it is necessary that they both use the same standard encoding. When there is a conflict, strange characters like ‘, ’ gets shown on the browsers.

In RSS feeds, UTF-8 is the standard encoding scheme that is used and if a browser using ISO-8859-1 tries to read and display the data from the feed then these characters get passed on to the display.

To avoid having this strange characters displyed on screen (where ISO-8859-1 encoding is used), PHP’s iconv function comes in handy and you can use it like

echo iconv(“UTF-8″,”ISO-8859-1//TRANSLIT”, $temp_item[‘encoded’]);

and this will remove those characters and replace it with the nearest possible character during its tranliteration.


CakePHP: Parsing RSS feed in Simple Steps

How to read RSS feeds (XML file) and display contents in CakePHP?

Parsing an XML feed can be done in simple steps as follows in CakePHP …

CakePHP Controller: /app/controllers/rss_controller.php

*	CakePHP Controller to parse XML file
class RssController extends AppController{
	var $name = "Rss";
	// As the RSS will not currently use a database
	var $uses = array();
	var $feed_url = "";
	var $rss_item = array();
	function index(){
		$parsed_xml =& new XML($this->feed_url);
		// xml to array conversion
		$this->rss_item = $parsed_xml->toArray();
		$this->set('data', $this->rss_item['Rss']['Channel']['Item']);

CakePHP View: /app/views/rss/index.ctp


CakePHP: Beginners installation hurdles – Errors and Solutions

I thought to mention a few errors beginners into CakePHP might come across when configuring CakePHP and how to resolve

Notice: this error is being rendered by the app/views/errors/missing_table.thtml view file, a user-customizable error page.

This error occurs when the database is not configured in cakePhp. First create a database in MySQL or the database of your choice. Go to /app/config/ and make a copy of database.php.default and rename it to database.php. Open database.php and give the necessary settings of the new database created with the associated login credentials. Once that is done, refresh the page and see if that error is now resolved.
Continue Reading…

Kurinchi Calendar
September 2018
« Oct