Mysql Error Number 1046
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of no database selected mysql this site About Us Learn more about Stack Overflow the company Business Learn #1046 - no database selected import more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question
No Database Selected Php
x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up
No Database Selected Mysql Workbench Import
Error Number: 1046 No database selected - CodeIgniter up vote -1 down vote favorite When I load my model to run the sql file in codeigniter. I get a error saying no database selected but there is. The error occurs when I click my button to go to the next stage. It some how needs to load database first before load sql. Not to error 1046 (3d000) no database selected grant sure on how to make it work. if I refresh page it loads. Should not have to refresh page should be done as soon as click on button Error Error Number: 1046 No database selected CREATE TABLE `country` ( `country_id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(128) NOT NULL, `iso_code_2` varchar(2) NOT NULL, `iso_code_3` varchar(3) NOT NULL, `address_format` text NOT NULL, `postcode_required` tinyint(1) NOT NULL, `status` tinyint(1) NOT NULL DEFAULT ‘1’, PRIMARY KEY (`country_id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci; Filename: C:\xampp\htdocs\codeigniter\system\database\DB_driver.php Line Number: 330 On Controller $data['button_continue'] = $this->lang->line('button_continue'); $data['button_back'] = $this->lang->line('button_back'); if ($this->form_validation->run() == false) { $this->load->view('template/step_3', $data); } else { $this->load->model('install/model_install'); $this->model_install->database_install(); $this->model_install->database_connect(); $this->model_install->dump_sql(); redirect('step_4'); } Model public function dump_sql() { $file = APPPATH . 'modules/install/config/database.sql'; if (!file_exists($file)) { exit('Could not load sql file: ' . $file); } $lines = file($file); if ($lines) { $sql = ''; foreach($lines as $line) { if ($line && (substr($line, 0, 2) != '--') && (substr($line, 0, 1) != '#')) { $sql .= $line; if (preg_match('/;\s*$/', $line)) { $sql = str_replace("DROP TABLE IF EXISTS `", "DROP TABLE IF EXISTS `" . $this->input->post('dbprefix'), $sql); $sql = str_replace("CREATE TABLE IF NOT EXISTS `", "CREATE
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn
No Database Selected Codeigniter
more about Stack Overflow the company Business Learn more about hiring developers or no database selected mysql command line posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow no database selected mysqli Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Error Code 1046: No database Selected up vote 0 http://stackoverflow.com/questions/23842565/error-number-1046-no-database-selected-codeigniter down vote favorite I wrote a stored procedure (sp_archivev3) on MySQl Workbench which is as follows. Basically, Inserting values from one database to another. -- -------------------------------------------------------------------------------- -- Routine DDL -- Note: comments before and after the routine body will not be stored by the server -- -------------------------------------------------------------------------------- DELIMITER $$ CREATE DEFINER=`MailMe`@`%` PROCEDURE `sp_archivev3`() BEGIN INSERT INTO send.sgev3_archive(a_bi, b_vc, c_int, d_int, e_vc, f_vc, g_vc, h_vc, i_dt, j_vc, k_vc, l_vc, http://stackoverflow.com/questions/24190575/error-code-1046-no-database-selected m_dt, n_vch, o_bit) SELECT a_bi, b_vc, c_int, d_int, e_vc, f_vc, g_vc, h_vc, i_dt, j_vc, k_vc, l_vc, m_dt, n_vch, o_bit FROM send.sgev3 WHERE m_dt BETWEEN '2014-06-09' AND CURDATE(); END When I run call sp_archivev3(); , I get an error with an error code 1046: No database selected SELECT the default DB to be used by double-clicking its name in the SCHEMAS list in the sidebar. Please let me know what's wrong with my stored procedure. mysql stored-procedures share|improve this question asked Jun 12 '14 at 17:35 rocky 1101312 Is send the DB name or the table name? DB name should come first –Eran Jun 12 '14 at 17:43 send is a db name. –rocky Jun 12 '14 at 17:47 Then are you trying to copy data between different tables in the same DB? –Eran Jun 12 '14 at 17:49 Yes, that's correct. –rocky Jun 12 '14 at 17:53 add a comment| 1 Answer 1 active oldest votes up vote 3 down vote accepted The problem is that MySQL doesn't know which procedure named sp_archivev3 is supposed to be executed; MySQL doesn't know which database to look in. (Stored programs are objects in a specifi
Meyer Claus Meyer Pro Student 2,523 Points Problems with Mysql file (1046 - No database selected) Error SQL https://teamtreehouse.com/community/problems-with-mysql-file-1046-no-database-selected query: CREATE TABLE sizes ( id INT( 11 ) NOT NULL AUTO_INCREMENT , size VARCHAR( 32 ) COLLATE utf8_unicode_ci DEFAULT NULL , order INT( 11 ) NOT NULL , PRIMARY KEY ( id ) ) ENGINE = INNODB DEFAULT CHARSET = utf8 COLLATE = utf8_unicode_ci AUTO_INCREMENT =5; MySQL said: Documentation 1046 - No no database database selected No good, if you get problems just importing a file! Problem is that I cant write "Create table" 1 Answer Petros Sordinas 15,723 Points Petros Sordinas Petros Sordinas 15,723 Points about 2 years ago You have to tell SQL which database you are using Either : USE database_name; or if the database no database selected does not exist CREATE DATABASE database_name USE database_name; Claus Meyer Pro Student 2,523 Points Claus Meyer Claus Meyer Pro Student 2,523 Points 2y ago THANKS, I got it to work now... Oki, my database name is: movikcrewhunter USE movikcrewhunter; CREATE TABLE sizes ( id int(11) Posting to the forum is only allowed for members with active accounts. Please sign in or sign up to post. Our mission is to bring affordable, technology education to people everywhere, in order to help them achieve their dreams and change the world. Our Company About Us Contact Us Community Treehouse Stories Student Perks Treehouse Blog Affiliate Program Careers Topics HTML CSS Design JavaScript Ruby PHP WordPress iOS Android Development Tools Business Tracks Web Design Web Development Rails Development PHP Development iOS Development Android Development WordPress Development Starting a Business Treehouse Blog About Treehouse Privacy Policy Terms & Conditions © 2016 Treehouse Island, Inc. Sign in Email Address Password I forgot my password Sign in