-2

As my address bar comes with,

localhost/likeus/index.php/mov/detail/14

If I put any other value instead of 14 it will shows blank as we all know there is no data in the database table. But if I put something like --124*7jlkl=+ or blank it shows an error like this,

A Database Error Occurred

Error Number: 1064

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 1

SQL code:

select * 
from list 
where id!=-- and lang = '' and status = '1' order by limit 5

Filename: D:\wamp\wamp\www\likeus\system\database\DB_driver.php

Line Number: 330

In simple php we can do,

$select_up = "SELECT * FROM list WHERE id =-=- or someting ";
$result_up = mysql_query($select_up);

if($result_up)
$fetch = mysql_fetch_assoc($result_up);
else 
{
    header("location:error.php");
}

So then how can I handle such an error in CI, please help with it with proper lines of code.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459

1 Answers1

0

use mysql_real_escape_string() for each input

Alex Shesterov
  • 26,085
  • 12
  • 82
  • 103
Notepad
  • 1,659
  • 1
  • 12
  • 14