A Database Error Occurred Error Number: 1054

Posted on

A Database Error Occurred Error Number: 1054 – This article will take you through the common SQL errors that you might encounter while working with sql, codeigniter,  function. The wrong arrangement of keywords will certainly cause an error, but wrongly arranged commands may also be an issue. SQL keyword errors occur when one of the words that the SQL query language reserves for its commands and clauses is misspelled. If the user wants to resolve all these reported errors, without finding the original one, what started as a simple typo, becomes a much bigger problem.

SQL Problem :

i tried to make option delete for my CI with sql, but why its still error?

error warning:

A Database Error Occurred

Error Number: 1054

Unknown column 'sip' in 'where clause'

select * from t_label where label = sip

Filename: E:webrbt.newsystemdatabaseDB_driver.php

Line Number: 330


function hapus($id_user){
            if($this->session->userdata('username')==TRUE) {
                $name = $this->db->query("select USER_NAME from t_user where USER_ID = $id_user")->row();
                $id_label = $this->db->query("select * from t_label where label = $name->USER_NAME")->row();
                $this->db->query("delete from t_label, t_publisher where t_label.id_label = t_publisher.id_label and t_label.id_label = $id_label->id_label");
                $this->db->delete('t_user', array('USER_ID' => $id_user));

whats wrong with my code? really need help here

Solution :

You need to quote the string. Try this:

$id_label = $this->db->query("select * from t_label where label = '" . $name->USER_NAME . "'")->row();

Finding SQL syntax errors can be complicated, but there are some tips on how to make it a bit easier. Using the aforementioned Error List helps in a great way. It allows the user to check for errors while still writing the project, and avoid later searching through thousands lines of code.

Leave a Reply

Your email address will not be published. Required fields are marked *