• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
SQL Injection problem

#1
I'm begginer with CodeIgniter and I stucked on problem with counting. 

I try to count records in my database using code below:

$count = $this->db->where(['title'=> $this->input->post('title'), 'name'=> $this->input->post('name')])->from("table")->count_all_results();

Then I check the query in development using code below:

echo $this->db->last_query();

Everything is ok, if I send data like title: test1 and name: test2:

SELECT COUNT(*) AS `numrows` FROM `table` WHERE `title` = 'test1' AND `name` = 'test2'

But if I send data similar to SQL Injection: test1 AND id = 1' it changes to: 

SELECT COUNT(*) AS `numrows` FROM `table` WHERE `opis` = 'test1 AND `id` = 1\'' AND `nazwisko` = 'test2'

How to prevent changing in this query id to `id` ? If I send data "test1 ANDY = 1' the query is without ` around id.
Reply


Messages In This Thread
SQL Injection problem - by ChrisPL - 03-04-2018, 07:06 AM
RE: SQL Injection problem - by Kmycic - 03-05-2018, 01:23 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.