PHP
PHP scripts for converting InnoDB to MyISAM database engine
This PHP CODE snippets will change your database engine from InnoDB to MyISAM, this is useful when you need to save time manually changing all the tables from InnoDB to MyISAM, for example when a CMS populates a database with tables that use InnoDB but you cannot run on your web host because InnoDB is disabled and MyISAM is your remaining options.
Commonly on a shared hosting environments, web host disabled InnoDB because it requires more disk space and eats more Server resources and Memory than MyISAM. To use this scripts you need to change the variables:
$dbServer // Database server, commonly use value is localhost
$dbUser // Database User, the one with priveleges to your database
$dbPass // Password of the Database User
$dbName // The database you want to convert from InnoDB to MyISAM
- Danreb's blog
- Login to post comments
How to increase the Maximum File Upload size in Drupal 7
While working with one of my Drupal 7 website project, I encountered a problem about the PHP "Maximum Upload File Size" limit set in the hosting provider. One feature that I need to implement to the site was to be able to upload a video file with the format (mp4, mov, flv, m4v, mpg, mpeg, ogg, ogv, mp3, oga). I am able to accomplish the video upload feature by creating a CCK file field that accepts uploading of video files limited to those file extension. I use the Mediafront module for Drupal 7 to play the uploaded file in the node.
The problem was the uploading of video files was limited to accept up to 8 MB and the limit was set in PHP.INI file, php.ini is a configuration file of PHP server installed in the host. Because the site is hosted in a shared server, I do not have an access to this configuration file and I can not adjust the settings easily. The website needs to upload at least up to 60 MB of video file size.
Looking for a solution and documentation on Drupal.org website on "How to increase the maximum file size upload" limit doesn't work in my situation. After searching for an hour for a solution and reading through all the recommendation Google search gave to me, I've found the one that works in my hosting provider, so here I decide to post and document it here in my blog. Please note that this may or may not work in some server because of various configuration setup but if nothing works for you, you can try this also and maybe we have on the same server hosting.
Here's what I've done
- First I've created an empty php.ini file and drop it where I've installed Drupal, im my case it is in the directory "home/user/public_html/dev" as I first develop the site in a sub domain and then migrate it to the main domain when it is ready. The exact location of my newly created blank php.ini after I drop it to my development site was "home/user/public_html/dev/php.ini" and I can access my dev site through this similar URL : http://dev.example.com.
- The second things I've done was to visit the URL of my dev site, and it gives me an error saying this "Fatal error: Class 'PDO' not found in /home/user/public_html/dev/includes/database/database.inc on line 185". Seeing this error means that the server is already reading the empty php.ini and because I put my own configuration file in this Drupal installation, this seems that its override or dis regard some settings in original php.ini and PHP does not load some additional extension that is set in there, for this example it is the PDO extension.
-
To be able for me to fix that PDO error I added this into my empty php.ini
extension=pdo.so
extension=pdo_sqlite.so
extension=sqlite.so
extension=pdo_mysql.so -
After fixing the PDO problem I added the actual configuration code for the file upload which is :
post_max_size = 160M
upload_max_filesize = 80M
magic_quotes_gpc = offThis settings will increase my upload file size up to 80 Megabytes, that's cool!
- Done
-
Here's the screenshot of the node editing forms

- Danreb's blog
- Login to post comments
Index Loop
A loop that executes when the number of iteration is explicit in the problem. The printing of numbers 1 to 10 is an example of this type of loop.
Learning Example:
Problem: Print the first five even numbers.
Analysis:
We know that the first five even numbers are the numbers 2, 6, 4, 8, 10. The problem simply says that we need to print these even numbers. If we look closer to the numbers, we will notice that there is a step of 2 from every other number. To take this step in the program, the counter function should use 2 as incrementing step to produce the even numbers.

The solution shown is the same solution in printing the numbers 1 to 10 or 1 to 1000. The things new in this solution are the incrementing step used, and the condition set to terminate the loop.
The terminating condition not only checks if the curent value is less than 10 but also cheks if they are the same. The flowchart terminates, if the current value of ctr greater than 10.
Note that the incrementing step set in the counter function is not limited to 1. The counter step differs as the problem calls for it.
- Danreb's blog
- Login to post comments
- Read more
Infinite Loop
A loop that runs without end. It is due to mistakes in the logical operation or expression or variables used to control the termination of the loop. Others call this logical error. Often this type of error is the hardest type of error to debug.
Learning Example : Print the first 10 counting numbers
Analysis :
We know that the solution is simply to print numbers 1 to 10. If we made use of wrong variables and or logical expression, then we might end up in having infinite loop.
The following flow chart is a classic example of infinite loop that should be avoided.
Take note of what happened if the programmer accidentally initialized variable to 0 instead of 10.
Worst if the comparison used in the decision symbol to terminate the loop in satisfying the problem is also illogical ( wrong logical operations > instead of <, etc ). This will lead to infinite loops and can give us headache in identifying the problem. Simulation is the best way to debug this error.
- Danreb's blog
- Login to post comments
Fundamentals of Looping
Iteration - The repetition of the loop. When the given problem says that we have to print the numbers 1 to 10, this would mean that we will need a repetition of instruction PRINT 10 times. The number of repetitions the
loop has taken to perform to satisfy the problem is the number of iterations.
Accumulator - A temporary storage location in a central processing unit that holds values during a process. Using the problem given in the iteration example, instead of printing the numbers 1 to 10, the problems looks at printing the sum of the numbers. Illustrating the problem we have,
Numbers given : 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
Sum of the numbers : 1+2+3+4+5+6+7+8+9+10 = 55
This mean that we will ADD the numbers 10 times, at the same time there will be 10 iterations that will happen, but instead of printing the number as it increases from 1 to 10, we should take this increasing numbers, add them and store them in a temporary variable to hold the current sum value until we completed the 10 iterations.
The variable that temporarily holds this increasing value for sum is the accumulator. Take note that accumulator is used not only for addition but for multiplications and other mathematical applications as well.
- Danreb's blog
- Login to post comments
DANREB.COM 