CraigF Posted May 18, 2007 Posted May 18, 2007 I register the account, and when i log into it, well when i TRY to log in, it says "No Database Selected" on a plain white screen, please help lol. mysql.php is set up: <? $c=mysql_connect('localhost','USER','PASS') or die(mysql_error()); mysql_select_db('fallen',$c); ?> the database name is fallen. Quote
hamster01 Posted May 18, 2007 Posted May 18, 2007 Re: No Database Selected I normally get that erro when i dont say what db i need. Or when the fields name is a function. in the query call it. ex: mysql_query("SELECT userid FROM dbname.tablename WHERE blah=$blah"); Quote
CraigF Posted May 18, 2007 Author Posted May 18, 2007 Re: No Database Selected where do i put that? mysql_query("SELECT userid FROM fallen.users WHERE ??=??"); Quote
hamster01 Posted May 18, 2007 Posted May 18, 2007 Re: No Database Selected Well, just replace the tablename in the query's to that. Quote
CraigF Posted May 18, 2007 Author Posted May 18, 2007 Re: No Database Selected in authenticate.php: $uq=mysql_query("SELECT userid FROM users WHERE login_name='{$_POST['username']}' AND `userpass`=md5('{$_POST['password']}')",$c) or die(mysql_error()); changed that to mysql_query("SELECT userid FROM users WHERE login_name='{$_POST['username']}' AND `userpass`=md5('{$_POST['password']}')",$c) or die(mysql_error()); it doesnt work i dont know what you mean and where to put it Quote
hamster01 Posted May 18, 2007 Posted May 18, 2007 Re: No Database Selected $uq=mysql_query("SELECT userid FROM users WHERE login_name='{$_POST['username']}' AND `userpass`=md5('{$_POST['password']}')",$c) or die(mysql_error()); to $uq=mysql_query("SELECT userid FROM fallen.users WHERE login_name='{$_POST['username']}' AND `userpass`=md5('{$_POST['password']}')",$c) or die(mysql_error()); Quote
CraigF Posted May 18, 2007 Author Posted May 18, 2007 Re: No Database Selected SELECT command denied to user 'USER'@'localhost' for table 'users' Now what lol. Thanks for that one step over Quote
hamster01 Posted May 18, 2007 Posted May 18, 2007 Re: No Database Selected check your conig file Quote
hamster01 Posted May 18, 2007 Posted May 18, 2007 Re: No Database Selected uhuh. Nvm that. ill give you my authenticate.php Is secure and can handle much more login requests ;) what version are you using ? Quote
hamster01 Posted May 18, 2007 Posted May 18, 2007 Re: No Database Selected Your smoking something? :lol: Thats only with free hosting. Even on my local I dont use a preflix :loL: Quote
CraigF Posted May 18, 2007 Author Posted May 18, 2007 Re: No Database Selected im using v1 lol, thanks :) Quote
hamster01 Posted May 18, 2007 Posted May 18, 2007 Re: No Database Selected Cool ;) Anyone else using this must ask me :@ Here is mine: <?php session_start(); include "mysql.php"; global $c; ?> <style type='text/css'> .style1 { font-family: Tahoma; font-size: x-small; } .style2 { font-family: Tahoma; font-size: xx-small; color: #FFFFFF; font-weight: bold; } .style4 {font-size: xx-small; color: #999999; font-family: Tahoma;} .style7 {font-family: Tahoma; font-size: xx-small;} .style8 {font-size: xx-small} body { background-image: url([url]http://www.gangsterterritory.com/bgmain.gif[/url]); background-repeat: repeat; } </style> <title>Login</title> <center> <h3> <div align="center" class="style1"> [img=yourlogo.png]</p> <table width="50%" border="0" cellpadding="10" cellspacing="5"> <tr> <td bgcolor="#333333" class="style2">Login >> Authenticateion </td> </tr> <tr> <td bgcolor="#000000" class="style4"><div align="center"> <?php $user = $_POST['username']; $pass = $_POST['password']; $safe_user = mysql_real_escape_string($user); $safe_pass = mysql_real_escape_string($pass); if ($safe_user == "" || $safe_pass == "") { echo "You did not enter a Username or Password. <a href=login.php>> [b]Back[/b]</a>"; exit; } $uq = mysql_query("SELECT userid FROM users WHERE login_name='$safe_user' AND `userpass`=md5('$safe_pass')",$c) or die(mysql_error()); if (mysql_num_rows($uq)==0) { echo "Incorrect Username or Password. <a href=login.php>> [b]Back[/b]</a>"; exit; } else { $mem = mysql_fetch_array($uq); $_SESSION['loggedin']=1; $_SESSION['userid']=$mem['userid']; ?> <div align="center"> <p class="style7">[b]Processing Log in</span>[/b] </p> </div> <p align="center" class="style1"><span class="style8">If you are not redirected within 10 seconds please click [url='loggedin.php']here[/url]. </span> </p> <p align="center"><span class="style4"> </span><span class="style7">[email='[email protected]']Click here to contact an administrator.[/email]</span></p> <?php echo "<meta http-equiv='Refresh' content='5; URL=loggedin.php'>"; } ?> </td> </tr> </table> </p> </div> </center> Quote
CraigF Posted May 18, 2007 Author Posted May 18, 2007 Re: No Database Selected now it is back to: No database selected Quote
mdshare Posted May 18, 2007 Posted May 18, 2007 Re: No Database Selected You always need the servername prefix to connect to a db do what lostone said kraig (same counts for the user, needs the servername prefix) Quote
CraigF Posted May 18, 2007 Author Posted May 18, 2007 Re: No Database Selected done workss nearly: " Incorrect Username or Password." but it should work Quote
hamster01 Posted May 18, 2007 Posted May 18, 2007 Re: No Database Selected Lost one f**koff. My authenticate.php has a connection to the database ****! You are truly the LOST one here I edited a word which would offend, at the very least, most women. -vinyl Quote
hamster01 Posted May 18, 2007 Posted May 18, 2007 Re: No Database Selected SO you took it without asking me :o Thief! And FYI, Kraig's msn does not work ;) Quote
mdshare Posted May 18, 2007 Posted May 18, 2007 Re: No Database Selected My authenticate.php has a connection to the database cunt! yes it has >>> include "mysql.php"; Quote
hamster01 Posted May 18, 2007 Posted May 18, 2007 Re: No Database Selected So protection against sql injections, and sql optimation is useless? Remember than ;) Quote
hamster01 Posted May 18, 2007 Posted May 18, 2007 Re: No Database Selected lol fine run away from your own post. I did supply an solution to him ;) Quote
CraigF Posted May 18, 2007 Author Posted May 18, 2007 Re: No Database Selected Guys please stop arguing, you both tried. but i can sign up and everything but if i try log in it doesnt work :s I have checked my password is correct Quote
hamster01 Posted May 18, 2007 Posted May 18, 2007 Re: No Database Selected One last thing losty.. I gave my whole script ;) --------Done---------- KrAiG, try the one i gave you(authenticate.php). It cant be the mysql.php as your register works. Quote
CraigF Posted May 18, 2007 Author Posted May 18, 2007 Re: No Database Selected still says incorrect. and if i sign up and try log in it still doesnt work, i dont think that the register file is working, because i can sign up with the same username loads of times Quote
CraigF Posted May 18, 2007 Author Posted May 18, 2007 Re: No Database Selected ALSO: i have put the origional register.php file in and it doesnt work either Quote
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.