If a string contains a single quote, it will generate an error. mysqli->real_escape_string() escapes quotes for MySQL. See example:
Suppose you have three fields (Title, field_city, field_country) to display in your view. By default they will display in three separate lines as follows:
Benjamin Franklin Philadelphia USA
To display this information in a single line, you need to edit the third field. Expand Rewrite Results, then type in the following:
[Title], [field_city], [field_country]
This will result in the following:
Benjamin Franklin, Philadelphia, USA
Drupal can be very memory intensive CMS, especially if you have lots of menus, blocks and modules. If you exhaust the allowed memory size, you would get an error such as the following
Fatal error: Allowed memory size of 16777216 bytes exhausted (tried to allocate 41 bytes) in somefile
To fix this problem, you need to allocate more memory.
1. Open you php.ini file If you don't know where this file is, run locate php.ini. Mine is located at /etc/php.ini. Make sure you back up this file before editing it.
On development systems it is common practice to have different log file to log PHP error logs for different tools and different versions of the same tool. Generally it is a good idea to use meaningful names to make it easy to distinguish between the log files. If you have doubts, you can either look inside the code to see which error log file is being called or do the following:
$ cd ~ $ ls -al /var/log/httpd before.diff
Run the tool such that it would write something to the log file. Then
When you use a foreach loop, PHP creates a copy of the current element you are using in your loop. Any changes you make to this element is not saved to the original array. See the first part of the following example:
strtotime() function can be used for date arithmetic. Following are some examples:
Get next date
print date('Y-m-d', strtotime('+1 day', strtotime('2013-09-30')));
Get previous month
print date('Y-m-d', strtotime('-1 month', strtotime('2013-09-30')));
Go back 5 years
print date('Y-m-d', strtotime('-5 year', strtotime('2013-09-30')));
Laravel is a free and open-source PHP web framework like CodeIgniter and Zend. It is built on the Model-View-Controller (MVC) architectural pattern. It has very good documentation and training material. The community is also significant enough. I find it to be much easier than Zend and about as easy to use as CodeIgniter. Better training material and documentation makes Laravel easier for beginner than CodeIgniter.
MongoDB is document based NoSQL database. This means that:
- it has no schema
- it has no relations
- it is agile and scaleable
- stores information in nested documents of two-dimensional key/value pairs.
What are the benefits of using MongoDB?
- you do not have to pre-define your schema or data model
- ideal for client-side applications
Installing MongoDB on Mac with Homebrew
Following is what we will be creating. A view that will create a page with a list of nodes (titles + teasers) and a block (with node titles only) of all nodes tagged by a taxonomy term.
Assumption: - You have multiple nodes tagged with term "PHP" - The nodes are of type Article
Go to Structure > Views > Add a new view and fill in the form as follows:
View name: PHP Show Content of type Article tagged with PHP sorted by Newest first check Create a page check Create a block Save & Exit
Then go to Structure > Blocks to enable the block.
PHP does not support explicit type definition in variable declaration. For example, you CANNOT declare a variable as follows:
int $count = 10;
In PHP, a variable's type is determined by the context in which the variable is used.