Jump to content

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
Link to comment
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
Link to comment
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)
Link to comment
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 .....
Link to comment
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 .....
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.