Jump to content

Archived

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

the apprentice webmaster

can anyone help ( database connection issue )

Recommended Posts

hi guys , i am having this problem , everything seems to be fine but every time i ran the script i got this error

: 1046 - No database selected

select configuration_key as cfgKey, configuration_value as cfgValue from configuration

[TEP STOP]


this is what the dtabase connection look like

// define our database connection
  define('DB_SERVER', 'localhost');
  define('DB_SERVER_USERNAME', 'user');
  define('DB_SERVER_PASSWORD', 'user');
  define('DB_DATABASE', 'commerce_db');
  define('USE_PCONNECT', 'false');
  define('STORE_SESSIONS', '');
?>

the database is there , so why it is not connectiing , please anyone help

Share this post


Link to post
Share on other sites
The code you pasted doesn't connect to the database, it just sets variables to be used when the connection is made.  Is there any code looking like mysql_connect() or DB::connect() ?

Share this post


Link to post
Share on other sites
thx for your remar, i have this code in my database script

: function tep_db_connect($server = DB_SERVER, $username = DB_SERVER_USERNAME, $password = DB_SERVER_PASSWORD, $database = DB_DATABASE, $link = 'db_link') {
    global $$link;

    if (USE_PCONNECT == 'true') {
      $$link = mysql_pconnect($server, $username, $password);
    } else {
      $$link = mysql_connect($server, $username, $password);
    }

    if ($$link) mysql_select_db($database);

    return $$link;
  }

hope that helps

Share this post


Link to post
Share on other sites
A good start would be to check for errors when connecting or selecting the database.  In place of

[code]if ($$link) mysql_select_db($database);[/code]

put this:

[code]if (!$$link) die("Couldn't connect to database using server $server, username $username, database $database, link $link! " . mysql_error() . "\n");
if (!mysql_select_db($database)) die("Couldn't select database $database! " . mysql_error() . "\n");[/code]

That should give you an idea of why it's failing (if it is failing in that function)

Share this post


Link to post
Share on other sites
thx alot  btherl
when i placed the code you give me and ran the script it give me this

:
[b]    Couldn't select database osCommerce! Access denied for user 'user'@'localhost' to database 'oscommerce' [/b]

but you this isn't the database i put on the define data connection .

dtabase connection look like

// define our database connection
  define('DB_SERVER', 'localhost');
  define('DB_SERVER_USERNAME', 'user');
  define('DB_SERVER_PASSWORD', 'user');
==>>  define('DB_DATABASE', 'commerce_db');
  define('USE_PCONNECT', 'false');
  define('STORE_SESSIONS', '');
?>


so i went and change it ,  and now i am getting this

[b]Object not found!
The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again.

If you think this is a server error, please contact the webmaster.

Error 404[/b]

so help me again please .....

Share this post


Link to post
Share on other sites
thx alot  btherl
when i placed the code you give me and ran the script it give me this

:
    Couldn't select database osCommerce! Access denied for user 'user'@'localhost' to database 'oscommerce'

but you this isn't the database i put on the define data connection .

dtabase connection look like

// define our database connection
  define('DB_SERVER', 'localhost');
  define('DB_SERVER_USERNAME', 'user');
  define('DB_SERVER_PASSWORD', 'user');
==>>  define('DB_DATABASE', 'commerce_db');
  define('USE_PCONNECT', 'false');
  define('STORE_SESSIONS', '');
?>


so i went and change it ,  and now i am getting this

Object not found!
The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again.

If you think this is a server error, please contact the webmaster.

Error 404

so help me again please .....

Share this post


Link to post
Share on other sites

×

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.