dsfsw1233 2013-08-08 21:57
浏览 84
已采纳

用PHP将双引号放在mysql字符串中

I have this code in PHP:

$_pagi_sql='SELECT * FROM programas WHERE MATCH(titulo, texto,pais) AGAINST ('"$criterio"' IN BOOLEAN MODE) AND operador=34 And validez >= NOW()';

I want to put exactly this string in the variable $_pagi_sql:

SELECT * FROM programas WHERE MATCH(titulo, texto,pais) AGAINST ('"STH"' IN BOOLEAN MODE) AND operador=34 And validez >= NOW()

However the double quotes are not properly stored in the variable $_pagi_sql

How can it be done?

  • 写回答

2条回答 默认 最新

  • dtlab08822 2013-08-08 21:59
    关注

    You can enter double quotes by adding slashes before your single quotes.

    $_pagi_sql='SELECT * FROM programas WHERE MATCH(titulo, texto,pais) AGAINST (\'"$criterio"\' IN BOOLEAN MODE) AND operador=34 And validez >= NOW()';
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?