• About Sarwar
  • Portfolio
  • আমার বাংলা

sarwar's weblogs

~ story of web applications…..

sarwar's weblogs

Monthly Archives: December 2010

use PHP print_r function and return a string

07 Tuesday Dec 2010

Posted by Sarwar in Debug, PHP

≈ 1 Comment

Tags

debug, PHP, print_r, var_dump


print_r is one of the most useful feature of PHP, print_r prints a human-readable string representation of a variable. Sometime we need to get print_r value as sting to log or to combine the messages.

You can notice that print_r function have two argument first one is for string/array to be printed and another one use for whether it will print or return as string


#To have print_r return the data as a string, include the second argument "true":
$message = print_r($obj, true);

sometime you might be need to use var_export function instead of print_r

$msg = var_export($obj, true);

I use this several time while I debugging.

Happy Debugging 🙂

Share this:

  • Tweet
  • Email

Like this:

Like Loading...

storing array to mysql and retrieve string and use it as variable using php

07 Tuesday Dec 2010

Posted by Sarwar in PHP

≈ Leave a comment

Tags

array, PHP, serialize, store, unserialize


Sometime we need to store array to database then we need to retrieve and use as variable array. I used session variable to save data and used it later.

Its simple just use the following

#using serialize() method
$data = serialize($_SESSION);
$sql = "Insert into sessioninfo `data` values('$data')";

just run the above query and save the whole session data into a database table. You might be use any array here.

Now retrieve the data

# I assume you can retrieve the data from database and assign to the following variable
$data = unserialize($row['data']);

Now $data have the same value or nested array.

So just using serialize() and unserialize() we can do this.

Done !

Share this:

  • Tweet
  • Email

Like this:

Like Loading...

how to install whm/cpanel and change php settings and make PHP DSO

04 Saturday Dec 2010

Posted by Sarwar in Linux, PHP, WHM/cPanel

≈ 10 Comments

Tags

cPanel, PHP DSO, PHP Suexec, WHM


I used rackspace cloud to create a fresh new server with CentOS,

Login as root and used the following command

Configure the network and host
Open /etc/sysconfig/network and put HOSTNAME= your FQDN host name

[root@localhost ~]# nano /etc/sysconfig/network
HOSTNAME=server.domain.com

Update your host go to /etc/hosts

[root@localhost ~]# nano /etc/hosts

Change file to

127.0.0.1        localhost localhost.localdomain
67.12.145.20    host.domain.com  host

Now set hostname from command line

[root@localhost ~]# hostname host.domain.com

restart the network services

[root@localhost ~]# /etc/init.d/network restart

Update your server

[root@localhost ~]#  yum update

Install Perl

[root@localhost ~]#  yum install perl

Download WHM/cPanel installation files

[root@localhost ~]# wget http://layer1.cpanel.net/latest

Start cPanel installation, installation will take several hours so leave your ssh for several hours and check that your net connection is not down until installed it.
Note: when you install cPanel your ip must be authorized by cPanel, or you can registered for trial version, you can verify your ip address from http://www.cpanel.net/apps/verify/index.cgi

[root@localhost ~]# sh latest

You might me see the following message after finished the intall

cPanel Layer 2 Install Complete

Before going to web, you might get some firewall issue, so sometime you need to disable it, you maybe need to disable iptables use the following command

[root@localhost ~]# /etc/init.d/iptables stop

Web access: now you can access your cpanel from http://YOUR_IP:2026, or https://YOUR_IP:2087 and use user as root and your server root password. [YOUR_IP might me your ip or your domain address]

After login you need to give basic setup information of cPanel like network interfaces, nameserver configuration, FTP/Mail etc.

Now our target is to enable PHP DSO and add more features like GD, TTF, MbSring, IonCube etc.

You can see in software section of left navigation “Easy Apache (Apache Update)” click on it
Step 1 Profile : check previous profile and click on the Next
Step 2 Apache Version: select your required apache version and click on Next
Step 3 PHP Major Version: select your required major php version.
Step 4 PHP Minor Version: select your required minor php version.
Step 5 Short Options List: click on Exhaustive Options List and check all your require php settings

Now save your profile and build.

Build will take 40 min appropriately, wait for it. after finished the build You’ll have a popup confirmation box and you need to select DSO from dropdown. and save the configuration.

Now You have php with DSO.

I worked on it and its working with me very well. 🙂

Share this:

  • Tweet
  • Email

Like this:

Like Loading...

Author

  • Sarwar

Categories

  • .htaccess
  • Apache
  • API
  • CSS
  • Debug
  • Framework
    • CakePHP
  • HTML
  • JavaScript
    • Ajax
    • ckeditor
    • jquery
    • jQuery UI
    • tinymce
  • Joomla
    • Virtumart
  • Linux
  • MySQL
  • PHP
  • SVN
  • Twitter
  • WHM/cPanel
View Sarwar Hossain's profile on LinkedIn
Follow bdsarwar on Twitter

Tweets

  • “Running a small business without a plan is a lot like driving without directions.” — @GoldmanSachs via @appexchange    5 years ago
  • RT @TechCrunch: 5K people turn up to catch Pokémon in Chicago tcrn.ch/2aaLRys https://t.co/VVQSd7nmN4    5 years ago
  • linkedin.com/slink?code=eZ2… @ibneha, @mdthanvirahmed, @shafi_aszad, @ashrafulkauser, @digitalstatusbd, @eternolimited, @mamunha34354847    6 years ago
  • linkedin.com/slink?code=eYt… @html50, @bdwasif, @81faabfaa6f34a8, @saimonsajid, @voipworldcalls, @sarwar31945, @tomamuns    6 years ago
  • linkedin.com/slink?code=ewd… @ataharhh, @shariful51, @akhtar_h, @litetechno, @tahsin_wsit, @noormd25522880, @abmukid11    6 years ago
  • linkedin.com/slink?code=ewA… @solamanraji, @mycomplain, @washimk118_s, @audacity_it_ltd, @jibonbikash, @salimshalimm784, @mukul_politeboy    6 years ago

Flickr Photos

From Helipad ViewAbove the CloudHillNear to SkySunset Moment#sunset #beach #ocean #coxsbazar#jamroll #food #deliciousfood #homemade  #homemadefood#seaside #ocean #oceanview #travelphotography #coxsbazar #bayofbengal #travel #longestbeach#beach #lifeguard #seaside #holiday #tour #longestbeach #travel #travelphotography #coxsbazar #bayofbengal#resort #mountains
More Photos

Archives

  • February 2012 (1)
  • January 2012 (2)
  • August 2011 (1)
  • July 2011 (1)
  • June 2011 (2)
  • May 2011 (2)
  • April 2011 (1)
  • March 2011 (3)
  • December 2010 (3)
  • November 2010 (1)
  • October 2010 (4)
  • September 2010 (1)
  • June 2010 (1)
  • May 2010 (2)
  • April 2010 (1)
  • March 2010 (1)
  • January 2010 (2)
  • July 2009 (1)
  • January 2009 (1)
  • August 2008 (1)

Recent Comments

  • Kush on how to cakephp in a sub-directory, access it from root using .htaccess
  • Mr Griever on Access session data in a model -cakephp
  • apnarahimyarkhan on cakephp- CONCAT in query, Virtual Fields and make a drop down
  • Toko Kunci Pintu Murah on set & reset form text value onfocus, onblur, onclick using javascript
  • nevitaputri1.doodlekit on cakephp- CONCAT in query, Virtual Fields and make a drop down
  • RSS - Posts
  • RSS - Comments

Meta

  • Register
  • Log in
  • Entries feed
  • Comments feed
  • WordPress.com

Create a free website or blog at WordPress.com.

Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Cookie Policy
  • Follow Following
    • sarwar's weblogs
    • Join 328 other followers
    • Already have a WordPress.com account? Log in now.
    • sarwar's weblogs
    • Customize
    • Follow Following
    • Sign up
    • Log in
    • Report this content
    • View site in Reader
    • Manage subscriptions
    • Collapse this bar
%d bloggers like this: