mcerveni Posted May 9, 2009 Share Posted May 9, 2009 Hey guys, I've been connecting to multiple databases, and on my localhost at home it works fine. When I upload everything to the web, it doesn't work at all. When i log in it says: No database selected Code below: <?php include('header.php'); $email = $_GET['email']; $pass = $_GET['pass']; $handle = mysql_connect($host,$user,$pwd); mysql_query("USE $agentcenter_database",$handle); $query = "SELECT * FROM users WHERE email = '$email' && password = '$pass' "; $row = mysql_fetch_assoc(mysql_query($query)); if($row['email'] == $email && $row['password'] == $pass && $row['activated'] == "yes") { $empID = $row['empID']; $_SESSION['asc_logged_in'] = TRUE; $handle2 = mysql_connect($host2,$user2,$pwd2); mysql_query("USE $stats",$handle2); $sql1 = "SELECT * FROM employee_compo WHERE Email = '$email'"; $result1 = mysql_query($sql1) or die(mysql_error()); $row1= mysql_fetch_array($result1); $agentName = $row1['AgentName']; $_SESSION['agentName'] = $agentName; $_SESSION['empID'] = $empID; echo " <br><br><br> <h3> Welcome $agentName </h3> <a href='home.php'> Continue </a> "; } else { echo "<br><br><br><br> <font color='red'> Your email address or password is wrong.</font> <a href='index.php'> Please try again. </a> "; } ?> What doesn't seem to work is the second query. that's where it's giving me "No database selected" Any idea why? Link to comment https://forums.phpfreaks.com/topic/157497-connecting-to-multiple-databases/ Share on other sites More sharing options...
RussellReal Posted May 9, 2009 Share Posted May 9, 2009 the hosts have changed? passwords changed? Link to comment https://forums.phpfreaks.com/topic/157497-connecting-to-multiple-databases/#findComment-830358 Share on other sites More sharing options...
wildteen88 Posted May 9, 2009 Share Posted May 9, 2009 You're not selecting a database after your have connected to the server. This how your code should be: $handle = mysql_connect($host,$user,$pwd); mysql_select_db('your database name', $handle); mysql_query("USE $agentcenter_database",$handle); Link to comment https://forums.phpfreaks.com/topic/157497-connecting-to-multiple-databases/#findComment-830360 Share on other sites More sharing options...
mcerveni Posted May 9, 2009 Author Share Posted May 9, 2009 Thank you so much! lol i didn't realize I was missing that. And my deadline for this is tomorrow! you saved my ass! Thanks again. Link to comment https://forums.phpfreaks.com/topic/157497-connecting-to-multiple-databases/#findComment-830369 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.