If a page contains only PHP code, best practice is to omit the PHP end tag ( ?> ). PHP does not require the end tag on PHP only pages. Including the end tag can cause unwanted injection of trailing white spaces which can cause header already sent errors.
Creating a simple form and custom validation rules in CakePHP 1.2
Note: In CakePHP 1.2, form related methods have been deprecated from the HtmlHelper and moved to the new FormHelper. Now we have to use FormHelper instead of HtmlHelper. Also the tagErrorMsg is removed in the current version. Our Controller Class:For validating the given input, we need to write this in our controller function: class PagesController… Continue reading Creating a simple form and custom validation rules in CakePHP 1.2
Turn off phpBB cache
While creating phpBB templates or during development it can be really irritating to delete the contents of the cache folder repeatedly after each change. For that it is better to ask phpBB to recompile the updates. For that follow these steps – 1. From admin panel choose the “General” tab2. Choose “Load settings” from the… Continue reading Turn off phpBB cache
Dynamic conditions in PHP
The below example demonstrates how we can check dynamic conditions in PHP. $var1 = 11; $var2 = 110; $cond1 = ‘$var1 > $var2’; $cond2 = ‘$var1 < $var2'; if(eval("return $cond1;")){ echo $cond1; } if(eval("return $cond2;")){ echo $cond2; }
Get option text using Javascript
The HTML select is below Select Language PHP JSP C# And now the JavaScript
Using jQuery and Prototype together
Yes. You can use jQuery and Prototype together in the same page. I have been using jQuery and Prototype for quite some time now. But have always used them on different projects knowing for sure that if not anything else, their ‘$’ would clash. However I found out a solution. By default the ‘$’ in… Continue reading Using jQuery and Prototype together
Recursive Function to output Category / Sub-category Breadcrumb
/// Recursive function to output the breadcrumb function breadcrumb($id,$layer=0,$out=”){ /// If id = 0 outputs that it is Root Category. No need to go any further. if($id ==0){ return “Root Category”; } /// if id > 0 fetches the details of the category first $crumbsql = mysql_query(“Select * From category Where cat_id = ‘”.$id.”‘ “);… Continue reading Recursive Function to output Category / Sub-category Breadcrumb
MySQL single and double quotes insertion
More than often while inserting some description into MySQL from a form input one faces a ‘single and double quote’ problem. For example while inserting the following text – I have both ‘ and ” quotes in my description To make the text safe for a MySQL insertion parse it with mysql_real_escape_string() That would make… Continue reading MySQL single and double quotes insertion