Welcome Guest, Not a member yet? Register   Sign In
CI MYSQL problem
#1

[eluser]joeizang[/eluser]
hi guys,

I have a really strange one to ask so please any help will do

I am designing a site with login form drawing users from a database called for example tlc and has a table called tlcusers
I have set the database.php file in config to reflect my username and password and the selected the tlc db appropriately and
have inserted a dumy account in. when I try to login, it says:


A Database Error Occurred

Error Number: 1146

Table 'tlc.tlcuser' doesn't exist

SELECT * FROM (`tlcuser`) WHERE `username` = 'smith' AND `password` = 'aa91fc1ac0ebf2ca623f48e99ac2bb31f0675d72'

I honestly don't get it. the table is there and my model for this table only deals with the login and logout.

The problem is not CI ( I think) but y'allwill need to help a brother out.

God bless
#2

[eluser]InsiteFX[/eluser]
If you want help you need to post your code so we can look at it to see what is wrong.

Enjoy
InsiteFX
#3

[eluser]joeizang[/eluser]
ok guys my bad,

I will post my model for the login and the controller right well here they are:

class Login_model extends Model
{

function selectuser()
{
$this->db->where('username',$this->input->post('username'));
$this->db->where('password',sha1($this->input->post('password')));
$query = $this->db->get('tlcuser');

if($query->num_rows == 1)
{
return true;
}
}
}



CONTROLLER FOR LOGIN HERE:


class Login extends Controller
{
var $base;
var $css;
var $images;

function Login()
{
parent::Controller();
$this->base = $this->config->item('base_url');
$this->css = $this->config->item('css');
$this->images = $this->config->item('images');
$this->load->library('form_validation');
$this->load->model('login_model');
}

function index()
{
$data['main_content'] = 'loginfiles/login_view';
$data['base'] = $this->base;
$data['css'] = $this->css;
$data['images'] = $this->images;
$this->load->view('includes/template', $data);
}

function loginuser()
{
$query = $this->login_model->selectuser();

if($query)
{
$data = array(
'username' => $this->input->post('username'),
'authorized' => true
);
$this->session->set_userdata($data);
redirect('editors/index');
//$this->mainpage();
} else {
$this->index();
}
}
}


i hope this is of help in resolving this
#4

[eluser]InsiteFX[/eluser]
Our you loading the CodeIgniter database?

If not you can autoload it in the config.php file along with others.

Also when submitting your code use the code tags.

Enjoy
InnsiteFX
#5

[eluser]BrianDHall[/eluser]
I think it will likely end up being a problem with your database.php file or your db schema. Perhaps export your db schema and post the "create" portion so we can see the schema, and your password-removed database.php file.
#6

[eluser]joeizang[/eluser]
ok guys sorry about the errors in copying the code. I hope it's worth mentioning that I used phpmyadmin to create the database but here is the schema and the database php files:

database.php:

<?php


$active_group = "default";
$active_record = TRUE;

$db['default']['hostname'] = "localhost";
$db['default']['username'] = "root";
$db['default']['password'] = "root";
$db['default']['database'] = "tlc";
$db['default']['dbdriver'] = "mysql";
$db['default']['dbprefix'] = "";
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = "";
$db['default']['char_set'] = "utf8";
$db['default']['dbcollat'] = "utf8_general_ci";
?>

mysql schema:

SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;

--
-- Database: `tlc`
--
CREATE DATABASE `tlc` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;
USE `tlc`;

-- --------------------------------------------------------

--
-- Table structure for table `tlcusers`
--

CREATE TABLE IF NOT EXISTS `tlcusers` (
`user_id` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(20) NOT NULL,
`password` varchar(100) NOT NULL,
PRIMARY KEY (`user_id`),
UNIQUE KEY `username` (`username`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;

--
-- Dumping data for table `tlcusers`
--

INSERT INTO `tlcusers` (`user_id`, `username`, `password`) VALUES
(1, 'johndoe', 'aa91fc1ac0ebf2ca623f48e99ac2bb31f0675d72');

Hope this helps. sorry for all the trouble guys. thanks
#7

[eluser]n0xie[/eluser]
Ahum...

Code:
SELECT * FROM (`tlcuser`) ...

Code:
CREATE TABLE IF NOT EXISTS `tlcusers`
#8

[eluser]joeizang[/eluser]
sorry n0xie,

can you elaborate a little with the highlighting you did. like I said before I used phpmyadmin like i have done for all of my mysql related tasks. if there is something what is it and what do i do. pleeeeaaaseeee!!!!!


God bless
#9

[eluser]colo99[/eluser]
In case you haven't already fixed this.

Quote:A Database Error Occurred
Error Number: 1146
Table ‘tlc.tlcuser’ doesn’t exist

Well what n0xie wanted to say is, that your table name is tlc.tlcusers and you are trying to make a select statement on tlc.tlcuser

You got the table name just wrong.
#10

[eluser]joeizang[/eluser]
This is so embarrassing, I was just missing an 's'! Well I have learned a lesson, never code for long hours without a break.

Thanks y'all for all the effort. :cheese:




Theme © iAndrew 2016 - Forum software by © MyBB