Setup default.ctp layout and home.ctp contents

No Comments »

The easy way:

Copy cake/libs/view/layouts/default.ctp to app/views/layouts/default.ctp and change it to suit your needs. The layout is the structure of your page contents.

Create the file app/views/pages/home.ctp (the pages directory does not exist by default, so create it first). This file will be rendered in the layout (default.ctp by default..) as the contents of your website when users visit the front page.

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

Install CakePHP TextMate bundle in E Texteditor

1 Comment »

This is a guide to manually installing the CakePHP TextMate bundle in the TextMate Windows equivalent E TextEditor.

Click to continue reading “Install CakePHP TextMate bundle in E Texteditor”

1 Star2 Stars3 Stars4 Stars5 Stars (3 votes, average: 5.00 out of 5)
Loading ... Loading ...

HTML in MySQL via PHP (also prevention of SQL injection)

1 Comment »

Usually I insert data into a MySQL database through PHP using something like


$mysql_query = "INSERT INTO table SET name = '$name', age = '$age'"

etc.

However, if I want to insert something that contains the ‘ character, I will get a MySQL error. Instead of manually handling all this stuff, PHP offers the function mysql_real_escape_string() which solves this problem. It also prevents SQL-injections, and thus it is recommended that all user-input be handled by this function before the MySQL insert is done.

An example


$mysql_query = "INSERT INTO table SET name = '". mysql_real_escape_string($name) ."'";
1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 1.00 out of 5)
Loading ... Loading ...