mr_badger Posted May 28, 2007 Share Posted May 28, 2007 I'am getting this error on one of my pages "Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link resource in". this is the code <?php require_once('../Connections/conn.php'); ?> <?php mysql_select_db($database_web78-salon, $web78-salon); $query_rsTimes = "SELECT DISTINCT availDate FROM savailability ORDER BY availDate ASC"; $rsTimes = mysql_query($query_rsTimes, $web78-salon) or die(mysql_error()); $row_rsTimes = mysql_fetch_assoc($rsTimes); $totalRows_rsTimes = mysql_num_rows($rsTimes); ?> Quote Link to comment https://forums.phpfreaks.com/topic/53332-database-select-problem/ Share on other sites More sharing options...
AndyB Posted May 29, 2007 Share Posted May 29, 2007 Probably because $web78-salon is being interpreted as $web78 minus salon; same thing with the database name. Quote Link to comment https://forums.phpfreaks.com/topic/53332-database-select-problem/#findComment-263564 Share on other sites More sharing options...
mr_badger Posted May 29, 2007 Author Share Posted May 29, 2007 that makes sense, but I can't change the name, it has to have that minus. Quote Link to comment https://forums.phpfreaks.com/topic/53332-database-select-problem/#findComment-263570 Share on other sites More sharing options...
AndyB Posted May 29, 2007 Share Posted May 29, 2007 Really? Try a variant: $db_name = 'database_web78-salon'; $db_user = 'web78-salon'; mysql_select_db($db_name,$db_user); Quote Link to comment https://forums.phpfreaks.com/topic/53332-database-select-problem/#findComment-263575 Share on other sites More sharing options...
mr_badger Posted May 29, 2007 Author Share Posted May 29, 2007 I have tried what you suggested and the errors have gone, but it says no database selected, I can't work out why it's saying this. <?php $db_name = web78-salon; $db_user = web78-salon; mysql_select_db("localhost,web78-salon,darwen"); $query_rsTimes = "SELECT DISTINCT availDate FROM savailability ORDER BY availDate ASC"; $rsTimes = mysql_query($query_rsTimes, $conn) or die(mysql_error()); $row_rsTimes = mysql_fetch_assoc($rsTimes); $totalRows_rsTimes = mysql_num_rows($rsTimes); ?> Quote Link to comment https://forums.phpfreaks.com/topic/53332-database-select-problem/#findComment-263855 Share on other sites More sharing options...
AndyB Posted May 29, 2007 Share Posted May 29, 2007 Take a much closer look at my suggestion. The variables I defined are strings, hence their definition within quotes. The db_select query uses variables, not something enclosed in quotes as a single variable. I'm skeptical that your database name and username are identical, but you should know what's what. I'd suggest you move the definitions of host, database name, database user, database password, etc. into an included file (like connections.php perhaps) and make sure you define them as strings, and then in your script always refer to those defined variable names. Quote Link to comment https://forums.phpfreaks.com/topic/53332-database-select-problem/#findComment-263911 Share on other sites More sharing options...
mr_badger Posted May 29, 2007 Author Share Posted May 29, 2007 I think the problem is that my copy of dreamweaver is a copy downloaded from the internet, everything connects it just doesnt show my tables. Appartly this can be cause by not having the retail version of dreamweaver. Quote Link to comment https://forums.phpfreaks.com/topic/53332-database-select-problem/#findComment-264063 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.