Craziest Posted August 5, 2006 Share Posted August 5, 2006 i need to have two databases while am login. one fake and one original . if the fake login and the password is true then it will redirect him to another page. so i need to have two require statements so it can check both databases,,if its possible tht would be great... i will be greatful for any comments.... Quote Link to comment Share on other sites More sharing options...
ronverdonk Posted August 5, 2006 Share Posted August 5, 2006 Following is a quote from an entry in the php.net documentation for mysql_select_db:[quote]Originally Posted by matsko at rogers dot com 10-May-2006 09:19 Just incase the mysql_select_db() function still won't work with multiple database connections (as has happened to me before).$dbh1 = mysql_pconnect($host,$user,$pass);$dbh2 = mysql_pconnect($host,$user,$pass);You could do this...mysql_query("USE database1",$dbh1);mysql_query("Use database2",$dbh2);This does the same thing as the mysql_select_db() function...or this...You don't even have to select the database for each connection.mysql_query("SELECT * FROM database1.table",$dbh1);mysql_query("SELECT * FROM database2.table",$dbh2); [/quote] Quote Link to comment Share on other sites More sharing options...
redarrow Posted August 5, 2006 Share Posted August 5, 2006 [code]<?phpif($name && $password){if($_POST['submit']) {$db1=mysql_connect("xxxx","xxxxx","xxxxx");$result1=mysql_select_db("xxxxx",$db1);$query1="select * from xxxxx where id='$id'":$resulted1=mysql_query($query1);if(mysql_num_rows($resulted1)){echo " your logged into database 1";}else{$db2=mysql_connect("xxxx","xxxxx","xxxxx");$result2=mysql_select_db("xxxxx",$db2);$query2="select * from xxxxxxx where id='$id'":$resulted2=mysql_query($query2);if(mysql_num_rows($resulted2)){echo " your logged into database 2";} } }else{echo " Sorry but we have no deatail of your account please register thank you.";include("register.php");}?>[/code] Quote Link to comment Share on other sites More sharing options...
Craziest Posted August 5, 2006 Author Share Posted August 5, 2006 Thanks guys for the quick reply,im still getting afew problems since im using wordpress and adding this feature to the login form.this is what i addedwp-login.php[code]<?phprequire('./wp-config.php');function login($username, $password, $already_md5 = false) { global $wpdb, $wpdb1, $error, $tableusers; if($username && $password){if($_POST['submit']) {$wpdb=mysql_connect($server,$loginsql,$passsql);$query = "SELECT ID, user_login, user_pass FROM $tableusers, WHERE user_login = '$username'";$login =mysql_query($query);}else{$wpdb2=mysql_connect($server1,$loginsql1,$passsql1);$query2 = "SELECT ID, user_login, user_pass FROM $tableusers, WHERE user_login = '$username'";$login =mysql_query($query2);[/code]and in the wp-config.php[code]// ** MySQL settings ** //define('DB_NAME', 'wp1'); // The name of the databasedefine('DB_USER', 'root'); // Your MySQL usernamedefine('DB_PASSWORD', ''); // ...and passworddefine('DB_HOST', 'localhost'); // 99% chance you won't need to change this valuedefine('DB_NAME1', 'wp1fake'); // The name of the databasedefine('DB_USER1', 'root'); // Your MySQL usernamedefine('DB_PASSWORD1', ''); // ...and passworddefine('DB_HOST1', 'localhost'); // 99% chance you won't need to change this value$table_prefix = 'wp_'; // example: 'wp_' or 'b2' or 'mylogin_'define ('WPLANG', '');/* Stop editing */$server = DB_HOST;$loginsql = DB_USER;$passsql = DB_PASSWORD;$base = DB_NAME;/* Stop editing */$server1 = DB_HOST1;$loginsql1 = DB_USER1;$passsql1 = DB_PASSWORD1;$base1 = DB_NAME1;[/code]When i enter the username and pass in wp-login.php it says Warning: mysql_connect(): Access denied for user 'ODBC'@'localhost' (using password: NO) in c:\appserv\www\wp\wp-login.php on line 14which is [code]$query = "SELECT ID, user_login, user_pass FROM $tableusers, WHERE user_login = '$username'";[/code]Sorry im brand new in php :( please excuse my silly mistakes. Quote Link to comment Share on other sites More sharing options...
bubazoo Posted August 6, 2006 Share Posted August 6, 2006 huh, .....and I always thought u had to do a join (shrugs) ...learn something new everyday I suppose Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.