Hello here s the beginning of a script, when it gets to case forum 2, it gives me an error msg saying "no selected database" What s wrong?Must be something obvious I don't see Any idea is welcome $dbhost = 'localhost'; $dbuser = 'user'; $dbpass = 'password'; $dbbase = 'database'; $sql = mysql_connect($dbhost,$dbuser,$dbpass); mysql_select_db($dbbase); if(isset($_POST) && !empty($_POST['login']) && !empty($_POST['login2']) && !empty($_POST['pass'])) { extract($_POST); switch ($_POST['cat']) { case "forum2" : $qry = "select licence,pass,nom,prenom,sexe from autorise where nom='".$login."' and prenom='".$login2."'"; $req = mysql_query($qry) or die('ça marche pas !<br>'.$qry.'<br>'.mysql_error()); $data = mysql_num_rows($req); PHP:
are all of these set correctly? $dbhost = 'localhost'; $dbuser = 'user'; $dbpass = 'password'; $dbbase = 'database'; PHP: do you have the database set up? with adequate permissions for the user? change $sql = mysql_connect($dbhost,$dbuser,$dbpass); mysql_select_db($dbbase); PHP: to $sql = mysql_connect($dbhost,$dbuser,$dbpass) or die('COULD NOT CONNECT TO DB');; mysql_select_db($dbbase) or die('COULD NOT SELECT DB'); PHP:
db is installed and set correctly, user and things are ok , i ll try your code (last one ) in 2 minutes Thanks for your answer :d
ok..I can t believe i ve spent 3 days (not 24/24h ) on that ... Because there were no die instruction after the select, i took for granted that it was working and rather looked at the line giving the error...the first mysql instruction after the select. After I ve added the die check, i of course realised the db name (the one i ve checked 20 times in the last 3 days) is not the good one, i changed a "-" for a "_" . I knew it was something obvious Tks for your help, you get rep for it