No database selected in codeigniter Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) Data science time! April 2019 and salary with experience Should we burninate the [wrap] tag? The Ask Question Wizard is Live!How should I choose an authentication library for CodeIgniter?Fatal Error: Allowed Memory Size of 134217728 Bytes Exhausted (CodeIgniter + XML-RPC)Trouble changing databases for my models in codeigniterCodeIgniter Upload and Resize ProblemCannot connect to SQL Server 2012 from codeigniter 2.1.4upgrading from php 5.3 to php 5.5 showing connection errorMultiple database- access data from the 3rd database using codeigniterStoring Variables in Database classDebugging “Unable to connect to your database server using the provided settings” in CodeIgniterCodeigniter Can't Connect to External SQL Server
Single word antonym of "flightless"
Seeking colloquialism for “just because”
What causes the vertical darker bands in my photo?
What is the logic behind the Maharil's explanation of why we don't say שעשה ניסים on Pesach?
Should I use a zero-interest credit card for a large one-time purchase?
What is Wonderstone and are there any references to it pre-1982?
What does this icon in iOS Stardew Valley mean?
Extract all GPU name, model and GPU ram
The logistics of corpse disposal
How to react to hostile behavior from a senior developer?
How to answer "Have you ever been terminated?"
Storing hydrofluoric acid before the invention of plastics
Short Story with Cinderella as a Voo-doo Witch
At the end of Thor: Ragnarok why don't the Asgardians turn and head for the Bifrost as per their original plan?
What is a non-alternating simple group with big order, but relatively few conjugacy classes?
Withdrew £2800, but only £2000 shows as withdrawn on online banking; what are my obligations?
3 doors, three guards, one stone
Resolving to minmaj7
How to find out what spells would be useless to a blind NPC spellcaster?
Using audio cues to encourage good posture
If a contract sometimes uses the wrong name, is it still valid?
Do I really need recursive chmod to restrict access to a folder?
Is it ethical to give a final exam after the professor has quit before teaching the remaining chapters of the course?
Is it true that "carbohydrates are of no use for the basal metabolic need"?
No database selected in codeigniter
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
Data science time! April 2019 and salary with experience
Should we burninate the [wrap] tag?
The Ask Question Wizard is Live!How should I choose an authentication library for CodeIgniter?Fatal Error: Allowed Memory Size of 134217728 Bytes Exhausted (CodeIgniter + XML-RPC)Trouble changing databases for my models in codeigniterCodeIgniter Upload and Resize ProblemCannot connect to SQL Server 2012 from codeigniter 2.1.4upgrading from php 5.3 to php 5.5 showing connection errorMultiple database- access data from the 3rd database using codeigniterStoring Variables in Database classDebugging “Unable to connect to your database server using the provided settings” in CodeIgniterCodeigniter Can't Connect to External SQL Server
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I have made this function to take values from the form and overwrite the config/database.php.
function configure_database()
// write database.php
$data_db = file_get_contents('./uploads/database.php');
// session_start();
$data_db = str_replace('%DATABASE%', $_SESSION['dbname'], $data_db);
$data_db = str_replace('%USERNAME%', $_SESSION['username'], $data_db);
$data_db = str_replace('%PASSWORD%', $_SESSION['password'], $data_db);
$data_db = str_replace('%HOSTNAME%', $_SESSION['hostname'], $data_db);
file_put_contents('./application/config/database.php', $data_db);
$this->run_blank_sql();
and it successfully overwrites
the config/database.php
. at the last of the function
I have written the $this->run_blank_sql();
which calls the run_blank_sql()
I have written this function
to run the SQL
in uploads
directory.
function run_blank_sql()
$this->load->database();
// Set line to collect lines that wrap
$templine = '';
// Read in entire file
$lines = file('./uploads/install.sql');
// Loop through each line
foreach ($lines as $line)
// Skip it if it's a comment
if (substr($line, 0, 2) == '--'
But it gives me that error.
the configure_database()
overwrites these values successfully.
'hostname' => '%HOSTNAME%',
'username' => '%USERNAME%',
'password' => '%PASSWORD%',
'database' => '%DATABASE%',
'dbdriver' => 'mysqli',
To
'hostname' => 'localhost',
'username' => 'root',
'password' => *****,
'database' => 'studentPortal',
'dbdriver' => 'mysqli',
php codeigniter
|
show 5 more comments
I have made this function to take values from the form and overwrite the config/database.php.
function configure_database()
// write database.php
$data_db = file_get_contents('./uploads/database.php');
// session_start();
$data_db = str_replace('%DATABASE%', $_SESSION['dbname'], $data_db);
$data_db = str_replace('%USERNAME%', $_SESSION['username'], $data_db);
$data_db = str_replace('%PASSWORD%', $_SESSION['password'], $data_db);
$data_db = str_replace('%HOSTNAME%', $_SESSION['hostname'], $data_db);
file_put_contents('./application/config/database.php', $data_db);
$this->run_blank_sql();
and it successfully overwrites
the config/database.php
. at the last of the function
I have written the $this->run_blank_sql();
which calls the run_blank_sql()
I have written this function
to run the SQL
in uploads
directory.
function run_blank_sql()
$this->load->database();
// Set line to collect lines that wrap
$templine = '';
// Read in entire file
$lines = file('./uploads/install.sql');
// Loop through each line
foreach ($lines as $line)
// Skip it if it's a comment
if (substr($line, 0, 2) == '--'
But it gives me that error.
the configure_database()
overwrites these values successfully.
'hostname' => '%HOSTNAME%',
'username' => '%USERNAME%',
'password' => '%PASSWORD%',
'database' => '%DATABASE%',
'dbdriver' => 'mysqli',
To
'hostname' => 'localhost',
'username' => 'root',
'password' => *****,
'database' => 'studentPortal',
'dbdriver' => 'mysqli',
php codeigniter
you have plenty of code here but I don't see the rows that are causing the error. Post the relevant code please
– Lelio Faieta
Mar 22 at 9:14
Ok. Simply look at this function run_blank_sql(). in this $this->load->database(); not working here. I want to Install SQL which will create the table in DB but it says no DB selected.
– Waqas Ahmad
Mar 22 at 9:16
You need to read codeigniter.com/user_guide/database/… - you can pass an array of config options and then load the database. I think you're trying to amend the config file which is not the correct way of doing it.
– Antony
Mar 22 at 9:19
$data_db = str_replace('%DATABASE%', $_SESSION['dbname'], $data_db); Add a log and see $data_db the variable that you've overwritten.
– Harshana
Mar 22 at 9:19
@Harshana it successfully overwrites the DB name in the config/database.php.
– Waqas Ahmad
Mar 22 at 9:38
|
show 5 more comments
I have made this function to take values from the form and overwrite the config/database.php.
function configure_database()
// write database.php
$data_db = file_get_contents('./uploads/database.php');
// session_start();
$data_db = str_replace('%DATABASE%', $_SESSION['dbname'], $data_db);
$data_db = str_replace('%USERNAME%', $_SESSION['username'], $data_db);
$data_db = str_replace('%PASSWORD%', $_SESSION['password'], $data_db);
$data_db = str_replace('%HOSTNAME%', $_SESSION['hostname'], $data_db);
file_put_contents('./application/config/database.php', $data_db);
$this->run_blank_sql();
and it successfully overwrites
the config/database.php
. at the last of the function
I have written the $this->run_blank_sql();
which calls the run_blank_sql()
I have written this function
to run the SQL
in uploads
directory.
function run_blank_sql()
$this->load->database();
// Set line to collect lines that wrap
$templine = '';
// Read in entire file
$lines = file('./uploads/install.sql');
// Loop through each line
foreach ($lines as $line)
// Skip it if it's a comment
if (substr($line, 0, 2) == '--'
But it gives me that error.
the configure_database()
overwrites these values successfully.
'hostname' => '%HOSTNAME%',
'username' => '%USERNAME%',
'password' => '%PASSWORD%',
'database' => '%DATABASE%',
'dbdriver' => 'mysqli',
To
'hostname' => 'localhost',
'username' => 'root',
'password' => *****,
'database' => 'studentPortal',
'dbdriver' => 'mysqli',
php codeigniter
I have made this function to take values from the form and overwrite the config/database.php.
function configure_database()
// write database.php
$data_db = file_get_contents('./uploads/database.php');
// session_start();
$data_db = str_replace('%DATABASE%', $_SESSION['dbname'], $data_db);
$data_db = str_replace('%USERNAME%', $_SESSION['username'], $data_db);
$data_db = str_replace('%PASSWORD%', $_SESSION['password'], $data_db);
$data_db = str_replace('%HOSTNAME%', $_SESSION['hostname'], $data_db);
file_put_contents('./application/config/database.php', $data_db);
$this->run_blank_sql();
and it successfully overwrites
the config/database.php
. at the last of the function
I have written the $this->run_blank_sql();
which calls the run_blank_sql()
I have written this function
to run the SQL
in uploads
directory.
function run_blank_sql()
$this->load->database();
// Set line to collect lines that wrap
$templine = '';
// Read in entire file
$lines = file('./uploads/install.sql');
// Loop through each line
foreach ($lines as $line)
// Skip it if it's a comment
if (substr($line, 0, 2) == '--'
But it gives me that error.
the configure_database()
overwrites these values successfully.
'hostname' => '%HOSTNAME%',
'username' => '%USERNAME%',
'password' => '%PASSWORD%',
'database' => '%DATABASE%',
'dbdriver' => 'mysqli',
To
'hostname' => 'localhost',
'username' => 'root',
'password' => *****,
'database' => 'studentPortal',
'dbdriver' => 'mysqli',
php codeigniter
php codeigniter
edited Mar 22 at 9:12
Daniel E.
2,19011024
2,19011024
asked Mar 22 at 9:07
Waqas AhmadWaqas Ahmad
19913
19913
you have plenty of code here but I don't see the rows that are causing the error. Post the relevant code please
– Lelio Faieta
Mar 22 at 9:14
Ok. Simply look at this function run_blank_sql(). in this $this->load->database(); not working here. I want to Install SQL which will create the table in DB but it says no DB selected.
– Waqas Ahmad
Mar 22 at 9:16
You need to read codeigniter.com/user_guide/database/… - you can pass an array of config options and then load the database. I think you're trying to amend the config file which is not the correct way of doing it.
– Antony
Mar 22 at 9:19
$data_db = str_replace('%DATABASE%', $_SESSION['dbname'], $data_db); Add a log and see $data_db the variable that you've overwritten.
– Harshana
Mar 22 at 9:19
@Harshana it successfully overwrites the DB name in the config/database.php.
– Waqas Ahmad
Mar 22 at 9:38
|
show 5 more comments
you have plenty of code here but I don't see the rows that are causing the error. Post the relevant code please
– Lelio Faieta
Mar 22 at 9:14
Ok. Simply look at this function run_blank_sql(). in this $this->load->database(); not working here. I want to Install SQL which will create the table in DB but it says no DB selected.
– Waqas Ahmad
Mar 22 at 9:16
You need to read codeigniter.com/user_guide/database/… - you can pass an array of config options and then load the database. I think you're trying to amend the config file which is not the correct way of doing it.
– Antony
Mar 22 at 9:19
$data_db = str_replace('%DATABASE%', $_SESSION['dbname'], $data_db); Add a log and see $data_db the variable that you've overwritten.
– Harshana
Mar 22 at 9:19
@Harshana it successfully overwrites the DB name in the config/database.php.
– Waqas Ahmad
Mar 22 at 9:38
you have plenty of code here but I don't see the rows that are causing the error. Post the relevant code please
– Lelio Faieta
Mar 22 at 9:14
you have plenty of code here but I don't see the rows that are causing the error. Post the relevant code please
– Lelio Faieta
Mar 22 at 9:14
Ok. Simply look at this function run_blank_sql(). in this $this->load->database(); not working here. I want to Install SQL which will create the table in DB but it says no DB selected.
– Waqas Ahmad
Mar 22 at 9:16
Ok. Simply look at this function run_blank_sql(). in this $this->load->database(); not working here. I want to Install SQL which will create the table in DB but it says no DB selected.
– Waqas Ahmad
Mar 22 at 9:16
You need to read codeigniter.com/user_guide/database/… - you can pass an array of config options and then load the database. I think you're trying to amend the config file which is not the correct way of doing it.
– Antony
Mar 22 at 9:19
You need to read codeigniter.com/user_guide/database/… - you can pass an array of config options and then load the database. I think you're trying to amend the config file which is not the correct way of doing it.
– Antony
Mar 22 at 9:19
$data_db = str_replace('%DATABASE%', $_SESSION['dbname'], $data_db); Add a log and see $data_db the variable that you've overwritten.
– Harshana
Mar 22 at 9:19
$data_db = str_replace('%DATABASE%', $_SESSION['dbname'], $data_db); Add a log and see $data_db the variable that you've overwritten.
– Harshana
Mar 22 at 9:19
@Harshana it successfully overwrites the DB name in the config/database.php.
– Waqas Ahmad
Mar 22 at 9:38
@Harshana it successfully overwrites the DB name in the config/database.php.
– Waqas Ahmad
Mar 22 at 9:38
|
show 5 more comments
2 Answers
2
active
oldest
votes
It says clearly in
that No Database Selected
I think, You need to specify
$db['default']['database'] = "YOUR_DB";
in /application/config/database.php
DB is successfully connected. but this statement not working $this->load->database();
– Waqas Ahmad
Mar 22 at 14:43
what is the error now? @JohnDoe
– Josua Marcel Chrisano
Mar 23 at 8:07
In application/config/autoload.php add this : $autoload['libraries'] = array('database'); // add database in array
– Josua Marcel Chrisano
Mar 23 at 8:18
add a comment |
Wherever you are running the drop
(I don't see that in your code) is the problem. You're dropping a table but are not specifying the schema where that table is.
Even if you have only one table called category
you need to be specific about what schema it lives in. Change your drop
statement to be: drop table schema.category
.
This hasn't got anything to do with the $db['default']['database'] = "YOUR_DB";
in the configuration. It's just standard SQL
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55296163%2fno-database-selected-in-codeigniter%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
It says clearly in
that No Database Selected
I think, You need to specify
$db['default']['database'] = "YOUR_DB";
in /application/config/database.php
DB is successfully connected. but this statement not working $this->load->database();
– Waqas Ahmad
Mar 22 at 14:43
what is the error now? @JohnDoe
– Josua Marcel Chrisano
Mar 23 at 8:07
In application/config/autoload.php add this : $autoload['libraries'] = array('database'); // add database in array
– Josua Marcel Chrisano
Mar 23 at 8:18
add a comment |
It says clearly in
that No Database Selected
I think, You need to specify
$db['default']['database'] = "YOUR_DB";
in /application/config/database.php
DB is successfully connected. but this statement not working $this->load->database();
– Waqas Ahmad
Mar 22 at 14:43
what is the error now? @JohnDoe
– Josua Marcel Chrisano
Mar 23 at 8:07
In application/config/autoload.php add this : $autoload['libraries'] = array('database'); // add database in array
– Josua Marcel Chrisano
Mar 23 at 8:18
add a comment |
It says clearly in
that No Database Selected
I think, You need to specify
$db['default']['database'] = "YOUR_DB";
in /application/config/database.php
It says clearly in
that No Database Selected
I think, You need to specify
$db['default']['database'] = "YOUR_DB";
in /application/config/database.php
answered Mar 22 at 10:41
Josua Marcel ChrisanoJosua Marcel Chrisano
3,62243780
3,62243780
DB is successfully connected. but this statement not working $this->load->database();
– Waqas Ahmad
Mar 22 at 14:43
what is the error now? @JohnDoe
– Josua Marcel Chrisano
Mar 23 at 8:07
In application/config/autoload.php add this : $autoload['libraries'] = array('database'); // add database in array
– Josua Marcel Chrisano
Mar 23 at 8:18
add a comment |
DB is successfully connected. but this statement not working $this->load->database();
– Waqas Ahmad
Mar 22 at 14:43
what is the error now? @JohnDoe
– Josua Marcel Chrisano
Mar 23 at 8:07
In application/config/autoload.php add this : $autoload['libraries'] = array('database'); // add database in array
– Josua Marcel Chrisano
Mar 23 at 8:18
DB is successfully connected. but this statement not working $this->load->database();
– Waqas Ahmad
Mar 22 at 14:43
DB is successfully connected. but this statement not working $this->load->database();
– Waqas Ahmad
Mar 22 at 14:43
what is the error now? @JohnDoe
– Josua Marcel Chrisano
Mar 23 at 8:07
what is the error now? @JohnDoe
– Josua Marcel Chrisano
Mar 23 at 8:07
In application/config/autoload.php add this : $autoload['libraries'] = array('database'); // add database in array
– Josua Marcel Chrisano
Mar 23 at 8:18
In application/config/autoload.php add this : $autoload['libraries'] = array('database'); // add database in array
– Josua Marcel Chrisano
Mar 23 at 8:18
add a comment |
Wherever you are running the drop
(I don't see that in your code) is the problem. You're dropping a table but are not specifying the schema where that table is.
Even if you have only one table called category
you need to be specific about what schema it lives in. Change your drop
statement to be: drop table schema.category
.
This hasn't got anything to do with the $db['default']['database'] = "YOUR_DB";
in the configuration. It's just standard SQL
add a comment |
Wherever you are running the drop
(I don't see that in your code) is the problem. You're dropping a table but are not specifying the schema where that table is.
Even if you have only one table called category
you need to be specific about what schema it lives in. Change your drop
statement to be: drop table schema.category
.
This hasn't got anything to do with the $db['default']['database'] = "YOUR_DB";
in the configuration. It's just standard SQL
add a comment |
Wherever you are running the drop
(I don't see that in your code) is the problem. You're dropping a table but are not specifying the schema where that table is.
Even if you have only one table called category
you need to be specific about what schema it lives in. Change your drop
statement to be: drop table schema.category
.
This hasn't got anything to do with the $db['default']['database'] = "YOUR_DB";
in the configuration. It's just standard SQL
Wherever you are running the drop
(I don't see that in your code) is the problem. You're dropping a table but are not specifying the schema where that table is.
Even if you have only one table called category
you need to be specific about what schema it lives in. Change your drop
statement to be: drop table schema.category
.
This hasn't got anything to do with the $db['default']['database'] = "YOUR_DB";
in the configuration. It's just standard SQL
answered Mar 22 at 13:14
Javier LarrouletJavier Larroulet
1,5391521
1,5391521
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55296163%2fno-database-selected-in-codeigniter%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
you have plenty of code here but I don't see the rows that are causing the error. Post the relevant code please
– Lelio Faieta
Mar 22 at 9:14
Ok. Simply look at this function run_blank_sql(). in this $this->load->database(); not working here. I want to Install SQL which will create the table in DB but it says no DB selected.
– Waqas Ahmad
Mar 22 at 9:16
You need to read codeigniter.com/user_guide/database/… - you can pass an array of config options and then load the database. I think you're trying to amend the config file which is not the correct way of doing it.
– Antony
Mar 22 at 9:19
$data_db = str_replace('%DATABASE%', $_SESSION['dbname'], $data_db); Add a log and see $data_db the variable that you've overwritten.
– Harshana
Mar 22 at 9:19
@Harshana it successfully overwrites the DB name in the config/database.php.
– Waqas Ahmad
Mar 22 at 9:38