Jump to content


Photo

can anyone help ( database connection issue )


  • Please log in to reply
5 replies to this topic

#1 the apprentice webmaster

the apprentice webmaster
  • Members
  • PipPipPip
  • Advanced Member
  • 65 posts

Posted 20 September 2006 - 05:52 AM

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


#2 btherl

btherl
  • Staff Alumni
  • Advanced Member
  • 3,893 posts
  • LocationAustralia

Posted 20 September 2006 - 06:08 AM

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() ?

#3 the apprentice webmaster

the apprentice webmaster
  • Members
  • PipPipPip
  • Advanced Member
  • 65 posts

Posted 20 September 2006 - 06:17 AM

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

#4 btherl

btherl
  • Staff Alumni
  • Advanced Member
  • 3,893 posts
  • LocationAustralia

Posted 20 September 2006 - 07:45 AM

A good start would be to check for errors when connecting or selecting the database.  In place of

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

put this:

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");

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

#5 the apprentice webmaster

the apprentice webmaster
  • Members
  • PipPipPip
  • Advanced Member
  • 65 posts

Posted 20 September 2006 - 08:04 AM

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 .....


#6 the apprentice webmaster

the apprentice webmaster
  • Members
  • PipPipPip
  • Advanced Member
  • 65 posts

Posted 21 September 2006 - 05:55 AM

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 .....





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users