My mistakes

Codeigniter Lost session on redirect

Posted by: pvibeesh on: April 22, 2009

Please have a try

Check the encoding of your ci_sessions database table field

change it to utf8_general_ci

TinyMCE Editor How to set the content Using javascript

Posted by: pvibeesh on: March 18, 2009

tinyMCE.activeEditor.setContent(content);

$this->load->library(“image_lib/”,$config);

for loop:

$this->image_lib->initialize($config);

end for loop

When using this library repeatedly it will initialize the image properties at once only.

It uses the existing instance for the remaining calls

To solve this problem call the initalize fucnction manually.

when someone trying to or two conditions using active record database library in codeigniter

Eg:

$this->db->from('posts');

$this->db->where('id', $id);

$this->db->like('title', $title);

$this->db->like('body', $body);
$this->db->or_like('author', $author);

You can do it like this

$this->db->from('posts');

$this->db->where('id', $id);
$this->db->where('(`title` LIKE \'%'.$title.'%\' OR `body` LIKE \'%'.$body.'%\' OR `author` LIKE \'%'.$author.'%\')', NULL, FALSE);

// Query:

// SELECT * FROM (`posts`) WHERE (`title` LIKE '%ach%' OR `text` LIKE '%ach%' OR `author` LIKE '%ach%') AND `id` = '12'


A. First make sure PostgreSQL server has been started to remote server.

# /etc/init.d/postgresql start

If it is running and you get above error, you need to add enable TCP/IP support. By default, the PostgreSQL server only allows connections to the database from the local machine or localhost. This is a security feature.

Step # 1: Allow remote IP address to access PostgreSQL

You need to open file called /var/lib/pgsql/data/pg_hba.conf. Login as postgres user using su command:
$ su - postgres
$ vi /var/lib/pgsql/data/pg_hba.conf

Now append following line. Let us say you would like to give access to 192.168.0.0/24 network:
host all all 192.168.0.0/24 trust
Please replace 192.168.0.0 and 255.255.255.0 to reflect the actual network IP address range of the clients system in your own network.

Save close the file.

Step # 2: Allow communication over TCP/IP

You need to open PostgreSQL configuration file /var/lib/pgsql/data/postgresql.conf
$ vi /var/lib/pgsql/data/postgresql.conf
Now bind and open TCP/IP port by setting tcpip_socket to true:
tcpip_socket = true

Save and close the file.

Step # 3: Restart PostgreSQL server

Restart the PostgreSQL server with the following command
# /etc/init.d/postgresql restart

This will open default port 5432.

Step # 4: Test your setup

Use psql command from client system as follows:
psql -h PostgreSQL-IP-ADDRESS -U USERNAME -d DATABASENAME

Connect to remote server by IP address 192.168.0.3 and login using testuser to connect to testdb database, use:
$ psql -h 192.168.0.3 -U testuser -d testdb
Where,

  • -h 192.168.0.3 : Specifies the host name of the machine or IP address (192.168.0.3) on which the server is running.
  • -U testuser : Connect to the database as the testuser username instead of the default. You must have account and permission to connect as testuser.
  • -d testdb : Specifies the name of the database (testdb) to connect to.

When your are trying to connect a remote pgsql db on a Suse Linux 9 or others, It did not have the tcpip_socket parameter in postgresql.conf

To overcome this, I had to uncomment the following settings:

#—————————————————————————
# CONNECTIONS AND AUTHENTICATION
#—————————————————————————

# – Connection Settings -

listen_addresses = ‘*’
port = 5432

15 Tips For a Better Linux Experience

Posted by: pvibeesh on: October 15, 2008

http://www.linuxhaxor.net/2008/10/14/15-tips-for-a-better-linux-experience/

Linux Recovering data from damaged media

Posted by: pvibeesh on: October 15, 2008

Recovering data from damaged media can be handled by several Linux tools including some LiveCD, specifically built to help recover data. Parted Magic, Ubuntu Rescue Remix, SystemRescueCd, Foremost (data recovery), Ddrescue.

Accessing linux filesystem from windows

Posted by: pvibeesh on: October 15, 2008

If you dual boot with windows, accessing Linux file system from your windows installation might be important for you. There are three windows applications that can help you do this: Explore2fs, Ext2 Installable File System, DiskInternals Linux Reader.

Rounded edges using DIV tag

Posted by: pvibeesh on: September 4, 2008

Style

div.block div.block-header-l {
height:23px;
width:7px;
float:left;
position:absolute;
background:url(“images/block-header_bg-l.png”);
background-position:0pt;
background-repeat:no-repeat;
}
div.block div.block-header-r {
overflow:hidden;
padding-left:8px;
height:23px;
font-family: Tahoma,Helvetica,Arial Narrow;
background:url(“images/right.png”) no-repeat 100% 0pt;
font-weight:bold;
line-height:1.9em;
color: #02576b;
}
HTML
<div style=”margin:0pt;”>
<div class=”block-header-l”>&nbsp;</div>
<div class=”block-header-r”>    <?php print $block->subject ?> </div>
</div>

popup dialog creation using html DIV

Posted by: pvibeesh on: August 7, 2008

Images not attached

<html>
<head>
<style>
div#popup_dialog {
width:400px;
background-color:white;
}
div.top-left {
float:left;
background-image:url(“header_left.png”);
width:350px;
background-repeat:no-repeat;
}
div.top-right {
float:left;
background-image:url(“header_right.png”);
background-repeat:no-repeat;
width:50px;
clear:right;
}

div.footer-left {
float:left;
background-image:url(“footer_left.png”);
width:350px;
background-repeat:no-repeat;
}
div.footer-right {
float:left;
background-image:url(“footer_right.png”);
background-repeat:no-repeat;
width:50px;
}

div.dialog-content{
border-right:1px solid #88b187;
border-left:1px solid #88b187;
padding-left:4px;
padding-right:4px;
margin-top:-2px;
}

div.dialog-content span.content{
padding-left:4px;
padding-right:4px;
}

li {
padding-top:10px;
}

h1{
margin-top:-2px;
margin-bottom:0px;
}
div#popup_dialog span.title{
float:left;
}
div#popup_dialog span.date{
float:right;
}

</style>
<script>
function getPos(elem) {
var curleft = curtop = 0;
if (elem.offsetParent) {
do {
curleft += elem.offsetLeft;
curtop += elem.offsetTop;
} while (elem = elem.offsetParent);
return {x:curleft,y:curtop};
}
}
function getLeft(elem){
var x=0;
if (elem.calcLeft)
return elem.calcLeft;
var oElem=elem;
while(elem){
if ((elem.style)&& (!isNaN(parseInt(elem.style.borderLeftWidth)))&&(x!=0))
x+=parseInt(elem.style.borderLeftWidth);
x+=elem.offsetLeft;
elem=elem.offsetParent;
}
oElem.calcLeft=x;
return x;
}

function getTop(elem){
var x=0;
if (elem.calcTop)
return elem.calcTop;
var oElem=elem;
while(elem){
if ((elem.style)&& (!isNaN(parseInt(elem.style.borderTopWidth)))&&(x!=0))
x+=parseInt(elem.style.borderTopWidth);
x+=elem.offsetTop;
elem=elem.offsetParent;
}
oElem.calcTop=x;
return x;

}
function showpopup(id){
var left = getLeft(id) – 10;
var top = getTop(id) + 25;
var mainDiv = document.getElementById(‘popup_dialog’);
mainDiv.style.display = ‘block’;
mainDiv.style.position = ‘absolute’;
mainDiv.style.top = top+’px’;
mainDiv.style.left = left+’px’;
mainDiv.style.zIndex = 100;
}

function closeWindow() {
var mainDiv = document.getElementById(‘popup_dialog’);
mainDiv.style.display = “none”;
}
</script>
</head>
<body>
<ul>
<li><a id=”one” onmouseout=”closeWindow()” onmouseover=”showpopup(this)” href=”#”>One</a>
<li><a id=”two” onmouseout=”closeWindow()” onmouseover=”showpopup(this)” href=”#”>Two</a>
</ul>

<div style=”display:block;” id=”popup_dialog”>
<div class=”top-left”>&nbsp;</div>
<div class=”top-right”>&nbsp;</div>
<div style=”clear:both;”></div>
<div class=”dialog-content”>
<span class=”title”>
<p>Hai</p>
</span>
<span class=”date”>
<p>May 28th, 9PM</p>
</span>
<span class=”content”>
<p>
Yes, offsetLeft was an IE property first. However since it is now in
use by other browsers, particularly Safari as concerns Dashboard
development, it is valid to use it. XmlHttpRequest was an IE property
as well but that hasn’t stopped its adoption.
</p>
</span>
</div>
<div class=”footer-left”>&nbsp;</div>
<div class=”footer-right”>&nbsp;</div>
</div>
</body>
</html>