I am running the following query :
SELECT @newNo := MAX( category_code ) FROM category_master;
INSERT INTO category_master VALUES (@newNo +1, 'Test')
The query runs flawlessly in phpmyadmin but it shows a database error when run using codeigniter :
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 'INSERT INTO category_master VALUES(@newNo+1, 'Test')' at line 2
what could be the reason ?? In codeigniter model i use the following code :
$query = 'SELECT @newNo := MAX(category_code) FROM category_master;
INSERT INTO category_master VALUES(@newNo+1,
\''.$category_name.'\')';
$result = $this -> db -> query($query);