Archive

Archive for the ‘PHP’ Category

How To enable mod_rewrite on Xampp

August 18th, 2010 R Arun Raj No comments

Search For httpd.conf file and uncomment this line

#LoadModule rewrite_module modules/mod_rewrite.so

LoadModule rewrite_module modules/mod_rewrite.so

Restart your Server

create a .htaccess file on your server root

put this code

RewriteEngine On
RewriteBase /
RewriteRule ^contact-us$ index.php

Categories: PHP, Programming Tags: , , ,

Creating XML-RSS Feed Using PHP MYSQL

June 11th, 2010 R Arun Raj No comments

I have been working to create crowler friendly rss feed for our website. I think it is very easy to build . But when i started coding it i got so many problems with xml and special charcters. I tried program for replacing special characters. But it wont work. Finally i used utf8_encode. It worked

$h=utf8_encode(clean_url($result['name']));
$d=utf8_encode(clean_url($result['discription']));

I have attached PHP Source code for XML Generator

feed.php

Right click on the above link and save target as …

Below function is used to clean all extra characters in the content.

function clean_url($text)
{
$text=strtolower($text);
$code_entities_match = array(‘>>’,'–’,'�’,'–’,'&’,'“’,'”’,'–’,'’’,'-’,'–’,'”‘,’!',’@',’#',’$',’%',’^',’&’,'*’,'(‘,’)',’_',’+',’{‘,’}',’|',’:',’”‘,’< ‘,’>’,'?’,’[',']‘,’\\’,';’,”‘”,’,',’.',’/',’*',’+',’~',’`',’=',’-',’ï’,'–’,”‘”,’O');

return str_replace($code_entities_match,”, $text);
}

To make an rss feed you need title, description and link

Sample RSS FEED format

<rss version=”0.91″>
  <channel>
    <title>XML.com</title>
    <link>http://www.xml.com/</link>
    <description>XML.com features a rich mix of information and services for the XML community.</description>
    <language>en-us</language>
       <item>
            <title>Normalizing XML, Part 2</title>
            <link>http://www.xml.com/pub/a/2002/12/04/normalizing.html</link>
             <description>In this second and final look at applying relational normalization techniques to W3C XML Schema data modeling, Will Provost discusses when not to normalize, the scope of uniqueness and the fourth and fifth normal forms.</description>
       </item>

    <item>
      <title>SVG’s Past and Promising Future</title>
          <link>http://www.xml.com/pub/a/2002/12/04/svg.html</link>
           <description>In this month’s SVG column, Antoine Quint looks back at SVG’s journey through 2002 and looks forward to 2003.</description>
    </item>
  </channel>
</rss>

also go through the source code attached

How to configure cURL in xampp server

May 25th, 2010 anoopsankar No comments

xampp server with default configuration can’nt run curl_init();

to make it work in xampp server we have to edit three files namely

1. php.ini(which is a configuration stting file).

2. php.ini-recommended(INI-DIST file)

3. php.ini-dist(INI-RECOMMENDED file)

open these files in notepad and search for ‘curl’ and remove ‘;’ symbol, save and close the files.

Remember to restart your server before running the application.

Symfony Study Guide – Small Project Implementation

May 15th, 2010 R Arun Raj No comments

Download Symfony Sandbox 1.4

Source : www.symfony-project.org/installation
Requirement : Xampp or Wamp Package
PHP: 5.2 Above

Download Symfony and put this into your website root

Rename sf_sandbox to your project name. Here it is CRM

open config/properties.yml file and put below details

[symfony]
name=CRM
author=Arun Raj R
orm=Doctrine

Read more…

Symfony 1.4 Doctrine Pagination

May 14th, 2010 R Arun Raj No comments

Doctrine Pagination is made very simple .

public function executeIndex(sfWebRequest $request)
  {
    $this->pager = new sfDoctrinePager('TableName', sfConfig::get('app_max_jobs_on_homepage');
    $this->pager->setQuery(Doctrine::getTable('TableName')->createQuery('a'));
    $this->pager->setPage($request->getParameter('page', 1));
    $this->pager->init();
 }

Success page

<?php foreach ($pager->getResults() as $post): ?><div>
<?php if($post->getTitle()) { echo link_to($post->getTitle(), ‘news/fullstory?expand=’.$post->getId(),’class=”mhead”‘); } ?>
<?php if($post->getDn2()!=”) { echo image_tag($post->getDn2()); } ?>
<?php $content=$post->getContent();
$stripcontent=substr($content,” “,700);
echo $stripcontent;
?>
<div style=”display:block;” > <?php echo $post->getCreatedAt(); ?><?php echo link_to(“Full Story”, ‘news/fullstory?expand=’.$post->getId(),’class=”fullstory”‘) ?> <br /><br />
</div></div>
<?php endforeach ?>

pagination

<?php if ($pager->haveToPaginate())  { ?>

<div id=”navv”>

<?php echo link_to(‘Latest’, ‘news/index?page=’.$pager->getFirstPage(),’class=”pager”‘) ?>
<?php echo link_to(‘prev’, ‘news/index?page=’.$pager->getPreviousPage(),’class=”pager”‘ ) ?>
<?php $links = $pager->getLinks(); foreach ($links as $page): ?>
<?php echo ($page == $pager->getPage()) ? $page : link_to($page, ‘news/index?page=’.$page,’class=”pager”‘) ;?>
<?php if ($page != $pager->getCurrentMaxLink()): ?> <?php endif ?>
<?php endforeach ?>
<?php echo link_to(‘next’, ‘news/index?page=’.$pager->getNextPage(),’class=”pager”‘) ?>
<?php echo link_to(‘Oldest’, ‘news/index?page=’.$pager->getLastPage(),’class=”pager”‘) ?>
<?php } ?></div>

PHP MYSQL Tips and Tricks

September 17th, 2009 R Arun Raj No comments

This is a small article containing tricks and tips I aquired by reading PHP 6 Text Book.

I was used isset() function to check whether these arguements are set or not. And also I need to check this is empty or not.

Here is another function to check both of this requirement at single line.

empty()

It checks if a variable has an empty value: an empty string, 0, NULL,or FALSE.

Example

if ( !empty($_POST[‘name’]) && !empty($_POST[‘comments’]) && !empty($_POST[‘email’]) ) {

echo “Yes”;

}

Categories: PHP, Programming Tags: , , ,

PHP 6 upgrade : Advantages covered

September 14th, 2009 R Arun Raj No comments

PHP Personal Home Page now it is Hypertext Pre Processor.

Version : 6 (PHP 6)

Advantages,

  • Addition of improved MySql Extension
  • PHP 6 support Unicode, so that PHP 6 can handle all languages in the world. I faced lot of problems with ‘Malayalam’ font integration.
  • PHP 6 cleans up a lot of garbbages that was left in php 5
  • The two biggest removals are the “Magic Quotes” and “register globals” features

Download and Test PHP 6 at http://snaps.php.net/

What is magic Quotes ?

It automatically escapes single quotes or double quotes in form data by inserting a “\” Back slash in front of it. Now this automatic feature called magic Quotes has been removed  in PHP6.

Categories: Mysql, PHP, Programming Tags:

Image Resize Simple class

September 11th, 2009 R Arun Raj No comments

Here is a sample class file for image resize.image-resize-class

imageResize.class

Download the File  save it in web root and add .php extension to the file  .

How to use ?

<?php

require_once(‘imageResize.class.php’); // Path to File

imagejpeg(imageResize::Resize($fileSavePath,$width,$height),$newFileName);

?>

$fileSavePath should be the pathname of source file. Say “uploads/arun.jpg”.

$newFileName this should be the source File name with path.  Say “uploads/thumb/arun.jpg”.

Any Doubt ?

Categories: PHP Tags: , , ,

Videos, Slideshows and Podcasts by Cincopa Wordpress Plugin