Using WHERE Clause in server side processing - Error Unknown column 'Adam' in 'where clause'

Using WHERE Clause in server side processing - Error Unknown column 'Adam' in 'where clause'

dasapadasapa Posts: 17Questions: 3Answers: 0

Hi,

i am using server side processing and i have to modify where clause to display data. I use this code:

$sWhere .= ($sWhere ? ' AND ' : ' WHERE ') . 'Player = ' . $name;

Value of $name in this case is Adam and there is a column in DB called Player but i receive this error: Error Unknown column 'Adam' in 'where clause'. Any help?

Thanks

Answers

  • tposzytektposzytek Posts: 5Questions: 1Answers: 0

    Hi! If you look at the final, generated query you will probably find out, that the "where" clause looks something like:
    WHERE Player = Adam
    Whichever relative DB you're using, providing value without brackets is interpretted as a reference to another column which in your case does not exist.
    To solve the problem try to transform your code into:
    $sWhere .= ($sWhere ? ' AND ' : ' WHERE ') . 'Player = "' . $name . '"';

    Regadrs!

This discussion has been closed.