1

I'm currently working with PHP 5.4.x and SQL Server 7 and I'm having TONS of issues with the PDO object for the ODBC Driver (Which is the only one that works on Sql Server 7), Statements throw errors everywhere ....

I finally got it working using PDO::query() method, BUT I need to escape the Input .... And PDO::quote IS NOT WORKING, I red the Documentation on php pdo docs about PDO and it says that PDO::quote is Not well implemented on PDO_ODBC, which might explain why im getting errors.

For Example: this

$escapedString = $pdoObject->quote($myQueryString);

returns False, it does not return the escaped string.

That been said,

Do you know a good way to escape input to prevent SQL INJECTION???

PS: Due to driver issues (old tech) I CANNOT Trust in SQL Statements, so is not an option.

Any ideas??

EDIT:

For Example. This does not work

getQueryFromFile is only retrieving a query from a file.

and SqlServerPdo is just a wrapper class I wrote over the PHP PDO so I get the connection as a Singleton

For the Record, the query actually WORKS, it has been tested on the Sql Server Engine

$conn = SqlServerPdo::connect();

$query = SqlServerPdo::getQueryFromFile('STUDENTS_FIND');

$statement = $conn->prepare($query);

$statement->bindParam(':id', $id, PDO::PARAM_INT);}

$statement->execute();

This throws the error:

text is incompatible with int (SQLExecute[206] at ext\pdo_odbc\odbc_stmt.c:133)

It seems as if the statement is treating the :id param as a text, not as an INT.

bindValue returns the same error

Gabriel Matusevich
  • 3,835
  • 10
  • 39
  • 58

0 Answers0