Question

I have just change my hosting, before all my PHP scripts worked fine

but now i get many mysql error like this:

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 column = \'value\' 

it seems that there is a double quote in some script

there is a way to resolve without update all my PHP scripts?

EDIT: example of PHP code

function test( $table,$column, $where ){

if( get_magic_quotes_gpc() ) { $where = strip_tags( trim( $where ) ); }
else{  $where = strip_tags( mysql_real_escape_string( trim( $where ) ) ); }

$where = "AND id = '" . $where . "' ";

$query = "SELECT " . $column . " FROM " . $table . " WHERE 1 " . $where . " LIMIT 1";
//...

No correct solution

OTHER TIPS

You have to either pass the $table variable or declare it as global, if defined outside.

function test( $column, $where ){
global $table;    

if( get_magic_quotes_gpc() ) { $where = strip_tags( trim( $where ) ); }
else{  $where = strip_tags( mysql_real_escape_string( trim( $where ) ) ); }

$where = "AND id = '" . $where . "' ";

$query = "SELECT " . $column . " FROM " . $table . " WHERE 1 " . $where . " LIMIT 1";

What happens if your function looks like this?

function test( $table,$column, $where ){
    $where=stripslashes($where);
    $where = strip_tags(mysql_real_escape_string(trim( $where )));
    $where = "AND id = '" . $where . "' ";
    $query = "SELECT " . $column . " FROM " . $table . " WHERE 1 " . $where . " LIMIT 1";
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top