Simple error with Database library using codeIgniter - mysql

$this->db->select('*');
$this->db->from('product');
$this->db->where('del_in !=',1);
$query=$this->db->get();
return $query;
I am getting sql following error Please help me to solve this...
ERROR:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL
server version for the right syntax to use near '' at line 3
SELECT * FROM (`product`) WHERE `del_in` != 1 LIMIT 0 ,
Filename: D:\wamp\www\shopcart\system\database\DB_driver.php

Just make sure column name and table name are correct. After that try this code
$this->db->select('*');
$this->db->where('del_in !=',1);
$this->db->from('product');
$query=$this->db->get();
return $query->result();

Related

Error returned when I executed an sql query, can anyone help me resolve this problem?

Error returned is:
You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use
near
''id_partenaire','logo_partenaire','logo_tnb','favicon','global_primary_color','g'
at line 1
This is my query:
INSERT
INTO
CONFIGURATIONS_PARTENAIRES
('id_partenaire','logo_partenaire','logo_tnb','favicon','global_primary_color','global_secondary_color','global_infos_color','global_font_color','font_color_dark','font_color_light','moteur_ht','moteur_og','moteur_ht_primary_color','moteur_ht_secondary_color','moteur_og_primary_color','moteur_og_secondary_color')
VALUES
(16,'logo-2020-350x73-1.png','logo_tb.png','icon.gif','#ebebeb','#ffffff','#f50e98','#000000','#ffffff','#f06f05','1','1','#000000','#f06f05','#000000','#f06f05');
With back ticks instead of the quotes on the column names it should run better
INSERT INTO
CONFIGURATIONS_PARTENAIRES
(`id_partenaire`,
`logo_partenaire`,
`logo_tnb`,
`favicon`,
`global_primary_color`,
`global_secondary_color`,
`global_infos_color`,
`global_font_color`,
`font_color_dark`,
`font_color_light`,
`moteur_ht`,
`moteur_og`,
`moteur_ht_primary_color`,
`moteur_ht_secondary_color`,
`moteur_og_primary_color`,
`moteur_og_secondary_color`)
VALUES
( 16
,'logo2020-350x73-1.png'
,'logo_tb.png'
,'icon.gif'
,'#ebebeb'
,'#ffffff'
,'#f50e98'
,'#000000'
,'#ffffff'
,'#f06f05'
,'1'
,'1'
,'#000000'
,'#f06f05'
,'#000000'
,'#f06f05');

PARSE_ERROR MySQL

These lines give me the parse error, ı checked my syntax many times but it seems alright to me. I don't understand why does it give this error
code:
INSERT INTO club_request(RequestID,"Besiktas")
SELECT RequestID
FROM Request
WHERE RequestName = "New goalkeeper";
error:
ER_PARSE_ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"Besiktas") SELECT RequestID FROM Request WHERE RequestName = "New goalkeeper"' at line 1
INSERT INTO club_request(RequestID, ClubName)
SELECT RequestID, ClubName
FROM Request, Club
WHERE RequestName = "New goalkeeper" AND ClubName = "Besiktas";
lately I have turned it into this and now it works as I wanted, can't we insert partial value from select clause and partial value as a string ?

NODEJS MySQL Bindings throws ER_PARSE_ERROR 1064

Given the following:
let sql: any = 'SELECT * FROM test_people ORDER BY :column :direction LIMIT :limit, :offset';
let binds: any = { column: 'name', direction: 'desc', limit: '1', offset: '10' };
let result = await mysql.query(sql, binds);
For whatever reason it throws mysql syntax error, if I replace the bindings and write it hard-coded without the bindings then the query actually works and fetches the result. not sure what is wrong here. help ! :)
BTW, I also tried it with the question marks version, getting same syntax error.
Error output:
...
code: 'ER_PARSE_ERROR',
errno: 1064,
'You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near \':column :direction LIMIT :limit, :offset\' at line 1',
...
Appreciate any solution,
Only values can be bound. Column names (in ORDER BY), and the :direction cannot be bound. Also FYI table names, database names and other parts of the SQL syntax cannot be bound.

How to append string to column

I want to append a string as a prefix to the values of a column. When I try this one:
UPDATE ortsbezug SET Zusatz = CONCAT("Nordseite",Zusatz) WHERE FSOrtID = 2425;
I always get an error:
1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ') FROM ortsbezug WHERE FSOrtID = 2425 AND (Zusatz <> CONCAT("Nordseite" OR Zus' at line 1
Anyone has an idea where exactly the error could be?
screenshot of query and error

SQL syntax Limit 1 error

WordPress database error
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LIMIT 1' at line 4
for query
SELECT wp_wpsp_templates_fonts.name
FROM wp_wpsp_templates_fonts
WHERE wp_wpsp_templates_fonts.fontID =
LIMIT 1
made by
require('wp-blog-header.php'), require_once('wp-includes/template-loader.php'), include('/themes/twentyten/wpsp-sales-page.php'), require_once('/plugins/wpsp/wpsp-frontend.php'), TemplatesModel->GetFontByID
Below is the code.
function GetFontByID($fontID) {
global $wpdb;
$results = $wpdb->get_results(" SELECT ".$wpdb->prefix."wpsp_templates_fonts.name
FROM ".$wpdb->prefix."wpsp_templates_fonts
WHERE ".$wpdb->prefix."wpsp_templates_fonts.fontID = ".mysql_real_escape_string($fontID)."
LIMIT 1");
return $results[0]->name;
}
Any ideas on how to fix this issue?
GetFontByID() needs a parameter passed to it. Currently, the param appears blank.