Jump to content

Recommended Posts

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);
?>

Link to comment
https://forums.phpfreaks.com/topic/53332-database-select-problem/
Share on other sites

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);
?>

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.