Forum Moderators: coopster

Message Too Old, No Replies

Problem with a sql query in php

         

turbohost

10:44 am on Feb 13, 2005 (gmt 0)

10+ Year Member



Hi Guys,

Got a problem with a mysql query in php. The query

$present=$DB_site->query_first("SELECT bla FROM titles WHERE title='$something'");

returns an error when $something contains a '

How can I solve this?

Thx,
Turbo

dmmh

10:58 am on Feb 13, 2005 (gmt 0)

10+ Year Member



you probably arent sanitizing user input. beside the fact this will generate errors such as yours, it is EXTEREMELY dangerous not to do so.

$present=$DB_site->query_first("SELECT bla FROM titles WHERE title='".mysql_real_escape_string(trim($something))."'");

if you dont sanitise user input, you are vunarable to SQL injection ( [google.nl...] )

;)