Jump to content
xisto Community
Sign in to follow this  
iGuest

MySQL Error 1046

Recommended Posts

Anyone know how to get rid of this f***ing thing? I've got all my config set right, it can connect to the database, but when I try to select the damn database it gives me this:

MySQL Error: 1046 No Database Selected

Here's the code for my database class, which I use to process all my database activity. I've got it writing to a log, which says that it connects to the database correctly, but won't select the database.

<?phprequire_once("config.php");class database {    var $handle;    var $db;    var $result;    var $config;    function database() {@       $this->handle = mysql_pconnect($mysql_host, $mysql_user, $mysql_pass);        $log = fopen("log.txt",'a');        if(!$this->handle) {            fwrite($log,"Error: Could Not Connect to MySQL Database!nMySQL Error:n".mysql_errno()." ".mysql_error()."nnn");            fclose($log);            die("Error: Could Not Connect to MySQL Database!nMySQL Error:n".mysql_errno()." ".mysql_error());        }        else {            fwrite($log, "Connected to MySQL Database Successfully!");        }@       $this->db = mysql_select_db($mysql_dbname, $this->handle);        if(!$this->db) {            fwrite($log,"Error: Could not select Database!nMySQL Error:n".mysql_errno()." ".mysql_error()."nn");            fclose($log);            die("Error: Could not select Database!nMySQL Error:n".mysql_errno()." ".mysql_error()."nn");        }        else {            fwrite($log,"Selected MySQL Database Successfully!");        }    }    function query($query) {        @$result = mysql_query($query,$this->handle);        $log = fopen("log.txt",'a');        if(!$result) {            fwrite($log,"Error: Query was not executed!nQuery: ".$query."nMysql Error:n".mysql_errno().": ".mysql_error()."nn");            fclose($log);            echo "Non-critical Error: Query was not executed!nQuery: ".$query."nMysql Error:n".mysql_errno().": ".mysql_error()."nn";            return false;        }        else {            fwrite($log,"Query Executed Successfully!nQuery: ".$query."nn");            fclose($log);            $this->result = $result;        }    }    function getconfig() {        if(empty($this->config)) {            $result = $this->query("SELECT title, url, theme FROM config");            if($result) {                $this->config = mysql_fetch_array($result, MYSQL_ASSOC);                return $this->config;            }            else {                $this->config = false;                return $this->config;            }        }        else {            return $this->config;        }    }}?>

I know the database exists, and I've got the right user set, but it still won't work!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | 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.