Search not working

Search not working

tcash21tcash21 Posts: 13Questions: 0Answers: 0
edited May 2012 in DataTables 1.9
I'm using MSSQL and therefore had to remove the mysql_real_escape_string() function from the searching.

I tried replacing it with this alternative:
http://stackoverflow.com/questions/574805/how-to-escape-strings-in-mssql-using-php
[code]
function mssql_escape($data) {
if(is_numeric($data))
return $data;
$unpacked = unpack('H*hex', $data);
return '0x' . $unpacked['hex'];
}
[/code]

But that gave me errors. I also tried addslashes(). I've now resorted to not having any escape function so my code looks like this:
[code]
$sWhere = "";
if ( isset($_GET['sSearch']) && $_GET['sSearch'] != "" )
{
$sWhere = "WHERE (";
for ( $i=0 ; $i

Replies

  • snarf2larfsnarf2larf Posts: 64Questions: 0Answers: 0
    edited May 2012
    Have you tried outputting the SQL query generated and running that on your database to see if there are results or not? If there are any syntax errors through MSSQL you should be able to hunt them down.
  • tcash21tcash21 Posts: 13Questions: 0Answers: 0
    I'm not sure how to output the query after providing some parameters to the Where, Order and Limit parts of the SQL statement. Sorry I'm new to jQuery and js.

    Is there a way to fire off an alert that will output the SQL query each time I search?
  • tcash21tcash21 Posts: 13Questions: 0Answers: 0
    I had to use this in the WHERE statement "CONVERT(VARCHAR, ColumnName)" to convert it from NVARCHAR to VARCHAR. Stupid MSSQL.
This discussion has been closed.