Welcome Guest, Not a member yet? Register   Sign In
Error code 1054: Can't figure out why I'm getting this
#1

[eluser]dallen33[/eluser]
Here is my code:
Code:
<?php
    $clients_query = $this->mobile_db->get_where('clients', array('rep_id' => $this->dx_auth->get_user_id()));
    
    if ($clients_query->num_rows() > 0):

    foreach($clients_query->result() as $clients_row):
?>

And here's the error:
Quote:A Database Error Occurred
Error Number: 1054
Unknown column 'rep_id' in 'where clause'
SELECT * FROM (`clients`) WHERE `rep_id` = '3'

I don't understand what's so wrong about the database code. what am I missing?
#2

[eluser]jalalski[/eluser]
it's telling you that there is no column called 'rep_id' in the table 'clients'. Double check that there is such a column...
#3

[eluser]dallen33[/eluser]
There definitely is a column called rep_id in clients. Triple checked.
#4

[eluser]dallen33[/eluser]
I figured out the problem, but can't figure out a solution.

I have two databases I'm working with, and both have a clients table. One doesn't have a rep_id, one does. In my controller, I put this under the parent::Controller();
Code:
$this->mobile_db = $this->load->database('mobile_booking', TRUE);

And this is the code in my view:
Code:
<?php
    $clients_query = $this->mobile_db->get_where('client', array('rep_id' => $this->dx_auth->get_user_id()));
    
    if ($clients_query->num_rows() > 0):

    foreach($clients_query->result() as $clients_row):
?>
Is my database load in the wrong spot?




Theme © iAndrew 2016 - Forum software by © MyBB