A PHP program that connects two different MySQL databases _php tutorial

Source: Internet
Author: User

echo "Connecting as MySQL
\ n ";
$connection 1 = mysql_connect (' localhost ', ' MySQL ', ') or Die ($php _errormsg);
echo "Connection1 is $connection 1
\ n ";
echo "Selecting test for MySQL user
\ n ";
mysql_select_db (' Test ', $connection 1) or @die ("Error"). $php _errormsg. Mysql_error ());
echo "Connection as Joyce
\ n ";
$connection 2 = mysql_connect (' localhost ', ' Joyce ', ') or Die ($php _errormsg);
echo "Connection2 is $connection 2
\ n ";
echo "Selecting Books for Joyce user
\ n ";
$db 2 = mysql_select_db (' Techbizbookguide ', $connection 2) or Die (Mysql_error ());
$query 1 = "Select foo from Test";
$query 2 = "Select Title, Authorfirst, authorlast from BookInfo";
echo "Querying test
\ n ";
$users = mysql_query ($query 1, $connection 1) or Die (Mysql_error ());
echo "Querying books
\ n ";
$books = mysql_query ($query 2, $connection 2) or Die (Mysql_error ());
echo "Foos from Test
\ n ";
while (list ($foo) = Mysql_fetch_row ($users)) {
Echo $foo, "
\ n ";
}
echo "Books in Techbizbookguide
\ n ";
while (list ($title, $authorFirst, $authorLast) = Mysql_fetch_row ($books)) {
Use trim in case we had a book by "Madonna" or "Prince" or ...
echo $title, ' by ', trim ($authorFirst. ' ' . $authorLast), "
\ n ";
}
?>

http://www.bkjia.com/PHPjc/316073.html www.bkjia.com true http://www.bkjia.com/PHPjc/316073.html techarticle HTMLBODY bgcolor=ffffff? php echo connecting as mysqlbr\n; $connection 1 = mysql_connect (' localhost ', ' MySQL ', ') or D IE ($php _errormsg); Echo Connection1 is $connection 1br\n; Echo S ...

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.