Passing single quote within a query

2004-12-09 Thread Nestor Florez
Hello world, I am passing a a string Joe's car as part of the SQL query to be inserted to a String field. $field=Joe's car; $query=insert into mytable values('$field'); Do you generally change the quote to a double quote before inserting or what is the recomended way, because otherwise the

Re: Passing single quote within a query

2004-12-09 Thread Steve Davies
backslash escape the quote: $field=Joe\'s car; or if you're using PHP you can turn this on automatically HTH Steve Nestor Florez wrote: Hello world, I am passing a a string Joe's car as part of the SQL query to be inserted to a String field. $field=Joe's car; $query=insert into mytable

Re: Passing single quote within a query

2004-12-09 Thread Robert J Taylor
Nestor, You would do better to use prepared statements. When a parameter is substituted into the prepared statement it is automatically quoted -- and you are protected from SQL Injection attacks. The reason your script is failing is that the single quote in $field is being interpreted as the