...

View Full Version : No Database Selected



Phantom
04-06-2003, 03:35 PM
$link = mysql_connect("$config['db_host']","$config['db_user']","$config['db_pass']");
mysql_select_db("$config['db_name']");

That's the part of my code in an include file that's included in all of my game's files. Yet I get an error saying "No Database Selected" in the login and register files (which are the only files as of yet that use the database). Can anyone help me?

Galdo
04-06-2003, 05:01 PM
Have you tried:


$link = mysql_connect("$config['db_host']","$config['db_user']","$config['db_pass']");
mysql_select_db("$config['db_name']",$link);

firepages
04-06-2003, 05:51 PM
if you turn up error reporting levels ...



<?
error_reporting(E_ALL);
?>


you will see errors like
Notice: Undefined index: 'db_pass' in h:\phpdev\www\test.php on line 5

as the literal index 'db_pass' quotes and all ... does not exist.

so removing those double quotes will help !



<?
mysql_connect($config['db_host'],$config['db_user'],$config['db_pass'])or die("".__LINE__.mysql_error());
?>


note you can also use braces ... "{$config['var']}" ... but there is no point here in doing so.

Phantom
04-06-2003, 06:08 PM
Thanks that helped :-)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum