Thanks to antville.org
php variables

It is highly recommended to increase the following limits in /etc/php.ini so that uploads through PHP will work as expected.

# php -r"phpinfo();" | grep upload
file_uploads => On => On
max_file_uploads => 20 => 20
upload_max_filesize => 2M => 2M

Restart http deamon usually using the command:
/etc/init.d/httpd restart

... Link (0 comments) ... Comment


php cookies

The global array $_COOKIE is used to retrieve the cookie value for subsequent page requests. Like...

<?php
$visits = 1;
if (isset($_COOKIE["visits"])) {
$visits = (int)$_COOKIE["visits"];
}
setcookie("visits", $visits + 1, time() + (60 * 60 * 24 * 30));
echo "You have visited this page $visits time(s).";

... Link (0 comments) ... Comment


Curling PHP

CURL can be used very effectively using PHP. Here is an example.

# cat curl.php
<?php
$ch = curl_init("http://www.google.com/");
$fp = fopen("example.txt", "w");

curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);

curl_exec($ch);
curl_close($ch);
fclose($fp);
?>

... Link (0 comments) ... Comment


Current Directory Listing

Here is the code to show the files from the current directory.

<?php
if ($handle = opendir('.')) {
while (false !== ($file = readdir($handle)))
{
if ($file != "." && $file != "..")
{
$thelist .= '<a href="'.$file.'">'.$file.'</a> <p> ';
}
}
closedir($handle);
}
?>
<P>List of files:</p>
<P><?=$thelist?></p>

... Link (0 comments) ... Comment


Upgrade PEAR

I spent a lot of time figuring out how to upgrade my PEAR package.
The trick is to install the PEAR package with –force to make it go through

# pear upgrade --force PEAR

... Link (1 comment) ... Comment


Export to Excel

Just create a regular .PHP file, where you output your data in a nice little html-table. Then place the following snippet in the top of that file:

header("Content-type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=excel.xls");

And it’s just that easy. If you open the page, you’ll see a download-window asking you where to place the file.

... Link (0 comments) ... Comment


Show only PHP errors

Open /etc/php.ini file
# vi /etc/php.ini
Set error_reporting as follows:

error_reporting = E_COMPILE_ERROR|E_ERROR|E_CORE_ERROR

Alternately, you can show all errors, except for notices and coding standards warnings

error_reporting = E_ALL & ~E_NOTICE

Save and close the file. Restart apache web server:
# /etc/init.d/httpd restart

http://tinyurl.com/8zczkk

... Link (0 comments) ... Comment


Online for 6971 days
Last modified: 9/8/21, 7:50 AM
Status
Youre not logged in ... Login
Menu
... Home
... Tags

Search
Calendar
September 2021
SunMonTueWedThuFriSat
1234
567891011
12131415161718
19202122232425
2627282930
August
Recent updates
python module itertools list of
useful methods of itertools module. permutations combinations combinations_with_replacement zip_longest count...
by shantanuo (9/8/21, 7:50 AM)
wikipedia tools 1) Collection of
useful utilities https://wikipediatools.appspot.com/ 2) all history of a user https://xtools.wmflabs.org/ec/mr.wikisource.org/Shantanuo...
by shantanuo (8/20/21, 6:36 AM)
Duration/Term of Copyright In the
case of original literary, dramatic, musical and artistic works, the...
by shantanuo (8/20/21, 6:26 AM)
Preserve seeds 6 types of
seeds to be preserved for next season. 1) laal Mula...
by shantanuo (5/7/21, 5:46 AM)
Why do I care for
Linux? I don't care that much for other software. Linux...
by shantanuo (12/17/20, 9:27 AM)
important leafy vegetables 1. Amaranthus
caudatus: rajgira. 2. Amaranthus tricolor: Math.  (Chhoti Chulai- Hindi, Cheera-...
by shantanuo (4/12/20, 2:01 PM)
program creek program creek
seems to be a good site for handy references of python...
by shantanuo (4/11/20, 11:24 AM)
Standard out to a file
This code will change the standard out to a file...
by shantanuo (4/11/20, 11:18 AM)
Create config file for AWS
command line tool While creating amazon config file in a...
by shantanuo (2/20/20, 6:00 AM)
setting colors in pandas This
is how to set the colors in pandas mapper =...
by shantanuo (2/20/20, 5:53 AM)
log mysql output tee output.txt
show global variables; show engine innodb status\G show full processlist;...
by shantanuo (2/19/20, 10:33 AM)
access AWS API gateway using
python Amazon API gateway allows us to host serverless API's...
by shantanuo (2/16/20, 9:41 AM)
Using boto In the bad
old days, the glacier class used to have different layers....
by shantanuo (2/15/20, 10:28 AM)
backup mysql users  3
steps to install percona utility... yum install perl-DBI perl-Data-Dumper perl-DBD-MySQL wget...
by shantanuo (2/13/20, 1:49 PM)
Steps to be used for
generating AWS API gateway a) Method Execution - Get Method...
by shantanuo (2/13/20, 1:30 PM)
apply colors to pandas Here
is how to change the color of negative values to...
by shantanuo (2/12/20, 8:57 AM)
Holidays in India These are
the common holidays celebrated in India (Mumbai) during 2016 -...
by shantanuo (2/11/20, 1:53 PM)
change log file size in
MySQL Here are the steps to be followed while changing...
by shantanuo (2/11/20, 10:38 AM)
MySQL common error messages 1146
Table does not exist 1054 column does not exist 1062...
by shantanuo (2/11/20, 10:13 AM)
ipython parallel demo First start
ipython in cluster mode ipcluster start -n 4 from IPython.parallel...
by shantanuo (2/9/20, 9:02 AM)
djanog settings You may see
this message if you have DEBUG = True in your...
by shantanuo (2/9/20, 4:07 AM)
clear tmp folder Here is
following commands to clear unwanted stuff from the /tmp partition...
by shantanuo (2/8/20, 2:41 PM)
change your server time to
IST If you need to change your server clock to...
by shantanuo (2/8/20, 2:39 PM)
Transfer root emails to another
email address If you have root access to the server...
by shantanuo (2/8/20, 2:32 PM)
special strings in cron Instead
of the first five fields, you can use any one...
by shantanuo (2/8/20, 2:30 PM)

RSS feed

Made with Antville
Helma Object Publisher