0

In my local test environment, I uploaded information to tables using POST data no problem. I'm doing some testing on a live domain now on my host's servers, and am getting an error when using the same techniques.

The table is called User_Information, and I know it exists by checking phpMyAdmin. It was created using script.

Here in brief is the code being used to insert information to the table, using CodeIgniter framework. This is a summary, and am certain that the syntax of the true code is fine:

['database' library is already autoloaded and connected]

$first = $this->input->post('firstname');
$last = $this->input->post('lastname');
$email = $this->input->post('email');
$city = $this->input->post('city');
$state = $this->input->post('state');

$insert = array(
                    'First_Name' => $first,
                    'Last_Name' => $last,
                    'Email' => $email,
                    'etc' => $etc,
                );

$this->db->insert('User_Information', $insert);

And the error being thrown:

Error Number: 1146

Table 'myDatabase.sqUser_Information' doesn't exist

INSERT INTO `sqUser_Information` (`First_Name`, `Last_Name`, `Email`, `etc`) 
    VALUES ('Leonhard', 'Euler', 'Elias@euler.com', 'Select One')

Filename: models/Process_form.php

Line Number: 56

The issue is the value getting submitted for the table name -- from the error, it looks like it is looking for a table called sqUser_Information instead of the provided User_Information. I don't know where the 'sq' is coming from, or why it is getting prepended to my table, nor have I yet been able to find other similar situations online.

I would like to be able to access and insert data into my table, but cannot do so at the moment because of this faulty name being passed.

Any suggestions?

Naltroc
  • 989
  • 1
  • 14
  • 34
  • Possible duplicate of [Code igniter prepending db prefix in table aliases](http://stackoverflow.com/questions/10548950/code-igniter-prepending-db-prefix-in-table-aliases) – Ibu Jan 26 '17 at 20:52

1 Answers1

1

In Codeigniter, you are allowed to set a database table prefix. Check the file application/config/database.php and check the setting $db['default']['dbprefix']

Just delete the field and make sure it looks like

$db['default']['dbprefix'] = '';

You can read more about codeigniter database configuration here.

If the field is already set to an empty string, it's possible you mistyped it when you created the table. Hope this helps.

Wold
  • 952
  • 1
  • 13
  • 25