+ Reply to Thread
Results 1 to 8 of 8

Thread: Database error

  1. #1
    onlinegamesnz is offline x10Hosting Member onlinegamesnz is an unknown quantity at this point
    Join Date
    May 2011
    Posts
    2

    Database error

    hi, i am trying to setup a login system and have setup a database with all tables in it, and info in the appropriate tables have been added. when i accesss the index and try login, the message "No database selected" shows.

    DB USER "customin_login"
    DB HOST "localhost"
    DB PASS "*****"
    DATABASE "customin_loginsystem"

    whereas customin is my username?

    Any ideas? the patch is as follows for live example

    http://custominterriors.x10.mx/Site/admin/

    Any help would be greatly appreciated
    Thanks

    PS MODS, forgive me if this is in the wrong place ;)

    also, i have the backend.class.php file in which the database attributes are edited, and then another backend.classs1.php, do i edit them both?
    Last edited by onlinegamesnz; 05-04-2011 at 05:12 AM.

  2. #2
    descalzo's Avatar
    descalzo is offline Grim Squeaker descalzo has a brilliant futuredescalzo has a brilliant futuredescalzo has a brilliant future
    Join Date
    Jul 2009
    Location
    Ankh-Morpork
    Posts
    7,636

    Re: Database error

    Something is wrong with your code.

    "No database selected"

    It is not refusing the connection, which would result in a different error message.
    Nothing is always absolutely so.

  3. #3
    onlinegamesnz is offline x10Hosting Member onlinegamesnz is an unknown quantity at this point
    Join Date
    May 2011
    Posts
    2

    Re: Database error

    heres my code. i have created a databse called loginsystem and imported a sql file with all tabkles in it.


    Code:
    <?
    // start session
    session_start();
    // set the PHP SETTINGS such that it does not use SESSIONS with COOKIE support
    ini_set("session.use_cookies",0);
    // defination of backEnd class
    class backEnd {
     // database settings
     var $DATABASE = 'customin_loginsystem';
     var $DB_HOST = 'localhost';
     var $DB_USER = 'customin_login';
     var $DB_PASS = '********';
     
     // other variables and arrays
     var $page_no = 1;
     var $no_of_rows = 2;
     var $admin_title = ".: Login System : Welcome to Administartion :.";
      var $client_title = ".: Welcome to Login System :."; 
     var $error_msg = "";
     var $host_path = "http://waheed/loginsystem/";
     var $array_roles = array(
       0 => "Administrator",
       1 => "Webmaster",
       2 => "User");
     // connect to MYSQL
     function _connect(){
       $db_handle = mysql_connect($this->DB_HOST, $this->DB_USER, $this->DB_PASS) or die(mysql_error());  
       mysql_select_db($this->DATABASE, $db_handle);
       return $db_handle;
     }
    Thanks again for the help
    Last edited by onlinegamesnz; 05-04-2011 at 07:01 PM.

  4. #4
    murtazrocks58 is offline Banned murtazrocks58 is an unknown quantity at this point
    Join Date
    Nov 2010
    Location
    Godhra
    Posts
    65

    Re: Database error

    There is an error in the code

    Try to preceed the database name with your user name
    and also the password

  5. #5
    bidzey75's Avatar
    bidzey75 is offline x10Hosting Member bidzey75 is an unknown quantity at this point
    Join Date
    Apr 2011
    Posts
    51

    Re: Database error

    I think using a class for a MySql connection is an overkill, but since we cant see all of it maybe it does more. This is not all of the code, is it? The code here is declaring the class (with missing parts). If you want to use it you have to initiate it into a variable. like this:

    Code:
    class Foo {
        function Foo($init_parameter) {
            $this->some_parameter = $init_parameter;
        }
    }
    
    // initiate code:
    
    $foo = new Foo("some init value");

  6. #6
    murtazrocks58 is offline Banned murtazrocks58 is an unknown quantity at this point
    Join Date
    Nov 2010
    Location
    Godhra
    Posts
    65

    Re: Database error

    Try to preceed the database name with your user name

  7. #7
    Interscopia's Avatar
    Interscopia is offline x10 Caffeine Addict Interscopia is an unknown quantity at this point
    Join Date
    May 2011
    Location
    England
    Posts
    174

    Re: Database error

    Quote Originally Posted by murtazrocks58 View Post
    Try to preceed the database name with your user name
    This should work.

  8. #8
    vv.bbcc19's Avatar
    vv.bbcc19 is offline Community Advocate vv.bbcc19 is just really nice
    Join Date
    Jun 2010
    Location
    India
    Posts
    1,505

    Re: Database error

    Ahah..currently the site is working.Nice tutorials dear members.
    What does the site intend to do anyways?

+ Reply to Thread

Similar Threads

  1. Replies: 1
    Last Post: 10-12-2010, 12:17 PM
  2. Database Error: Unable to connect to the database
    By paolix77 in forum Free Hosting
    Replies: 1
    Last Post: 04-26-2010, 10:38 PM
  3. Replies: 5
    Last Post: 04-25-2010, 04:02 PM
  4. Replies: 1
    Last Post: 04-17-2010, 12:26 PM
  5. Replies: 1
    Last Post: 11-23-2008, 04:36 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers