Tuesday, 21 May 2013

url rewrite

URL rewriting on Linux Apache and wamp
For rewriting url on Centos Please do these steps.
  1. First go to '/etc/httpd/conf/httpd.conf' and for wamp left click on wamp icon and go to Apache then httpd.conf and uncomment - #LoadModule rewrite_module modules/mod_rewrite.so and #AddModule mod_rewrite.c, so do so please remove trailing #.

  2. Now Edit directory section in this file for directory /var/www/html and change 'AllowOverride none' to 'AllowOverride All'.

    Eg.
    Options Indexes FollowSymLinks
    AllowOverride none
    Order allow,deny
    Allow from all
    ;
    TO

    Options Indexes FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all
    ;
  3. Now make a file in server root directory '/var/www/html' name .htaccess and write these line in this

Options +FollowSymlinks

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{REQUEST_FILENAME}\.php -f

RewriteRule ^(.*).php$ $1.html [NC]

RewriteRule ^(.*).html$  $1.php [NC]



4-Now this will replace php extension in your file to .html extension  so now if you want to open index.php then write only http://url/index.html only instead of http://url/index.php

Tuesday, 7 May 2013

for submit form on change jquery




<script>
$(document).ready(function() {
alert("hello");
    $('#catname').change(function() {
        $('form').submit();
    });
});


</script>

Tuesday, 9 April 2013



//for js
$("select.gw").live("change",function()
    {
   
        var gpid = $(this).attr("data");
        var thid = $(this).attr("id");
        var gwid = $("select#"+thid+" option:selected").val();
        var tmpp = "select#"+thid+" option:selected";
        if(gwid!='')
        {
       
        $.post("ajax/dropdown.php", { gwid: gwid },
        function(data) {
       
        $("select#"+gpid).attr("disabled",false);
        $("select#"+gpid).html(data);
        });
        }
        else
        {
       
        $("select#"+gpid).html("");
        $("select#"+gpid).attr("disabled",true);
        }
   
    });
   
           
            //drop down list
<select name="gw1" id="gw1" class="gw" data="gp1"><option value="">Please Select</option>
                <?php $fetRefre = mysql_query("select * from  table");
                while($rowGate = mysql_fetch_array($fetRefre))
                {?>
                <option value="<?=$rowGate['id']?>"><?=$rowGate['name']?>       
                <?php }?>
                </select>


//ajax page
if($_POST['gwid']) {
  $id = $_POST['gwid'];
  $sql=mysql_query("SELECT * FROM table where gw_id =$id ");

    while($row = mysql_fetch_array($sql)) {
      $id=$row['id'];
      $data=$row['name'];
      echo "<option value=$id>$data</option>";
    }
 }

Friday, 5 April 2013

chain delete recursive

function recursiveDelete($id) {
                        $result=mysql_query("SELECT * FROM vb_users WHERE parent_uid = '$id'");
                                if (mysql_num_rows($result)>0) {
                                     while($current=mysql_fetch_array($result)) {
                                      recursiveDelete($current['id']);
                                     }
                                }
                                echo $id."<br>";
                      // mysql_query("DELETE FROM cc_reseller WHERE id='$id'") or die("some thing error 1");
                       
                     
                        }   
     recursiveDelete($_GET['id']);

Wednesday, 20 March 2013

Anil Yadav: memcache

Anil Yadav: memcache: Memcached with PHP. Memcahced open source distributed memory object caching system it helps you to speeding up the dynamic web appli...

Tuesday, 19 March 2013

memcache

Memcached with PHP.

Memcahced open source distributed memory object caching system it helps you to speeding up the dynamic web applications by reducing database server load. In this post I want to explain how I had implemented Memcached object caching system for  This system is very helpful for high traffic media and blog related websites.

Memcached



Database
Sample database demos table contains id, title and link.
CREATE TABLE demos
(
id INT PRIMARY KEY AUTO_INCREMENT,
title VARCHAR(300),
link VARCHAR(300),
);

First User Request
First request goes to database server at the same time data object storing in Memcached server.
Memcached

Second User Request
Second user request data comes from Memcached object.
Memcached

Memcached Installation
Lots of better resources available on web please follow the links. php_memcache.dll
INSTALLING MEMCACHED ON AMAZON LINUX AMI - QUICK AND EASY.
INSTALLING MEMCACHED ON Windows.
install Memcached on Xampp on Windows 7
Memcached for PHP 5.3 on Windows 7.

index.php
Contains PHP code.
<?php
include('db.php');
$memcache = new Memcache;
$memcache->connect('localhost', 11211) or die ("Could not connect");

$key = md5('List 9lessons Demos'); // Unique Words
$cache_result = array();
$cache_result = $memcache->get($key); // Memcached object 

if($cache_result)
{
// Second User Request
$demos_result=$cache_result;
}
else
{
// First User Request 
$v=mysql_query("select * from demos order by id desc");
while($row=mysql_fetch_array($v))
$demos_result[]=$row; // Results storing in array
$memcache->set($key, $demos_result, MEMCACHE_COMPRESSED, 1200);
// 1200 Seconds
}

// Result
foreach($demos_result as $row)
{
echo '<a href='.$row['link'].'>'.$row['title'].'</a>';
}

?>

db.php
You have to change hostname, username, password and database name.
<?php
$mysql_hostname = "localhost";
$mysql_user = "username";
$mysql_password = "password";
$mysql_database = "database";
$bd = mysql_connect($mysql_hostname, $mysql_user, $mysql_password)
or die("Opps some thing went wrong");
mysql_select_db($mysql_database, $bd) or die("Opps some thing went wrong");
?>