ANIL KUMAR PANIGRAHI 's Blog

Posts Tagged ‘PHP Code

How to create rss feeds using php and mysql

Posted by: Anil Kumar Panigrahi in: ● July 2, 2010

Hi friends,
In this post i want to explain how to create rss feeds using php code and get the data from mysql table.
1) Connect to database:
We already discussed about how to connect database using php code.See the following code to connect database:

1
2
3
4
5
6
7
8
9
10
11
 
<?php
DEFINE (’DB_USER’, ‘root’);
DEFINE (’DB_PASSWORD’, ‘root’);
DEFINE (’DB_HOST’, ‘localhost’);
DEFINE (’DB_NAME’, ‘rss’);
 
// Make the connnection and then [...]

Thumbnail image creation using php code

Posted by: Anil Kumar Panigrahi in: ● June 3, 2010

In this post explains how to create thumbnail image using php code.
function make_thumb($img_name,$filename,$new_w,$new_h)
{
//get image extension.
$ext=getExtension($img_name);
//creates the new image using the appropriate function from gd library
if(!strcmp(“jpg”,$ext) || !strcmp(“JPG”,$ext) || !strcmp(“jpeg”,$ext) || !strcmp(“JPEG”,$ext))
$src_img=imagecreatefromjpeg($img_name);
if(!strcmp(“gif”,$ext) || !strcmp(“GIF”,$ext))
$src_img=imagecreatefromgif($img_name);
if(!strcmp(“png”,$ext) || !strcmp(“PNG”,$ext))
$src_img=imagecreatefrompng($img_name);
//gets the dimmensions of the image
$old_x=imagesx($src_img);
$old_y=imagesy($src_img);
$ratio1=$old_x/$new_w;
$ratio2=$old_y/$new_h;
if($ratio1>$ratio2) {
$thumb_w=$new_w;
$thumb_h=$old_y/$ratio1;
}
else {
$thumb_h=$new_h;
$thumb_w=$old_x/$ratio2;
}
// we create a new image with the new dimmensions
$dst_img=ImageCreateTrueColor($thumb_w,$thumb_h);
// resize the big image [...]

How to get complete information about server using php code

Posted by: Anil Kumar Panigrahi in: ● March 22, 2010

Hi, In php there is one predefined variable called $_SERVER, with that only we can get the complete information about server.
Once check the below script:
<?php
echo “<table border = ‘2′ style=’color:#ffffff’>”;
$i = 0;
foreach($_SERVER as $key=>$value){
if($i%2 == 0) {
echo “<tr bgcolor=’#993300′>”;
} else {
echo “<tr bgcolor=’#0099FF’>”;
}
echo “<td>”;
echo $key;
echo “</td>”;
echo “<td>”;
echo $value;
echo “</td>”;
echo “</tr>”;
$i++;
}
echo “</table>”;
?>

How to highlight the source code in our php application?

Posted by: Anil Kumar Panigrahi in: ● March 18, 2010

Hi friends,
In our php application some times we want to highlight the source code to user friendly , so the following function helped you to highlight the source code.

<?php
if (!empty($_POST[’text’])){
echo ‘<div style="border: solid 1px red; width:300px;height: 150px; padding: 20px; margin: 20px">’;
highlight_string(stripslashes($_POST[’text’]));
echo ‘</div>’;
}
?>
<form action="<?php echo $_SERVER[’PHP_SELF’]?>" method="post">
<textarea name="text" style="width: 300px; height: 150px;padding: 20px; margin: 20px"><?php echo [...]


About Me

  Anil Kumar Panigrahi
  Software Engineer (PHP)
  Blogger & Founder of Anil Labs
  Baruva, India

You can share with me . . .

My Own Contributions

1) First contribution for codeigniter framework ( multi language support using google translate API ). we can get files from http://github.com/nyros/codeigniter_multilanguage


2) Audio and Video Streaming using FFMpeg and PHP -complete doc file : http://www.docstoc.com/docs/8300349/Audio-and-Video-Streaming

Twitter Updates

Follow me @anil2u
  • http://www.google.co.uk/ logo is changing with mouse move . . . - posted on 07/09/2010 10:57:33
  • True enemies are real friends . . . - posted on 06/09/2010 10:15:29
  • Just watched nice movie " Madrasapattinam ". - posted on 05/09/2010 16:20:48
  • We will always be thankful to our teacher for all the hard work and efforts they have put in, for educating us.- Happy teachers Day . . . :) - posted on 05/09/2010 05:39:13
  • Working on shipping cost functionality (UPS and USPS) for oscommerce shopping cart - posted on 01/09/2010 09:40:03