Diego_sf93 Diego_sf93 - 2 months ago 9
MySQL Question

Put double quotes in a mysql string with PHP

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?

Answer

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()';