Hey,

i'm trying to connect to databases together in a single php, i follow a guide i searched in google, but there is something wrong with it...no error, juz a blank page...

<?php
	//This file is to check for the invoice number whether it exists or the field is empty
    session_start();										//starting session
    $host="localhost"; // Host name
    $username=""; // Mysql username
    $password=""; // Mysql password
    $db_name="test"; // Database name
    $tbl_name="test2"; // Table name
    $db_name1="test1"; // Database name
    $tbl_name1="test3"; // Table name 

    // Connect to server and select database.
    $dbh1=mysql_connect("$host", "$username", "$password")or die("cannot connect");
    $dbh2=mysql_connect("$host", "$username", "$password",true)or die("cannot connect");
	
	mysql_select_db("$db_name1", $dbh1)or die(mysql_error());
	mysql_select_db("$db_name2", $dbh2)or die(mysql_error());
     
    $invoiceno=$_POST['invoiceno'];							
    $_SESSION['invoice_no']=$invoiceno;						
    $sql="SELECT * FROM $tbl_name WHERE invoice_no = '$invoiceno'";			
    $result = mysql_query($sql);											$row=mysql_fetch_array($result);										
    echo "$row";
    if($row>0)													
	{
		echo "Invoice No. found";
	}
    else										
	{
		echo "ngek ngek";
	}
?>

okay...so i manage to get the syntax's right...now i'm having problem connecting the databases...one is connecting but not the other one...

session_start();										//starting session
    $host="localhost"; 		// Host name
    $username=""; 			// Mysql username
    $password=""; 			// Mysql password
    $db_name="test"; 		// Database name
	$db_name1="test1"; 		// Database name
    $tbl_name="test2"; 		// Table name
	$tbl_name1="test3"; 	// Table name 
	
    // Connect to server and select database.
    $dbh1=mysql_connect("$host", "$username", "$password")or die("cannot connect");
    $dbh2=mysql_connect("$host", "$username", "$password",true)or die("cannot connect");
	
	mysql_select_db("$db_name", $dbh1)or die(mysql_error());
	mysql_select_db("$db_name1", $dbh2)or die(mysql_error());

error i'm getting : Access denied for user ''@'localhost' to database 'test1'

okay...let me know if u do....i'm still trying to figure this one out...thanks

It basically means that your login details are incorrect for the database.

you are getting this error due to user name is not correct i think

sorry...i solved it long time ago...forgot to update

mysql_query($sql,dhb1);	<------need to specify the connection