RE: MySQL query failing on apostrophe in data

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> How do I avoid the problem in the subject hereto?  SELECT query uses
> variable in the WHERE clause.  Fails on the following query:
>
> SELECT Tbl.fld FROM Tbl WHERE Tbl.fld2='11301201 0603A HKA 3902 #3708_JD's
> AE Exp' AND ...

Escape it.
 SELECT Tbl.fld FROM Tbl WHERE Tbl.fld2='11301201 0603A HKA 3902 #3708_JD\'s
AE Exp' AND ...

Use mysql_escape_string() or addslashes()
http://www.php.net/manual/en/function.mysql-escape-string.php
http://www.php.net/manual/en/function.addslashes.php

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux