How can I fetch data from one database on a server and store them in other database on another server using PHP?
Many times we need to transfer data from one database exists on a server to another database exists on another server ,in that case we can use fourth parameter of mysql_connect function which is an optional parameter. If fourth parameter is true then it will create a new link for another database connection even if we have created database connection earlier with same detail with same database or with another database. Lets discuss how it works by an example.
Function syntax:
mysql_connect ( [string $server [, string $username [, string $password [, bool $new_link [, int $client_flags]]]]] )
Now Connect database1 using host, username and password as given below
$db1 = mysql_connect(”host”,”user”,”pwd”)
mysql_select_db(’db1name’, $db1);
Fire a query on db1
$res1 = mysql_query(”query”,$db1);
Connect database2 using host, username and password and include fourth parameter true as given below
$db2 = mysql_connect(”host”,”user”,”pwd”, true)
mysql_select_db(’db2name’, $db2);
Fire a query on db2
$res2 = mysql_query(”query”,$db2);
Now both link will remain live.If you will not use fourth parameter than setting of $db1 will be overwrite by $db2 so you can not use both objects without using this fourth parameter as true.Now after using fourth parameter you can use both database1 and database2 on same page.You can fetch data from first database and than insert that data in second database .
Tags: mysql_connect, transfer data
How to run code of php5 on a server with php4 using htaccess
Nov 26, 2009 Beginners, Experts, Php
This is big question for beginners every time.Now as we know that php5 is in full flow but still there are lot of servers out there with php4 and if you upload your php5 code on those servers then it will be mess.May be your site will not run or any part or your will go down.But don’t worry friends , there are only 2 lines to put this problem far from you.
Just put these 2 lines below in a htaccess file and put that htaccess at the root directory.
AddHandler x-httpd-php5 .php
AddHandler x-httpd-php .php4
Now all the modules either they have written in php4 or php5 will work very well.
Calculating USPS Shipping Rates with PHP
If you have a custom shopping cart and you want to calculate actual shipping rates from USPS this is the post for you. I hope that by the end of this post you will have an understanding of the process and you can begin implementing USPS rates in your own website.
You may wish to grab a copy of the USPS Rates Manual for yourself.
Read the rest of this entry »