Author: darshakkumar
-
how to working with two database in php/mysql?
//connection file //tested in php 5.3.5 & mysql 5.5.8 //make sure database username & database host are same at same place… $host=”localhost”; $dbnm=’db1′; $dbunm=’root’; $dbpass=”; $conn=mysql_connect($host,$dbunm,$dbpass); $db=mysql_select_db($dbnm,$conn); //==================================================================// $host_=”localhost”; $dbnm_=’db2′; $dbunm_=’root’; $dbpass_=”; $conn_=mysql_connect($host_,$dbunm_,$dbpass_); mysql_select_db($dbnm_,$conn_) or die(mysql_error()); //============== Example =============================// $sql=”select * from db1.test”; $re=mysql_query($sql) or die(mysql_error()); $sql_=”select * from db2.test”; $re_=mysql_query($sql_); //join query between two database’s tables….…
-
how to get xml CDATA content and write in csv format in php?
<!–?php $url = ‘http://calendar.forex-tsd.com/calendar.php?xml=1&calendar[]=4’; //get file content but not display in browser because xml content some <![CDATA[ CDATA – (Unparsed) Character Data $test = file_get_contents($url); //so we replace replace with @#$ and store into $arr array variable. $arr=explode(‘@#$’,str_replace(‘]]>’,”,str_replace(‘<![CDATA[‘,’@#$’,$test))); $str[]=”; //we open or create a file.csv file. $fp = fopen(‘file.csv’, ‘w’); //we write a data in…
-
how to Change browser url without page reloading with ajax request using JavaScript, HTML5 history API, jQuery, PHP like Facebook, Github navigation menu?
Consider a page that has the following links to three menu items and a div to display the ajax content. <div id=”menu”> <a href=”m1.php” rel=”tab”>menu1</a> | <a href=”m2.php” rel=”tab”>menu2</a> | <a href=”m3.php” rel=”tab”>menu3</a> </div> To override the default action for the link(anchor tag), use the following jQuery code snippet. $(function(){ $(“a[rel=’tab’]”).click(function(e){ //code for the link…
-
How to create robots.txt file?
Robots.txt is a text (not html) file you put on your site to tell search robots which pages you would like them not to visit. Robots.txt is by no means mandatory for search engines but generally search engines obey what they are asked not to do. It is important to clarify that robots.txt is not…
-
how to set default timezone in php?
<?php date_default_timezone_set(‘Europe/London’); echo date(‘Y-m-d H:i:s’); ?>
-
how to fetch all supported timezones in PHP?
<?php $timezone_offsets = array(); foreach(timezone_identifiers_list() as $timezone_identifier) { $date_time_zone = new DateTimeZone($timezone_identifier); $date_time = new DateTime(‘now’, $date_time_zone); $timezone_offsets[$timezone_identifier] = $date_time_zone->getOffset($date_time); } echo “<pre>”; print_r($timezone_offsets); ?>
-
how to insert,select,delete,update data from file in c?
Download example file : example.c Compiled on : Borland Turbo C++ 3.0
-
how to refresh particular div tag content without reloading page using jquery?
// Note : First include jquery.js file….. <script type=”text/javascript”> var auto_refresh = setInterval( function () { $(‘#load_div’).load(‘load.php’).fadeIn(“slow”); }, 100000); // refresh every 10000 milliseconds </script> //index.php <div id=”load_div”> </div> //load.php In this page you can write your code. like load randam user,image etc….
-
How to pass data from one domain to another domain(cross domain) using json?
//Javascript code <script type=”text/javascript”> $(document).ready(function() { var surl = “http://www.example.com/json.php”; email_id=document.getElementById(“email”).value; $.ajax({ url: surl, data: {email:email_id}, dataType: “jsonp”, jsonp : “callback”, jsonpCallback: “jsonpcallback” }); }); function jsonpcallback(rtndata) { document.getElementById(“disp_data”).innerHTML=rtndata.message; } </script> //json.php file code <?php $display=”<b>HI Json</b>”; $display.=”<p>HI This is testing json.</p>”; $rtnjsonobj->message = $display; echo $_GET[‘callback’]. ‘(‘. json_encode($rtnjsonobj) . ‘)’; ?>
-
error page using htaccess file
first create .htaccess file and save it. then write below code ErrorDocument 404 /404.html here 404 means when page not found then it occurs 404.html means that page which you want to display.
