Jump to content

mysql_db_select error


chesirpig

Recommended Posts

I am trying to get a function to work so that after a user has logged on, I can pull a recordset of that users information from the $_SESSION['MM_Username'].

If i just echo the MM_Username, it works.  If I define that as a variable and echo it, it works.  I have a require once statement to my DB.  Which works on every other page.

Here is the code:

function get_user_info($MM_Username){

global $dw_bside;

mysql_select_db($database_dw_bside, $dw_bside);

$query_rsPatinfo = "SELECT *";

$query_rsPatinfo .=" FROM pat_info ";

$query_rsPatinfo .=" WHERE pat_info.email = ". $MM_Username ;

$rsPatinfo = mysql_query($query_rsPatinfo, $dw_bside) or die("Client survey query failed: " . mysql_error());

if ($current = mysql_fetch_array($rsPatinfo)) {

return $current;}

else { return null;}

}

i always get the error: mysql_select_db expects statement 2 to be a resource  for both the select_db and the query.  I've tried with and without the global.

Thanks for the imput.

Link to comment
https://forums.phpfreaks.com/topic/201072-mysql_db_select-error/
Share on other sites

Firstly, globals are never a good solution. Secondly, the variable $database_dw_bside also does not exist within your function.

 

Assuming you already have a connection open and have already selected your database outside of the function, I would simply remove the call to mysql_select_db. mysql_query does note require a connection to be passed to it, it will use the first open connection it finds if you don't explicitly provide one.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.