1,105,423 Community Members

No database selected error Plz help

Member Avatar
vinodpaul
Newbie Poster
1 post since Nov 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 
<?php
include 'vars.php';
set_time_limit(0);
putenv("TZ=Asia/Calcutta");
$conn = mysql_connect($hostname,$username,$pass)Or DIE ("Unable to connect to database");
mysql_select_db($dbname, $conn);
global $name,$pass,$userid,$sex,$nam,$password,$flag;
$userid = $_REQUEST['userid'];
$userid=strtoupper($userid);
$password = $_REQUEST['password'];
$query = "SELECT name,password,lastlogin FROM binaryusers where userid = '$userid'";
$res = mysql_query($query)or die ("Bad query: " . mysql_error() );
if (mysql_fetch_row($rs))
{
global $name, $pass, $sex, $nam,$lastlogin;
$nam = mysql_result($res,0,0);
$pass = mysql_result ($res,0,1);
$lastlogin=mysql_result ($res,0,2);
if ($pass==$password&&$userid!='')
{
global $userid,$pass,$lastlogin;
session_start();
$_SESSION['user'] = $userid;
$_SESSION['pass'] = $pass;
$_SESSION['pinlogin']=0;
$_SESSION['lastlogin']=$lastlogin;
$jtime=time();
$query="update binaryusers set lastlogin='$jtime' where userid='$userid'";
mysql_query($query);
echo "<meta http-equiv=\"REFRESH\" content=\"0;url=memberlogin.php\">";
}
else
{
  echo "userid or password is incorrect";
}
}
else
{
  echo "userid or password is incorrect";
}
?>
LastMitch
Deleted Member
 
0
 

@vinodpaul

No database selected error Plz help

You know it would be nice if you can discussed more about the issue rather than just showing the code?

Member Avatar
pritaeas
mod_pritaeas
11,298 posts since Jul 2006
Reputation Points: 1,420 [?]
Q&As Helped to Solve: 1,833 [?]
Skill Endorsements: 155 [?]
Moderator
Featured
Sponsor
 
0
 

Are you sure $dbname contains the right database name?

Member Avatar
neatric
Newbie Poster
11 posts since Jun 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 4 [?]
Skill Endorsements: 0 [?]
 
0
 

hi
please indent your code. Makes it easier to read.
Check the following variables and verify they are correct.
$dbname
$pass
$username
$hostname
One of them must be wrong!
Post back if this works or when you get a solution.

Member Avatar
SagarSe7en
Junior Poster
143 posts since Jul 2011
Reputation Points: 0 [?]
Q&As Helped to Solve: 4 [?]
Skill Endorsements: 0 [?]
 
0
 

Try Adding The Following after the first line of code

mysql_select_db("nameofdatabase") or die("Connection Error");
You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article