Welcome Guest ( Log In | Register)



 
Reply to this topicStart new topic
> MySQL Error 1046
God
post Jan 30 2005, 08:28 PM
Post #1





Guests






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

CODE
<?php

require_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!
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Os X Mysql Problem(0)
  2. Mysql Hacks(6)
  3. Beginning Php And Mysql: From Novice To Professional, Third Edition Review(1)
  4. Psp Error- Tut On How To Fix(32)
  5. Error E74? (xbox 360)(12)
  6. Mysql Downtimes...(39)
  7. Mysql Won't Update(5)
  8. How To Connect Mysql With Jsp ?(4)
  9. Email Error Ends Up On Welsh Road Sign(1)
  10. Getting Php Error On Oscommerce(3)
  11. Can You Add Images Into A Mysql Database?(21)
  12. Vb And Mysql(3)
  13. Php Myadmin(6)
  14. Linking To Mysql From Vb(7)
  15. Ips Driver Error(2)
  1. Website Structure(3)
  2. Mccodes With Mysql! [resolved](6)
  3. Mysql Server Down(10)
  4. ---> Ftp Error Codes What They Mean <---(5)
  5. Help Moving Mysql Files To A New Host(2)
  6. Need Advice On Setting Up Mysql Database.(4)
  7. Error Installing Template In Joomla! 1.5.7(0)
  8. Flex Error #1034: Type Coercion Failed: Cannot Convert Mx.managers(1)
  9. Actionscript 3 & Xml Error #1010(0)
  10. An XSL Transform Error(2)
  11. Quick Question(10)
  12. Linux/ Apache /mod_rewrite Issue(4)
  13. Mysql Database Size(7)
  14. Connection Error 800a0e7a On Win Server 2003 X64(1)
  15. Import From Excel File Into Mysql Database(11)


 



- Lo-Fi Version Time is now: 22nd November 2008 - 04:32 PM