Wednesday, January 27, 2010

Display Find Get Yahoo Backlinks in php

Contact Us

Hire PHP Web Developer

$url = "http://www.google.com";

$page = file_get_contents("http://siteexplorer.search.yahoo.com/search?p=$url&bwm=i&bwmf=a&bwms=p");

$expression = '/<span class="btn">Inlinks \((.*)\)<i class="tl"><\/i>/Us'; 

preg_match($expression, $page, $matches); 

print_r($matches);

Search whole word from database value in mysql

Contact Us

Hire PHP Web Developer

Following example will retrive all the records from table that have 'music' word in emp_info colomn.
Query will avoid emp_id = 4 bcoz its not has 'music' only. its 'musics' in value.

There are 3 ways, you can get result from databse.

Lets assume we have following table :

table : emp_info

CREATE TABLE 
  emp_info (
  emp_id  INT UNSIGNED NOT NULL PRIMARY KEY,
  emp_name VARCHAR(200),
  emp_info TEXT,
  FULLTEXT (emp_info)
   );

Insert following rows into table :

emp_id  emp_name emp_info
=============================================================================
1  Rocky  i love to sing a song 
2  Andy  i want to become a singer 
3  Jackson  i am music lover
4  Neil  i don't like musics
5  Williem  sometime i enjoy music
6  Helly  i love music all day 


query1 => SELECT emp_id FROM emp_info WHERE  emp_info like '% music %'
query2 => SELECT emp_id FROM emp_info WHERE  MATCH (emp_info) AGAINST('music') 
query3 => SELECT emp_id FROM emp_info WHERE  emp_info REGEXP '[[:<:]]music[[:>:]]' =1 

Output of all query: 
emp_id : 
3
5
6

contact : iamvasim@gmail.com

Monday, January 18, 2010

how to use ob_start function in php

Contact Us

Hire PHP Web Developer

Syntax :
bool ob_start ([ callback $output_callback [, int $chunk_size [, bool $erase ]]] )

what it does :
This function will turn output buffering on. While output buffering is active no output is sent from the script (other than headers), instead the output is stored in an internal buffer.

Example :

<?php
function callback_function($buffer)
{
// replace all the apples with oranges
return (str_replace("hi", "hello", $buffer));
}

ob_start("callback_function");
?>
<html>
<body>
<p>Hello World, example : hi to all </p>
</body>
</html>
ob_end_flush();

Output :
Hello World, example : hello to all