the apprentice webmaster Posted September 20, 2006 Share Posted September 20, 2006 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 selectedselect 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 Quote Link to comment Share on other sites More sharing options...
btherl Posted September 20, 2006 Share Posted September 20, 2006 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() ? Quote Link to comment Share on other sites More sharing options...
the apprentice webmaster Posted September 20, 2006 Author Share Posted September 20, 2006 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 Quote Link to comment Share on other sites More sharing options...
btherl Posted September 20, 2006 Share Posted September 20, 2006 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) Quote Link to comment Share on other sites More sharing options...
the apprentice webmaster Posted September 20, 2006 Author Share Posted September 20, 2006 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 ..... Quote Link to comment Share on other sites More sharing options...
the apprentice webmaster Posted September 21, 2006 Author Share Posted September 21, 2006 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 ..... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.