1. Click on the database (from list of databases on the phpMyAdmin home screen) in which you want to rename table name.
2. You will see a list of tables on click of the database.
3. Select the table and there is a dropdown below the tables with Read more…
PDO stands for PHP Data Objects. PDO is a consistent way to access databases.
Today, mostly websites or desktop based applications store their data in databases. Therefore, PHP has also provided the way to connect with databases.
PHP supports following ways to connect to the database:
1. Mysql Read more…
In Moodle when we create a new course we have an option to add summary/description of course. We can use this summary anywhere while showing courses. This summary could be anything. It can be simple text, image, multimedia or hyperlinks.
Hyperlinks are 2 forms:
Hyperlink launches a Read more…
We can send ical attachment in email using attach ical file (filename with .ics file extension).
For example, following is the object containing the information about ical like event start date and time, location, event summary etc:
$ical_content = “BEGIN:VCALENDAR
PRODID://Drupal iCal API//EN
BEGIN:VEVENT Read more…
FPDF (To generate PDF files)
Using PHP we can generate PDF files dynamically. FPDF is a free PHP class that contains a number of PHP functions with the help of which we can create and manipulate PDFs. To get started with FPDF, we just need to download FPDF library from Read more…
Whenever the situation occurs to rerender the page contents without reloading the whole page, we use ajax in it. By using ajax we get the response data back in the success function which we will show on the screen. Let’s have a look:
In the above screenshot Read more…
When we pass a floating point value to a variable, then the value which we store in the variable is not the actual value but it is something approximately near to that number which transfers to that variable.
Let us understand this by a PHP example:
<?php Read more…
In Cakephp, console applications are useful in running background processes and can be run without access to web browser. The CakePHP console provides a framework for creating shell scripts.To run the cakephp functions, first of all create a shell to use in console.
For example, create a TestShell in Read more…
Error: Call to undefined function mcrypt_encrypt()
Description: In one of our project, I was trying to save a field value in encrypted format in the database, using PHP, which could be retrieved back to its normal value, where we need to display it.
So for that Read more…
If we follow cakephp rules to create a form then we can use cakephp inbuilt functionality like we don’t need to assign labels to form fields. Cakephp automatically creates a label for each form field also in case of update/insert validation error messages, the message is automatically shown Read more…
While working on two servers, we can take the backup of database on one server using mysqldump command in php.
exec(‘mysqldump –host ‘.$dbhost.’ –user ‘.$dbuser.’ –password=’.$dbpass.” “. $dbname.’ > ‘.$dbname.’.sql’);
After creating dump of database, user can move the dump database file from one server to another Read more…
Scaffolding in CakePHP
Application scaffolding in CakePHP is a technique that allows the developer to define and create a basic application that can create, retrieve, update and delete objects. Basically CRUD (create, Read, Update, Delete) data operations are common in most of the applications.
Scaffolding basically provides temporary structure or Read more…
How to specify an extra field (not existing in the table) while fetching data from database using find method? Solution is explained below.
Assign value to virtual field before find function call:
$this->virtualFields[‘virtual_field_name’] = ‘any value’;
Use virtual field in find function:
$result = $this – > find(‘all’,
‘fields’ => array Read more…
By default, each cURL request can access only SSL certified websites. However, at times it is required to access those sites which are self-signed. To verify that your cURL request is able to access self-signed websites or not, use below command:
curl <URL of the domain to Read more…
Suppose you want to design a custom scheduler in wordpress plugin instead of using wordpress scheduler which has fixed values of recurrence which are ‘hourly’, ‘twicedaily’,’daily’. And if you want to make the scheduler dynamic instead of making it static i.e. instead of setting the fixed scheduler value Read more…
Problem: After the first space in the string no data appears in the input field.
There is an issue when a string contains words with spaces and we want to display the whole string in an input field but after the first space, no data is displayed in Read more…
Merge Tags in gravity forms are the tags that are used to dynamically populate the field values in the form content in gravity forms like IP address, browser name, logged in user name etc . There are many merge tags available in the gravity forms by default.
But sometimes there may Read more…
Suppose the URL contains query string for example www.mywebsite.com/sme_page?q=12
then the value of query variable can be retrieved in PHP using the get method such as:
While creating a plugin for WordPress, to retrieve a value of query variables Read more…
Requirement: While running the website in browser, the url path shows controller name followed by the action name and parameters list. In that case the url looks like:
We may come across two types of requirements.
Displaying only the action name without showing Read more…
Problem: I installed sendmail in my ubuntu system with the help of link http://lukepeters.me/blog/getting-the-php-mail-function-to-work-on-ubuntu. I installed it to test php mail functionality on localhost for my project. It was working slow, therefore, after testing, I wanted Read more…