If you are looking for any other specific book of php and mysql contact me!
Author Archives: om
How to delete a folder with PHP?
To delete a file, or a folder and its contents i have compiled a recursive algorithm.
Hope this will be useful for all of you.
read()) {
// Skip pointers
if ($entry == '.' || $entry == '..') {
continue;
}
// Recurse
rmdirr($dirname . DIRECTORY_SEPARATOR . $entry);
}
// Clean up
$dir->close();
return rmdir($dirname);
}
?>
How to Stop SQL Injection in MYSQL?
How to Redirect with PHP?
How to display certain number of words from a record?
I got good php tutorial to display certain number of words from database; in place of Database record you can use any other regular string.
300) {
$ext = "... read more";
} else {
$ext = "";
}
function elliStr($s,$n) {
for ( $x = 0; $x < strlen($s); $x++ ) {
$o = ($n+$x >= strlen($s)? $s : ($s{$n+$x} == " "?
substr($s,0,$n+$x) . "..." : ""));
if ( $o!= "" ) { return $o; }
}
}
echo (elliStr("$text", 300)) . $ext;
?>
How to remove HTML Tags from string?
How to display limited characters?
How to display random record with PHP AND MYSQL?
How to collect Checkbox Array values?
Beginner PHP Programmer always searches for easy way to collect Checkbox data from forms.
Here in this post I have used 3-4 lines of easy code to collect data from multi checkboxes. Instead of using several table-fields you can store your comma separated data in on field of the table. This is easy and handy.
How to Install PECL Library in shared server?
Most of us don’t have installation access in all LAMP based shared server.
In this Open source world you never know which function and which code you have to use.
Recently I have encountered one php function which was really important for me to post something from one server to another.
That was http_post_fields() which is available in pecl_http php extension.
pecl_http php extension is used to provide a convenient and powerful set of functionality for most of PHP’s applications, like HTTP urls, dates, redirects, headers and messages etc.
After spending so many hours I figured out how to install and make it work.
I would be happy if you can utilize my hard work and install your own without any paid help!
These are the Steps
1. Download directly in you server for example html folder or wherever you want to install.
wget http://pecl.php.net/get/pecl_http-1.6.1.tgz
2. Uncompress the files using following commands
tar –xzvf pecl_http-1.6.1.tgz
cd pecl_http-*
Note : If there is one more directory after untar please remove that.
3. Compile and install using these commands (Just run one after another)
A. phpize
B. ./configure
C. make
D. make install
4. After completing step 3 add following line in your PHP.INI file.
Now a day’s giving php.ini access is fashion!
extension=http.so
5. Add newly installed pecl_http php extension to php.ini file. Its important to add correct path, if you are installing from root this step is not required.
extension_dir=/home/this_is_your_server_path/html/pecl_http-1.6.1/modules
Thats it!