Use external smtp server

to use external smtp server we need to change some ini setting . this setting can be chage using following code ini_set(sendmail_from,”info@domain.com”); ini_set(SMTP,”New smto host name”); ini_set(smtp_port,”25″); using rhis code you can send mail fro the given smtp mail server

select ranodom record from mysql and php

Use this query “select * from table_name order by rand() limit 1 “

Copy file to other server using curl

//——-curl $source_file=”example.php”; $fp = fopen($source_file, “r”); $url = “ftp://username:password@target_server_url:21 file_path /file_name”; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_UPLOAD, 1); curl_setopt($ch, CURLOPT_INFILE, $fp); curl_setopt($ch, CURLOPT_FTPASCII, 1); curl_setopt($ch, CURLOPT_INFILESIZE, filesize($source_file)); $result = curl_exec($ch); curl_close($ch); //———

Get Database size in mysql and php

<?php require_once(“conf.php”); // youe database connection file $result = mysql_query( “SHOW TABLE STATUS” ); $dbsize = 0; while( $row = mysql_fetch_array( $result ) ) { $dbsize += $row[ "Data_length" ] + $row[ "Index_length" ]; } ?> <?php echo “<p>The size of the database is ” . formatfilesize( $dbsize ) . “</p>”; ?>

google search code in php

$url = “http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q=Paris%20Hilton” // sendRequest // note how referer is set manually $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_REFERER, “http://www.yousite.com”); $body = curl_exec($ch); curl_close($ch); // following function json_decode is ready avaialable in php 5 > $json = json_decode($body);

display errors in php

For some good reasons some server hide php errors , still you want to display it for debugging purpose then use following simple two lines of code in a page where you want to display error error_reporting(E_ALL); ini_set(“display_errors”,”1″);

Php Server side security using preg_match.

To avoid the cross side scripting or make site safe from hacker attacks one need to perform data validation before allowed data insertion into database . We can achieve this using php preg_match which check data format to see whether it is in valid state or not. The following code snippet is standard validation example [...]

Php Server side security using preg_match.

To avoid the cross side scripting or make site safe from hacker attacks one need to perform data validation before allowed data insertion into database . We can achieve this using php preg_match which check data format to see whether it is in valid state or not. The following code snippet is standard validation example [...]

Welcome to your Dream world ! ! !

Hi Guys , This is my test blog . To see how it looks .

Follow

Get every new post delivered to your Inbox.